Codeforces Round 698 (Div. 1)


A. Nezzar and Board
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
6
2 1
1 2
3 0
2 3 7
2 -1
31415926 27182818
2 1000000000000000000
1 1000000000000000000
2 -1000000000000000000
-1000000000000000000 123
6 80
-5 -20 13 -14 -2 -11
Output
YES
YES
NO
YES
YES
NO
----------------------------------------------------------------------------------------------------
B. Nezzar and Binary String
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
5 2
00000
00111
1 5
1 3
2 1
00
01
1 2
10 6
1111111111
0110001110
1 10
5 9
7 10
1 7
3 5
6 10
5 2
10000
11000
2 5
1 3
Output
YES
NO
YES
NO
----------------------------------------------------------------------------------------------------
C. Nezzar and Nice Beatmap
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
0 0
5 0
4 2
2 1
3 0
Output
1 2 5 3 4
----------------------------------------------------------------------------------------------------
D. Nezzar and Hidden Permutations
time limit per test: 5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
4 2
1 2
3 4
6 4
1 2
1 3
3 5
3 6
2 1
1 2
Output
1 2 3 4
3 4 1 2
2 3 4 1 6 5
1 4 3 2 5 6
1 2
1 2
----------------------------------------------------------------------------------------------------
E. Nezzar and Tournaments
time limit per test: 5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3 4 3
1 2 7
3 4 5 6
3 5
1 1 10
3 5
Output
-4
9
Input
7 8 12
958125 14018 215153 35195 90380 30535 204125
591020 930598 252577 333333 999942 1236 9456 82390
3 123458
2 4 444444
3 123456
1 2 355555
3 123478
3 1111
2 6 340324
3 1111
2 8 999999
2 7 595959
3 222222
3 100
Output
1361307
1361311
1702804
1879305
1821765
1078115
1675180
----------------------------------------------------------------------------------------------------
F. Nezzar and Chocolate Bars
time limit per test: 5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
1 1
2
Output
4
Input
1 1
1
Output
0
Input
1 5
1234
Output
15630811
Input
2 1
2 3
Output
476014684
Input
10 33
10 20 30 40 50 60 70 80 90 100
Output
675105648
----------------------------------------------------------------------------------------------------
