-
Notifications
You must be signed in to change notification settings - Fork 138
/
Copy pathSolution.java
34 lines (31 loc) · 916 Bytes
/
Solution.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n;
n = sc.nextInt();
ArrayList<ArrayList<Integer>> arr = new ArrayList<ArrayList<Integer>>();
for (int i = 0; i < n; i++) {
int size, tmp;
size = sc.nextInt();
arr.add(new ArrayList<Integer>());
for (int j = 0; j < size; j++) {
tmp = sc.nextInt();
arr.get(i).add(tmp);
}
}
int q;
q = sc.nextInt();
for (int i = 0; i < q; i++) {
int x, y;
x = sc.nextInt()-1;
y = sc.nextInt()-1;
try {
System.out.println(arr.get(x).get(y));
} catch (Exception e) {
System.out.println("ERROR!");
}
}
}
}