#abc271b. [abc271_b]Maintain Multiple Sequences
[abc271_b]Maintain Multiple Sequences
Problem Statement
There are sequences of integers.
The -th sequence has terms; the -th term of the -th sequence is .
You are given queries. For the -th query, given integers and , find the -th term of the -th sequence.
Constraints
- $1 \\leq a_{i, j} \\leq 10^9 \\, (1 \\leq i \\leq N, 1 \\leq j \\leq L_i)$
- $1 \\leq s_k \\leq N, 1 \\leq t_k \\leq L_{s_k} \\, (1 \\leq k \\leq Q)$
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print lines. The -th line should contain the answer to the -th query.
Sample Input 1
2 2
3 1 4 7
2 5 9
1 3
2 1
Sample Output 1
7
5
The -st sequence is and the -nd is .
The answer to each query is as follows:
- The -rd term of the -st sequence is .
- The -st term of the -nd sequence is .
Sample Input 2
3 4
4 128 741 239 901
2 1 1
3 314 159 26535
1 1
2 2
3 3
1 4
Sample Output 2
128
1
26535
901