Codeforces Round 403 (Div. 2, based on Technocup 2017 Finals)


A. Andryusha and Socks
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
1 1
Output
1
Input
3
2 1 1 3 2 3
Output
2
----------------------------------------------------------------------------------------------------
B. The Meeting Place Cannot Be Changed
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
7 1 3
1 2 1
Output
2.000000000000
Input
4
5 10 3 2
2 3 2 4
Output
1.400000000000
----------------------------------------------------------------------------------------------------
C. Andryusha and Colored Balloons
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 3
1 3
Output
3
1 3 2 
Input
5
2 3
5 3
4 3
1 3
Output
5
1 3 2 5 4 
Input
5
2 1
3 2
4 3
5 4
Output
3
1 2 3 1 2 
----------------------------------------------------------------------------------------------------
D. Innokenty and a Football League
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
DINAMO BYTECITY
FOOTBALL MOSCOW
Output
YES
DIN
FOO
Input
2
DINAMO BYTECITY
DINAMO BITECITY
Output
NO
Input
3
PLAYFOOTBALL MOSCOW
PLAYVOLLEYBALL SPB
GOGO TECHNOCUP
Output
YES
PLM
PLS
GOG
Input
3
ABC DEF
ABC EFG
ABD OOO
Output
YES
ABD
ABE
ABO
----------------------------------------------------------------------------------------------------
E. Underground Lab
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2 1
2 1
3 1
Output
3 2 1 3
Input
5 4 2
1 2
1 3
1 4
1 5
Output
3 2 1 3
3 4 1 5
----------------------------------------------------------------------------------------------------
F. Axel and Marston in Bitland
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2
1 2 0
2 2 1
Output
3
Input
2 3
1 2 0
2 2 1
2 2 0
Output
-1
----------------------------------------------------------------------------------------------------
