Educational Codeforces Round 81 (Rated for Div. 2)


A. Display The Number
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
3
4
Output
7
11
----------------------------------------------------------------------------------------------------
B. Infinite Prefixes
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
6 10
010010
5 3
10101
1 0
0
2 0
01
Output
3
0
1
-1
----------------------------------------------------------------------------------------------------
C. Obtain The String
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
aabce
ace
abacaba
aax
ty
yyt
Output
1
-1
3
----------------------------------------------------------------------------------------------------
D. Same GCDs
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
4 9
5 10
42 9999999967
Output
6
1
9999999966
----------------------------------------------------------------------------------------------------
E. Permutation Separation
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3 1 2
7 1 4
Output
4
Input
4
2 4 1 3
5 9 8 3
Output
3
Input
6
3 5 1 6 2 4
9 1 9 9 1 9
Output
2
----------------------------------------------------------------------------------------------------
F. Good Contest
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2
1 2
1 2
Output
499122177
Input
2
42 1337
13 420
Output
578894053
Input
2
1 1
0 0
Output
1
Input
2
1 1
1 1
Output
1
----------------------------------------------------------------------------------------------------
