Codeforces Round 562 (Div. 1)


A. Increasing by Modulo
time limit per test: 2.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 3
0 0 0 1 2
Output
0
Input
5 7
0 6 1 3 2
Output
1
----------------------------------------------------------------------------------------------------
B. Good Triple
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
010101
Output
3
Input
11001100
Output
0
----------------------------------------------------------------------------------------------------
C. And Reachability
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 3
1 3 0 2 1
1 3
2 4
1 4
Output
Fou
Shi
Shi
----------------------------------------------------------------------------------------------------
D. Anagram Paths
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 4
1 ?
1 ?
2 ?
2 a
3 b
2 b
Output
Shi 351
Shi 1
Fou
Shi 2
Input
5 2
1 ?
1 ?
2 ?
3 ?
4 a
5 b
Output
Shi 352
Shi 3
----------------------------------------------------------------------------------------------------
E. Xor Permutations
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
0 1 2 3
Output
Shi
2 0 1 3 
2 1 3 0 
Input
2
0 0 0 0
Output
Shi
0 1 2 3 
0 1 2 3 
Input
2
0 1 2 2
Output
Fou
----------------------------------------------------------------------------------------------------
