Codeforces Round 347 (Div. 2)


A. Complicated GCD
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 2
Output
1
Input
61803398874989484820458683436563811772030917980576 61803398874989484820458683436563811772030917980576
Output
61803398874989484820458683436563811772030917980576
----------------------------------------------------------------------------------------------------
B. Rebus
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
? + ? - ? + ? + ? = 42
Output
Possible
9 + 13 - 39 + 28 + 31 = 42
Input
? - ? = 1
Output
Impossible
Input
? = 1000000
Output
Possible
1000000 = 1000000
----------------------------------------------------------------------------------------------------
C. International Olympiad
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
IAO'15
IAO'2015
IAO'1
IAO'9
IAO'0
Output
2015
12015
1991
1989
1990
Input
4
IAO'9
IAO'99
IAO'999
IAO'9999
Output
1989
1999
2999
9999
----------------------------------------------------------------------------------------------------
D. Graph Coloring
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
1 2 B
3 1 R
3 2 B
Output
1
2 
Input
6 5
1 3 R
2 3 R
3 4 B
4 5 R
4 6 R
Output
2
3 4 
Input
4 5
1 2 R
1 3 R
2 3 B
3 4 B
1 4 B
Output
-1
----------------------------------------------------------------------------------------------------
E. To Hack or not to Hack
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
120 120 1
61 61 120
-61 61 120
0 0 0
Output
1
Input
4
0 0 119
-3 -17 -42
0 7 0
51 0 0
Output
2
----------------------------------------------------------------------------------------------------
