Codeforces Round 564 (Div. 2)


A. Nauuo and Votes
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 7 0
Output
-
Input
2 0 1
Output
+
Input
1 1 0
Output
0
Input
0 0 1
Output
?
----------------------------------------------------------------------------------------------------
B. Nauuo and Chess
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
Output
2
1 1
1 2
Input
4
Output
3
1 1
1 3
3 1
3 3
----------------------------------------------------------------------------------------------------
C. Nauuo and Cards
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
0 2 0
3 0 1
Output
2
Input
3
0 2 0
1 0 3
Output
4
Input
11
0 0 0 5 0 0 0 4 0 0 11
9 2 6 0 8 1 7 0 3 0 10
Output
18
----------------------------------------------------------------------------------------------------
D. Nauuo and Circle
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 2
1 3
2 4
Output
16
Input
4
1 2
1 3
1 4
Output
24
----------------------------------------------------------------------------------------------------
E1. Nauuo and Pictures (easy version)
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 1
0 1
2 1
Output
332748119
332748119
Input
1 2
1
1
Output
3
Input
3 3
0 1 1
4 3 5
Output
160955686
185138929
974061117
----------------------------------------------------------------------------------------------------
E2. Nauuo and Pictures (hard version)
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 1
0 1
2 1
Output
332748119
332748119
Input
1 2
1
1
Output
3
Input
3 3
0 1 1
4 3 5
Output
160955686
185138929
974061117
----------------------------------------------------------------------------------------------------
F. Nauuo and Portals
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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