Codeforces Round 801 (Div. 2) and EPIC Institute of Technology Round


A. Subrectangle Guess
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 1
3
4 4
2 12 6 10
3 15 16 4
1 13 8 11
14 7 9 5
2 3
-7 5 2
0 8 -3
Output
1
9
4
----------------------------------------------------------------------------------------------------
B. Circle Game
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1
37
2
100 100
Output
Mike
Joe
----------------------------------------------------------------------------------------------------
C. Zero Path
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 1
1
1 2
1 -1
1 4
1 -1 1 -1
3 4
1 -1 -1 -1
-1 1 1 -1
1 1 1 -1
3 4
1 -1 1 1
-1 1 -1 1
1 -1 1 1
Output
NO
YES
YES
YES
NO
----------------------------------------------------------------------------------------------------
D1. Tree Queries (Easy Version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1
2
1 2
10
2 4
2 1
5 7
3 10
8 6
6 1
1 3
4 7
9 6
Output
0
1
2
----------------------------------------------------------------------------------------------------
D2. Tree Queries (Hard Version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1
2
1 2
10
2 4
2 1
5 7
3 10
8 6
6 1
1 3
4 7
9 6
Output
0
1
2
----------------------------------------------------------------------------------------------------
E. Ambiguous Dominoes
time limit per test: 8 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
1 2
Output
-1
Input
2
1 1
1 2
Output
2 2
2 1
1 1
LR
LR
UU
DD
Input
10
1 3
1 1
2 1
3 4
1 5
1 5
3 1
2 4
3 3
4 1
Output
4 5
1 2 5 1 5
3 4 1 3 1
1 2 4 4 1
1 3 3 3 1
LRULR
LRDLR
ULRLR
DLRLR
UULRU
DDUUD
LRDDU
LRLRD
----------------------------------------------------------------------------------------------------
