Codeforces Round 286 (Div. 2)


A. Mr. Kitayuta's Gift
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
revive
Output
reviver
Input
ee
Output
eye
Input
kitayuta
Output
NA
----------------------------------------------------------------------------------------------------
B. Mr. Kitayuta's Colorful Graph
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 5
1 2 1
1 2 2
2 3 1
2 3 3
2 4 3
3
1 2
3 4
1 4
Output
2
1
0
Input
5 7
1 5 1
2 5 1
3 5 1
4 5 1
1 2 2
2 3 2
3 4 2
5
1 5
5 1
2 5
1 5
1 4
Output
1
1
1
1
2
----------------------------------------------------------------------------------------------------
C. Mr. Kitayuta, the Treasure Hunter
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 10
10
21
27
27
Output
3
Input
8 8
9
19
28
36
45
55
66
78
Output
6
Input
13 7
8
8
9
16
17
17
18
21
23
24
24
26
30
Output
4
----------------------------------------------------------------------------------------------------
D. Mr. Kitayuta's Technology
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 5
1 2
1 3
1 4
2 3
2 4
Output
3
Input
4 6
1 2
1 4
2 3
2 4
3 2
3 4
Output
4
----------------------------------------------------------------------------------------------------
E. Mr. Kitayuta vs. Bamboos
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 1 2 5
10 10
10 10
15 2
Output
17
Input
2 10 10 1000000000
0 10
0 10
Output
10
Input
5 3 3 10
9 5
9 2
4 7
9 10
3 8
Output
14
----------------------------------------------------------------------------------------------------
