Codeforces Round 483 (Div. 1) [Thanks, Botan Investments and Victor Shaburov!]


A. Finite or not?
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
6 12 10
4 3 10
Output
Finite
Infinite
Input
4
1 1 2
9 36 2
4 12 3
3 5 4
Output
Finite
Finite
Finite
Infinite
----------------------------------------------------------------------------------------------------
B. XOR-pyramid
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
8 4 1
2
2 3
1 2
Output
5
12
Input
6
1 2 4 8 16 32
4
1 6
2 5
3 4
1 2
Output
60
30
12
3
----------------------------------------------------------------------------------------------------
C. Elevator
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
3 5
5 3
Output
10
Input
2
5 3
3 5
Output
12
----------------------------------------------------------------------------------------------------
D. Arkady and Rectangles
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
-1 -1 1 1
-4 0 0 4
0 0 4 4
-4 -4 0 0
0 -4 4 0
Output
5
Input
4
0 0 4 4
-4 -4 0 0
0 -4 4 0
-2 -4 2 4
Output
5
----------------------------------------------------------------------------------------------------
E. NN country
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
1 1 1 4 5 6
4
4 2
5 4
1 3
6 7
6
4 5
3 5
7 2
4 5
3 2
5 3
Output
1
3
-1
1
2
3
Input
7
1 1 2 3 4 1
4
4 7
3 5
7 6
7 6
6
4 6
3 1
3 2
2 7
6 3
5 3
Output
1
-1
-1
1
-1
1
----------------------------------------------------------------------------------------------------
