Codeforces Round 934 (Div. 2)


A. Destroying Bridges
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
2 0
2 1
4 1
5 10
5 3
4 4
Output
2
1
4
1
5
1
----------------------------------------------------------------------------------------------------
B. Equal XOR
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2 1
1 2 2 1
6 1
6 4 2 1 2 3 1 6 3 5 5 4
4 1
1 2 3 4 1 2 3 4
6 2
5 1 3 3 5 1 2 6 4 6 4 2
Output
2 1
2 1
6 4
1 3
1 2
1 2
5 1 3 3
6 4 2 4
----------------------------------------------------------------------------------------------------
C. MEX Game 1
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
4
0 0 1 1
4
0 1 2 3
2
1 1
Output
2
1
0
----------------------------------------------------------------------------------------------------
D. Non-Palindromic Substring
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
4 4
aaab
1 4
1 3
3 4
2 4
3 2
abc
1 3
1 2
5 4
pqpcc
1 5
4 5
1 3
2 4
2 1
aa
1 2
12 1
steponnopets
1 12
Output
9
0
2
5
5
2
14
0
2
5
0
65
----------------------------------------------------------------------------------------------------
E. Tree Compass
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1
2
1 2
4
1 2
1 3
1 4
7
2 7
3 2
6 4
5 7
1 6
6 7
Output
1
1 0
2
1 1
2 1
2
1 1
2 1
3
6 1
7 1
2 1
----------------------------------------------------------------------------------------------------
F1. Counting Is Fun (Easy Version)
time limit per test: 3 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
4
3 1 998244853
4 1 998244353
3 2 998244353
343 343 998244353
Output
4
7
10
456615865
----------------------------------------------------------------------------------------------------
F2. Counting Is Fun (Hard Version)
time limit per test: 3 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
4
3 1 998244853
4 1 998244353
3 2 998244353
343 343 998244353
Output
4
7
10
456615865
----------------------------------------------------------------------------------------------------
