Codeforces Round 692 (Div. 1, based on Technocup 2021 Elimination Round 3)


A. Peaceful Rooks
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3 1
2 3
3 2
2 1
1 2
5 3
2 3
3 1
1 2
5 4
4 5
5 1
2 2
3 3
Output
1
3
4
2
----------------------------------------------------------------------------------------------------
B. Grime Zoo
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
0?1
2 3
Output
4
Input
?????
13 37
Output
0
Input
?10?
239 7
Output
28
Input
01101001
5 7
Output
96
----------------------------------------------------------------------------------------------------
C. Poman Numbers
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 -1
ba
Output
Yes
Input
3 -7
abc
Output
No
Input
7 -475391
qohshra
Output
Yes
----------------------------------------------------------------------------------------------------
D. The Thorny Path
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
1 0
Output
0
Input
2 1
1 2
Output
332748118
Input
5 5
1 4
5 2
4 3
1 5
5 4
Output
931694730
----------------------------------------------------------------------------------------------------
F. My Beautiful Madness
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
1 4
1 1 1
1 1 1
2 1 1
3 0
Output
Yes
Input
5 3
1 2
1 3
3 4
4 5
1 1 2
1 5 5
3 1
Output
No
Input
10 6
1 2
2 3
3 4
4 7
7 10
2 5
5 6
6 8
8 9
1 9 9
1 9 8
1 8 5
3 0
3 1
3 2
Output
No
Yes
Yes
----------------------------------------------------------------------------------------------------
