VK Cup 2016 - Round 2


A. Little Artem and Grasshopper
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
><
1 2
Output
FINITE
Input
3
>><
2 1 1
Output
INFINITE
----------------------------------------------------------------------------------------------------
B. Little Artem and Matrix
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2 6
2 1
2 2
3 1 1 1
3 2 2 2
3 1 2 8
3 2 1 8
Output
8 2 
1 8 
Input
3 3 2
1 2
3 2 2 5
Output
0 0 0 
0 0 5 
0 0 0 
----------------------------------------------------------------------------------------------------
C. Little Artem and Dance
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 3
1 2
2
1 2
Output
4 3 6 5 2 1
Input
2 3
1 1
2
1 -2
Output
1 2
Input
4 2
2
1 3
Output
1 4 3 2
----------------------------------------------------------------------------------------------------
D. Little Artem and Random Variable
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
0.25 0.75
0.75 0.25
Output
0.5 0.5 
0.5 0.5 
Input
3
0.125 0.25 0.625
0.625 0.25 0.125
Output
0.25 0.25 0.5 
0.5 0.25 0.25 
----------------------------------------------------------------------------------------------------
E. Little Artem and Time Machine
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
1 1 5
3 5 5
1 2 5
3 6 5
2 3 5
3 7 5
Output
1
2
1
Input
3
1 1 1
2 2 1
3 3 1
Output
0
----------------------------------------------------------------------------------------------------
F. Little Artem and 2-SAT
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 1 1
1 2
1 2
Output
SIMILAR
Input
2 1 1
1 2
1 -2
Output
0 0 
----------------------------------------------------------------------------------------------------
G. Little Artem and Graph
time limit per test: 12 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
1 2
Output
3
Input
4 3
1 2 3
Output
16
----------------------------------------------------------------------------------------------------
