CodeTON Round 5 (Div. 1 + Div. 2, Rated, Prizes!)


A. Tenzing and Tsondu
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
1 3
9
1 2 3
2 3
1 2
1 1 1
3 2
1 2 3
1 1
3 3
1 1 1
2 2 2
10 10
1 2 3 3 2 2 1 1 2 2
3 3 3 3 2 1 1 1 1 1
10 10
1 2 3 4 5 6 7 8 9 10
6 7 8 9 10 11 1 1 1 1
Output
Tsondu
Draw
Tsondu
Tenzing
Draw
Draw
----------------------------------------------------------------------------------------------------
B. Tenzing and Books
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
5 7
1 2 3 4 5
5 4 3 2 1
1 3 5 7 9
5 2
3 2 3 4 5
5 4 3 2 1
3 3 5 7 9
3 0
1 2 3
3 2 1
2 2 2
Output
Yes
No
Yes
----------------------------------------------------------------------------------------------------
C. Tenzing and Balls
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
5
1 2 2 3 3
4
1 2 1 2
Output
4
3
----------------------------------------------------------------------------------------------------
D. Tenzing and His Animal Friends
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 4
1 3 2
1 4 2
2 3 1
2 5 1
Output
4 4
10000 1
10010 1
10100 1
11110 1
Input
3 0
Output
inf
----------------------------------------------------------------------------------------------------
E. Tenzing and Triangle
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 6 1
1 2 1
2 1 1
1 1 1
3 2 6
Output
4
Input
6 7 1
4 2 1
3 3 1
5 1 4
3 2 5
4 1 1
0 6 4
Output
4
Input
10 4 100
0 0 1
0 1 1
0 2 50
0 3 200
1 0 1
1 1 1
1 2 1
2 0 200
2 1 200
3 0 200
Output
355
----------------------------------------------------------------------------------------------------
F. Tenzing and Tree
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
1 2
3 2
2 4
Output
0 3 4 5 6 
Input
1
Output
0 0 
----------------------------------------------------------------------------------------------------
G. Tenzing and Random Operations
time limit per test: 2 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
2 2 5
2 2
Output
84
Input
5 7 9
9 9 8 2 4
Output
975544726
----------------------------------------------------------------------------------------------------
H. Tenzing and Random Real Numbers
time limit per test: 1 second
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
3 2
0 1 2
1 3 3
Output
748683265
Input
3 3
0 1 2
0 1 3
0 2 3
Output
748683265
Input
3 4
0 1 2
0 1 3
1 2 3
1 2 2
Output
935854081
Input
4 4
0 1 2
0 3 4
1 1 3
1 2 4
Output
0
Input
8 12
0 1 2
0 2 3
1 3 4
0 1 4
0 5 6
0 6 7
1 7 8
0 5 8
1 3 7
1 3 8
1 4 7
1 4 8
Output
997687297
----------------------------------------------------------------------------------------------------
I. Tenzing and Necklace
time limit per test: 2 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
4
5 2
1 1 1 1 1
5 2
1 2 3 4 5
6 3
4 2 5 1 3 3
10 3
2 5 6 5 2 1 7 9 7 2
Output
3
7
5
15
----------------------------------------------------------------------------------------------------
