Codeforces Round 503 (by SIS, Div. 2)


A. New Building for SIS
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
3
2 3 2
Output
2 2 3 
Input
3
1 2 3
Output
1 2 3 
----------------------------------------------------------------------------------------------------
C. Elections
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 2
1 100
Output
0
Input
5 5
2 100
3 200
4 300
5 400
5 900
Output
500
Input
5 5
2 100
3 200
4 300
5 800
5 900
Output
600
----------------------------------------------------------------------------------------------------
D. The hat
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8
2
2
Output
? 4
? 8
! 4
Input
6
1
2
3 
2
1
0
Output
? 1
? 2
? 3
? 4
? 5
? 6
! -1
----------------------------------------------------------------------------------------------------
E. Sergey's problem
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 4
1 2
2 3
2 4
2 5
Output
4
1 3 4 5 
Input
3 3
1 2
2 3
3 1
Output
1
3 
----------------------------------------------------------------------------------------------------
