All-Ukrainian School Olympiad in Informatics


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

Examples
Input
3 3
2 1
1 2 10 15
1 2 4 20
1 3 5 1
Output
30
----------------------------------------------------------------------------------------------------
B. Mice
time limit per test: 0.5 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2 0 2
0 1 3
2 5
Output
1
----------------------------------------------------------------------------------------------------
C. Mutation
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 3 13
BACAC
4 1 2
1 2 3
2 3 4
3 4 10
Output
5
----------------------------------------------------------------------------------------------------
D. Plus and xor
time limit per test: 0.5 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
142
76
Output
33 109
----------------------------------------------------------------------------------------------------
E. Points
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 1
-1 -1
1 -1
-1 1
Output
32
----------------------------------------------------------------------------------------------------
F. Tourist
time limit per test: 0.5 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
-1 1
42 7
40 8
2
Output
1 2
----------------------------------------------------------------------------------------------------
