Codeforces Round 348 (VK Cup 2016 Round 2, Div. 2 Edition)


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

Examples
Input
1
Output
1
Input
2
Output
1
Input
3
Output
2
Input
4
Output
3
----------------------------------------------------------------------------------------------------
B. 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
----------------------------------------------------------------------------------------------------
C. 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 
----------------------------------------------------------------------------------------------------
D. 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
----------------------------------------------------------------------------------------------------
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
----------------------------------------------------------------------------------------------------
