#BS0000055. Thư từ (Letters)
Thư từ (Letters)
Letters
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
There are dormitories numbered from to . Dormitory contains rooms, locally numbered from to .
If all rooms are concatenated into one sequence, their global numbers range from to
All rooms of dormitory come first, then all rooms of dormitory , and so on.
There are letters. Letter contains only a global room number , where . For every letter, determine the dormitory number and the local room number inside that dormitory.
Input
- The first line contains integers .
- The second line contains .
- The third line contains in increasing order.
Output
Print lines. Line contains two integers : the dormitory number and local room number corresponding to .
Subtasks
- Subtask 1 — 20%: , .
- Subtask 2 — 30%: , .
- Subtask 3 — 50%: , ; every satisfies .
Example
Input
3 6
10 15 12
1 9 12 23 26 37
Output
1 1
1 9
2 2
2 13
3 1
3 12
Explanation
The prefix totals are . For example, belongs to dormitory because . There are rooms before that dormitory, so its local room number is .