Codeforces Round 593 (Div. 2)


A. Stones
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3 4 5
1 0 5
5 3 2
Output
9
0
6
----------------------------------------------------------------------------------------------------
B. Alice and the List of Presents
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 3
Output
7
Input
2 2
Output
9
----------------------------------------------------------------------------------------------------
C. Labs
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
Output
2 8 5
9 3 4
7 6 1
----------------------------------------------------------------------------------------------------
D. Alice and the Doll
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3 2
2 2
2 1
Output
Yes
Input
3 3 2
3 1
2 2
Output
No
Input
3 3 8
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3
Output
Yes
----------------------------------------------------------------------------------------------------
E. Alice and the Unfair Game
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
2 2 2
Output
7
Input
5 2
3 1
Output
21
----------------------------------------------------------------------------------------------------
F. Alice and the Cactus
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
1 2
2 3
1 3
Output
984375007
Input
5 6
1 2
2 3
1 3
3 4
4 5
3 5
Output
250000002
----------------------------------------------------------------------------------------------------
