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


A. 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 
----------------------------------------------------------------------------------------------------
B. 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
----------------------------------------------------------------------------------------------------
C. 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
----------------------------------------------------------------------------------------------------
D. 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
----------------------------------------------------------------------------------------------------
E. Andryusha and Nervous Barriers
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10 5 1
3 2 3 10
Output
7
Input
10 5 2
3 1 3 10
5 3 5 10
Output
16
Input
10 5 2
3 1 3 7
5 3 5 10
Output
14
Input
10 15 4
7 3 9 5
6 4 10 1
1 1 4 10
4 11 11 20
Output
53
----------------------------------------------------------------------------------------------------
F. Intranet of Buses
time limit per test: 10 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2
0 0
0 1
1 1
1 0
Output
1.000000000
Input
2 2
0 0
1 0
Output
0.000000000
----------------------------------------------------------------------------------------------------
