-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPractical_3_4.java
More file actions
30 lines (27 loc) · 909 Bytes
/
Practical_3_4.java
File metadata and controls
30 lines (27 loc) · 909 Bytes
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
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Practical_3_4 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
String s = sc.nextLine();
ArrayList<ArrayList<String>> a = new ArrayList<ArrayList<String>>(n);
for (int i = 0; i < n; i++) {
s = sc.nextLine();
a.add(i, new ArrayList<String>(Arrays.asList(s.split("\\s"))));
}
int m = sc.nextInt();
for (int i = 0; i < m; i++) {
int x = sc.nextInt();
int y = sc.nextInt();
if (x <= a.size() && y < a.get(x-1).size() && y >= 0) {
System.out.println(a.get(x-1).get(y));
} else {
System.out.println("ERROR!");
}
}
}
}