Codeforces Round 142 (Div. 2)


A. Dragons
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2
1 99
100 0
Output
YES
Input
10 1
100 100
Output
NO
----------------------------------------------------------------------------------------------------
B. T-primes
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
4 5 6
Output
YES
NO
NO
----------------------------------------------------------------------------------------------------
C. Shifts
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 6
101010
000100
100000
Output
3
Input
2 3
111
000
Output
-1
----------------------------------------------------------------------------------------------------
D. Planets
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

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