Codeforces Round 880 (Div. 1)


A. k-th equality
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
1 1 1 9
2 2 3 1
2 2 1 1
1 5 6 42
1 6 6 10000000
5 5 6 3031568815
6 6 6 1000000000000
Output
2 + 1 = 3
10 + 90 = 100
-1
9 + 99996 = 100005
-1
78506 + 28543 = 107049
-1
----------------------------------------------------------------------------------------------------
B. Lottery
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 6 2
1 4 5
Output
4 2
Input
7 7 1
2 4 7 3 0 1 6
Output
1 5
----------------------------------------------------------------------------------------------------
C. Twin Clusters
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2
4 15 0 7 11 8 3 2
1
0 1 2 3
0
0 0
3
15 63 57 39 61 25 42 61 50 41 27 41 56 23 17 27
Output
2 4 6 6
2 2 3 4
1 1 2 2
1 1 4 10
----------------------------------------------------------------------------------------------------
D. Doctor's Brown Hypothesis
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 8 346
1 2
1 3
2 4
3 4
4 5
5 1
6 7
7 6
Output
5
Input
5 6 128
1 2
1 3
2 4
3 4
4 5
5 1
Output
6
Input
3 3 30
1 2
2 3
3 2
Output
2
----------------------------------------------------------------------------------------------------
E. Old Mobile
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 2
0
Output
666666674
Input
2 3
0 0
Output
916666678
Input
2 3
0 1
Output
500000009
----------------------------------------------------------------------------------------------------
F. Good Graph
time limit per test: 7 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 8
1 4
1 5
1 6
2 4
2 5
2 6
3 5
3 6
Output
YES
6
1 4
1 5
2 5
2 6
3 6
3 4
Input
3 4
1 4
1 5
2 6
3 6
Output
NO
2
2 3 
----------------------------------------------------------------------------------------------------
