Codeforces Round 319 (Div. 1)


A. Vasya and Petya's Game
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
Output
3
2 4 3 
Input
6
Output
4
2 4 3 5 
----------------------------------------------------------------------------------------------------
B. Invariance of Tree
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
4 3 2 1
Output
YES
4 1
4 2
1 3
Input
3
3 1 2
Output
NO
----------------------------------------------------------------------------------------------------
C. Points on Plane
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
0 7
8 10
3 4
5 0
9 12
Output
4 3 1 2 5 
----------------------------------------------------------------------------------------------------
D. Flights for Regular Customers
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
1 2 0
2 3 1
Output
2
Input
2 1
1 2 100500
Output
Impossible
Input
3 3
2 1 0
2 3 6
1 2 0
Output
8
----------------------------------------------------------------------------------------------------
E. Painting Edges
time limit per test: 6 seconds
memory limit per test: 600 megabytes
input: standard input
output: standard output

Examples
Input
3 3 2 5
1 2
2 3
1 3
1 1
2 1
3 2
3 1
2 2
Output
YES
YES
YES
NO
YES
----------------------------------------------------------------------------------------------------
