1#include <cmath>
2#include <cstdio>
3#include <vector>
4#include <iostream>
5#include <algorithm>
6//using namespace std;
7
8
9int main() {
10 /* Enter your code here. Read input from STDIN. Print output to STDOUT */
11 int n; //number of Arrays
12 int q; //number of Queries
13 int tempValue; //would be used to store the input value of each element in inner vector
14
15 //storing the number of arrays in 'n' and number of queries in 'q'
16 std::cin >> n >> q;
17
18 ////////////////////////
19 /*creation of vectors*/
20 //////////////////////
21
22 //creating 'n' number of vector<int>
23 std::vector<std::vector<int>> a(n);
24
25
26 int numberOfElements; //number of elements in each inner vector
27 //for each vector
28 for(int i = 0; i < n; i++){
29 //store the number of elements desired
30 std::cin >> numberOfElements;
31 //runs 'numberOfElements times
32 for(int j = 0; j < numberOfElements; j++){
33 std::cin >> tempValue;
34 a[i].push_back(tempValue);
35 }
36 }
37
38 ///////////////////////
39 /*queries of vectors*/
40 /////////////////////
41
42 int outVector; //stores the queried outer vector index
43 int inVector; //stores the queried inner vector index
44 //runs 'q' times
45 for(int i = 0; i < q; i++){
46 std::cin >> outVector >> inVector;
47 std::cout << a[outVector][inVector];
48 std::cout << std::endl;
49 }
50
51 return 0;
52}
53