Codeforces Round 360 (Div. 1)


A. NP-Hard Problem
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
4 5
2 3 5 12
Output
Yes
Input
2 7
2 3
Output
No
----------------------------------------------------------------------------------------------------
C. The Values You Can Make
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 18
5 6 1 10 12 2
Output
16
0 1 2 3 5 6 7 8 10 11 12 13 15 16 17 18 
Input
3 50
25 25 50
Output
3
0 25 50 
----------------------------------------------------------------------------------------------------
D. Dividing Kingdom II
time limit per test: 6 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 6 5
5 4 86
5 1 0
1 3 38
2 1 33
2 4 28
2 3 40
3 5
2 6
1 3
2 3
1 6
Output
-1
33
-1
-1
33
----------------------------------------------------------------------------------------------------
E. TOF
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
1 2
2 3
3 1
Output
2998
Input
6 7
1 2
2 3
3 1
3 4
4 5
5 6
6 4
Output
3001
----------------------------------------------------------------------------------------------------
