Codeforces Round 415 (Div. 1)


A. Do you want a date?
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
4 7
Output
3
Input
3
4 3 1
Output
9
----------------------------------------------------------------------------------------------------
B. Glad to see you!
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
NIE
TAK
NIE
TAK
TAK
TAK
Output
1 1 2
1 2 1
1 1 3
1 3 1
1 2 3
1 3 2
2 2 3
----------------------------------------------------------------------------------------------------
C. Find a car
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 1 1 1 1
3 2 5 4 5
1 1 5 5 10000
1 4 2 5 2
Output
1
13
93
0
----------------------------------------------------------------------------------------------------
D. Hitchhiking in the Baltic States
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
6 6
1 2
3 4
2 2
1 4
Output
3
----------------------------------------------------------------------------------------------------
E. Surprise me!
time limit per test: 8 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2 3
1 2
2 3
Output
333333338
Input
5
5 4 3 1 2
3 5
1 2
4 3
2 5
Output
8
----------------------------------------------------------------------------------------------------
