QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#329650#4082. 열차의 이동GuanYunChang 150 ✓2700ms109416kbC++207.7kb2024-02-17 00:11:122024-02-17 00:11:14

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 11
Accepted

Test #1:

score: 11
Accepted
time: 0ms
memory: 3708kb

input:

3 80
2 1
3 2
1 2 2 3
2 1 2 3
2 3 2 1
3 2 1 2
2 3 1 2
1 2 2 3
3 2 2 1
1 2 2 3
1 2 2 3
1 2 2 3
3 2 1 2
1 2 3 2
2 1 2 3
3 2 1 2
2 3 2 1
2 3 1 2
1 2 3 2
2 1 3 2
1 2 3 2
1 2 3 2
2 1 2 3
2 1 3 2
3 2 2 1
1 2 3 2
1 2 3 2
1 2 2 3
2 1 2 3
1 2 2 3
2 3 2 1
2 3 2 1
2 1 3 2
1 2 3 2
2 1 2 3
3 2 2 1
1 2 3 2
2 1 3 2...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

result:

ok 80 lines

Test #2:

score: 0
Accepted
time: 1ms
memory: 3680kb

input:

9 80
2 6
9 3
6 7
4 5
3 4
4 7
8 6
8 1
5 4 1 8
7 4 3 9
6 4 6 1
2 4 5 9
6 7 1 8
7 2 5 3
3 5 2 8
3 4 4 7
4 6 4 9
2 6 8 1
8 6 6 7
6 7 2 6
9 3 4 3
4 9 6 4
5 4 1 8
1 2 3 6
5 9 2 1
4 7 3 4
6 2 5 4
9 4 7 2
1 2 6 3
9 5 7 1
3 7 7 2
7 4 6 8
4 5 8 1
5 3 6 1
2 7 7 5
3 7 8 2
3 9 3 4
1 8 4 5
2 6 7 4
7 5 1 6
1 8 3 4...

output:

4
2
2
-1
2
4
6
1
2
2
1
1
1
2
4
-1
-1
1
3
3
-1
-1
2
2
4
5
2
4
1
4
2
3
4
3
4
4
3
2
-1
1
1
3
3
3
3
1
5
3
5
4
2
4
3
3
1
2
3
4
-1
4
3
2
2
2
3
2
3
1
5
4
-1
3
2
1
6
2
3
2
1
2

result:

ok 80 lines

Test #3:

score: 0
Accepted
time: 0ms
memory: 3708kb

input:

10 80
1 7
9 7
3 6
3 1
2 8
2 10
10 1
8 5
4 8
5 2 6 1
4 2 3 7
9 7 1 7
2 8 3 1
8 4 1 3
7 9 2 8
9 1 5 2
4 10 6 7
1 10 2 10
10 2 9 7
10 7 5 2
7 9 6 3
5 4 1 2
10 8 4 5
3 6 2 10
9 3 8 1
4 5 1 2
8 2 4 8
3 6 7 9
7 3 8 10
7 1 3 6
6 3 2 8
7 9 6 3
1 10 7 9
6 9 1 5
6 9 1 5
1 2 4 2
9 7 1 10
2 4 3 7
1 7 7 9
7 3 1 ...

output:

4
5
1
3
4
4
4
-1
1
3
3
3
-1
-1
3
-1
-1
1
3
4
2
4
3
2
-1
-1
2
2
5
1
3
3
4
4
-1
2
3
1
2
4
4
-1
-1
-1
-1
2
3
3
-1
4
3
3
3
3
2
2
3
3
1
3
-1
2
4
1
-1
3
2
2
2
-1
3
4
-1
4
4
4
-1
4
4
1

result:

ok 80 lines

Test #4:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

15 80
11 2
10 12
3 10
5 4
6 1
7 10
8 3
11 3
12 6
5 2
3 15
13 3
11 9
6 14
15 8 11 10
7 11 4 11
13 9 10 1
8 3 13 3
3 5 10 14
3 15 2 5
9 11 10 12
14 1 15 8
3 2 6 10
11 13 4 2
14 10 3 5
13 7 10 14
5 4 12 10
8 3 10 12
2 4 6 10
5 2 15 3
3 9 11 5
3 5 8 7
3 13 7 10
5 9 6 3
11 3 11 9
7 8 14 10
6 15 13 5
9 5 ...

output:

-1
3
-1
1
4
3
3
-1
3
3
4
-1
5
2
5
3
3
-1
2
5
1
-1
6
6
4
-1
2
-1
-1
-1
-1
3
3
-1
-1
6
5
3
4
6
6
-1
7
2
2
-1
-1
3
4
5
-1
-1
5
-1
5
1
-1
5
-1
4
-1
1
4
6
5
2
-1
-1
1
5
5
-1
-1
2
-1
3
-1
-1
3
4

result:

ok 80 lines

Test #5:

score: 0
Accepted
time: 1ms
memory: 3716kb

input:

37 80
8 19
4 7
10 22
21 1
9 8
5 28
6 14
30 28
35 1
37 8
30 17
7 24
20 3
15 4
5 29
37 26
34 15
1 6
27 20
33 3
22 24
2 13
37 12
4 31
17 23
26 27
20 1
25 36
3 36
18 37
8 22
4 16
6 28
5 13
6 32
33 11
10 9 8 27
17 37 18 34
24 20 23 21
19 8 22 10
15 34 27 20
22 34 26 25
29 6 24 19
6 33 6 23
24 10 4 24
34 ...

output:

-1
-1
-1
2
9
8
10
4
2
7
-1
-1
11
5
-1
11
4
-1
6
7
8
-1
7
5
4
-1
11
-1
3
-1
4
2
5
-1
13
-1
7
6
-1
6
-1
1
6
-1
5
-1
11
-1
10
5
-1
1
5
2
-1
4
2
10
7
-1
5
-1
7
7
8
-1
8
7
6
8
-1
7
8
12
8
11
7
-1
6
9

result:

ok 80 lines

Test #6:

score: 0
Accepted
time: 1ms
memory: 3616kb

input:

55 80
15 26
6 12
8 30
32 50
3 48
23 2
5 32
35 33
16 7
44 55
25 41
48 35
20 36
23 30
23 9
29 41
17 39
31 28
25 35
32 51
38 14
19 38
27 4
33 43
22 44
15 9
34 42
31 38
41 45
32 27
53 29
7 10
49 29
55 54
1 18
7 50
31 30
24 39
13 19
21 1
5 47
51 11
1 44
37 23
39 48
6 28
40 54
48 32
20 15
50 18
25 46
34 3...

output:

-1
8
-1
-1
13
9
-1
-1
11
12
4
10
-1
-1
8
-1
4
8
-1
8
7
-1
6
8
-1
7
5
-1
10
7
-1
6
6
7
11
-1
-1
-1
-1
-1
-1
9
10
-1
-1
9
-1
11
6
9
10
13
-1
11
10
7
-1
-1
8
3
7
11
11
8
-1
3
5
8
14
-1
9
10
9
4
-1
-1
10
-1
-1
-1

result:

ok 80 lines

Test #7:

score: 0
Accepted
time: 0ms
memory: 3928kb

input:

66 80
5 50
50 8
34 20
14 12
11 3
2 61
33 60
10 32
6 5
27 18
52 59
16 60
53 7
37 10
35 13
27 48
15 45
29 43
25 40
1 51
31 30
9 63
6 53
23 63
54 62
34 47
32 47
44 28
20 51
40 61
13 17
36 55
8 57
14 4
16 65
26 51
32 16
49 17
51 28
31 56
19 57
33 52
18 44
50 39
6 61
7 12
6 21
29 49
5 13
42 52
9 58
4 24
...

output:

-1
8
7
-1
8
-1
-1
-1
2
-1
-1
14
10
-1
-1
8
-1
-1
13
17
18
13
5
4
-1
13
-1
-1
-1
-1
11
6
8
-1
-1
-1
-1
9
4
12
2
4
-1
-1
-1
-1
-1
12
2
10
8
-1
6
10
-1
15
-1
-1
12
3
4
1
10
-1
-1
10
7
-1
-1
-1
3
4
16
-1
9
4
-1
15
6
-1

result:

ok 80 lines

Test #8:

score: 0
Accepted
time: 1ms
memory: 3716kb

input:

60 80
15 5
3 45
48 9
1 54
39 52
34 32
27 48
29 10
55 38
9 8
22 21
3 57
14 8
58 9
42 32
37 53
26 41
60 12
28 11
2 43
60 47
42 41
52 36
46 22
38 12
27 39
28 15
57 43
49 51
38 41
17 38
58 49
24 11
24 52
26 16
43 33
22 43
1 44
41 45
49 6
35 11
52 56
60 13
20 29
30 47
8 23
19 26
20 15
53 56
48 50
54 40
4...

output:

-1
8
4
9
10
-1
12
6
-1
9
-1
-1
13
12
-1
-1
-1
10
-1
10
-1
13
7
-1
14
7
9
-1
13
1
3
-1
-1
-1
22
-1
-1
11
9
5
-1
-1
-1
-1
7
12
3
-1
7
-1
-1
8
6
10
9
16
-1
11
-1
2
16
14
13
-1
4
5
7
9
5
10
4
8
-1
-1
16
-1
-1
-1
-1
-1

result:

ok 80 lines

Test #9:

score: 0
Accepted
time: 1ms
memory: 3748kb

input:

80 80
38 23
37 55
80 53
24 9
61 29
27 11
19 7
65 21
34 71
57 79
15 70
49 36
79 14
63 29
58 53
13 22
7 72
74 67
22 53
55 68
7 22
47 71
16 15
28 6
78 80
40 32
69 30
4 24
17 31
36 20
46 55
11 36
77 42
76 44
73 12
66 41
20 38
9 64
5 73
12 59
36 59
25 37
60 9
21 76
9 26
54 42
58 41
48 50
76 37
70 37
62 1...

output:

11
8
-1
7
-1
5
9
-1
4
8
2
4
-1
-1
19
9
6
10
-1
4
8
11
7
-1
15
14
-1
-1
8
10
4
9
19
-1
11
10
16
1
15
9
1
11
13
-1
14
6
10
18
18
11
21
9
4
9
12
13
15
-1
13
13
-1
8
10
10
10
2
11
10
3
12
10
19
12
10
5
13
13
5
-1
5

result:

ok 80 lines

Test #10:

score: 0
Accepted
time: 1ms
memory: 3624kb

input:

80 80
69 26
38 43
48 65
40 49
77 72
52 9
14 41
70 6
66 36
43 80
46 31
64 59
15 68
40 73
77 2
6 23
55 41
58 70
25 28
18 74
25 74
3 51
27 22
78 74
10 13
34 39
13 70
52 7
21 26
72 67
33 79
71 69
52 1
19 45
8 25
26 17
8 7
26 35
27 42
65 16
21 59
65 4
69 5
39 61
22 18
32 52
5 77
50 56
15 40
61 47
63 3
28...

output:

-1
8
-1
-1
14
-1
13
-1
8
12
-1
8
-1
4
13
9
19
-1
-1
-1
4
9
19
-1
-1
8
8
-1
13
-1
18
-1
-1
-1
26
5
13
-1
-1
5
11
-1
-1
10
-1
6
-1
11
9
-1
-1
4
-1
-1
24
17
16
-1
12
-1
-1
1
-1
-1
-1
7
20
-1
8
3
-1
9
8
-1
-1
12
4
-1
13
8

result:

ok 80 lines

Test #11:

score: 0
Accepted
time: 1ms
memory: 3676kb

input:

80 80
31 3
20 49
57 75
41 54
77 57
72 35
47 24
56 24
74 38
47 35
48 28
58 6
72 66
72 43
13 44
4 71
27 66
62 5
75 39
6 42
50 71
11 48
70 51
14 29
58 37
38 29
30 14
10 2
56 55
2 19
8 54
18 15
24 64
52 32
63 52
59 52
29 25
80 21
28 8
38 40
34 1
66 22
73 4
36 71
31 33
13 32
23 58
57 45
4 18
77 52
53 37
...

output:

-1
7
5
-1
18
9
-1
16
-1
-1
16
8
14
13
8
-1
-1
-1
-1
13
11
8
-1
13
6
-1
8
-1
11
9
10
-1
-1
6
7
-1
-1
10
14
8
-1
8
16
5
-1
-1
-1
9
-1
7
14
-1
11
17
6
14
-1
15
-1
-1
-1
6
17
-1
-1
-1
10
-1
4
-1
-1
6
16
3
6
12
-1
-1
-1
1

result:

ok 80 lines

Test #12:

score: 0
Accepted
time: 1ms
memory: 3928kb

input:

80 80
5 18
80 46
64 69
76 42
32 43
66 21
57 40
39 67
44 67
67 53
19 68
22 4
8 24
31 17
74 31
34 9
14 35
10 70
77 26
29 33
8 6
71 12
17 78
2 63
32 80
70 54
7 70
25 2
6 36
5 59
23 32
33 61
26 8
68 28
46 3
22 35
47 35
5 33
2 56
15 22
28 42
2 34
14 58
39 30
9 72
31 14
8 57
28 37
12 45
69 13
50 1
51 29
7...

output:

19
7
10
-1
12
8
-1
12
14
15
15
5
-1
6
-1
9
11
6
12
14
6
15
15
-1
15
14
-1
11
7
13
11
-1
-1
-1
4
10
-1
12
-1
12
10
-1
18
15
5
9
-1
12
8
10
15
-1
4
-1
-1
14
12
-1
-1
-1
-1
8
7
12
12
16
2
11
8
11
-1
3
11
13
8
11
8
-1
12
10

result:

ok 80 lines

Test #13:

score: 0
Accepted
time: 1ms
memory: 3948kb

input:

80 80
50 65
26 70
25 2
64 55
14 52
3 46
67 19
36 12
46 52
64 59
11 31
57 14
51 9
36 49
72 38
4 24
78 20
57 6
1 45
36 26
59 13
37 49
6 41
15 51
41 50
44 23
25 31
62 8
21 28
39 79
53 28
9 42
18 45
72 9
16 7
69 74
57 79
75 72
10 74
27 1
54 4
28 79
27 51
40 9
33 68
11 43
8 58
60 36
76 57
21 5
47 21
25 2...

output:

-1
20
13
-1
7
-1
13
-1
15
7
12
-1
13
-1
4
-1
14
3
16
7
9
-1
-1
14
16
15
-1
-1
-1
-1
7
10
9
6
-1
-1
-1
-1
6
6
14
5
18
4
-1
-1
13
6
-1
10
14
-1
-1
14
16
8
14
8
-1
-1
-1
8
14
-1
-1
8
9
9
-1
-1
-1
8
20
-1
15
6
-1
11
-1
-1

result:

ok 80 lines

Test #14:

score: 0
Accepted
time: 1ms
memory: 3740kb

input:

80 80
56 77
13 34
29 52
11 5
60 36
4 9
79 55
68 13
33 5
80 18
69 50
16 35
47 56
15 20
12 10
3 67
35 25
44 7
63 51
27 52
20 58
80 14
40 64
68 79
35 2
60 31
48 4
58 44
79 19
71 4
49 32
30 37
57 3
13 72
16 41
15 59
22 18
20 24
67 26
31 12
8 21
5 16
51 50
54 67
75 34
36 21
6 4
38 44
30 3
57 23
21 30
78 ...

output:

4
-1
-1
-1
20
7
10
12
-1
10
-1
-1
-1
-1
-1
15
-1
18
-1
7
12
-1
13
-1
-1
-1
5
8
5
-1
10
-1
-1
-1
16
-1
-1
11
11
-1
-1
9
18
-1
12
-1
-1
8
-1
8
-1
7
-1
-1
9
-1
11
-1
7
9
-1
13
11
11
10
-1
-1
4
6
10
6
-1
8
10
8
-1
9
-1
13
15

result:

ok 80 lines

Test #15:

score: 0
Accepted
time: 0ms
memory: 3668kb

input:

80 80
30 22
41 72
49 52
47 20
40 59
74 75
46 48
15 49
31 47
59 50
8 13
35 19
55 10
45 24
16 56
11 58
23 38
69 3
13 29
75 64
68 67
27 60
2 78
6 25
29 27
3 33
32 73
17 26
71 36
44 28
51 31
37 53
14 44
22 23
9 15
80 35
53 17
62 41
5 4
33 40
7 21
38 71
19 30
58 39
26 45
34 16
36 69
61 34
73 74
24 43
28 ...

output:

40
42
34
38
33
34
41
41
34
37
37
40
37
39
39
38
36
38
39
37
38
37
33
38
36
33
35
35
39
38
39
39
39
39
32
32
39
39
37
44
38
41
39
43
36
35
39
40
38
34
41
40
39
38
39
35
41
39
38
42
44
39
38
37
43
36
37
38
32
42
39
40
39
41
38
36
41
38
42
40

result:

ok 80 lines

Test #16:

score: 0
Accepted
time: 1ms
memory: 3948kb

input:

73 80
22 39
34 43
51 61
50 12
33 13
55 28
65 20
12 32
72 9
52 40
45 14
23 5
61 21
48 25
49 47
38 37
26 70
37 35
69 2
2 52
13 34
64 22
14 36
24 6
44 45
29 63
46 19
4 35
60 56
21 64
59 24
27 7
18 58
43 29
11 1
20 66
62 23
17 11
1 69
39 41
7 65
70 50
63 3
47 8
40 30
10 27
15 59
9 49
6 48
42 67
66 33
41...

output:

32
27
-1
-1
-1
-1
35
29
-1
-1
-1
-1
-1
33
-1
-1
31
-1
-1
35
-1
37
-1
34
-1
-1
32
-1
31
35
28
34
-1
-1
-1
40
-1
-1
-1
31
-1
39
-1
-1
-1
31
42
-1
34
-1
34
-1
34
-1
-1
-1
-1
-1
42
43
-1
-1
39
-1
-1
35
36
-1
-1
38
-1
39
42
39
36
-1
29
-1
40
-1

result:

ok 80 lines

Test #17:

score: 0
Accepted
time: 1ms
memory: 3744kb

input:

80 80
51 24
6 4
69 31
12 69
36 61
44 16
22 33
78 25
61 45
25 1
55 64
40 18
66 75
7 21
30 56
58 47
46 6
80 70
79 38
35 28
70 79
14 34
49 62
26 78
76 63
71 52
39 26
77 5
33 58
73 42
29 13
9 50
37 53
18 17
31 39
28 23
3 48
74 37
58 68
54 71
2 46
65 22
63 32
53 11
13 67
4 60
21 36
59 12
10 76
75 30
32 5...

output:

36
38
-1
34
42
39
43
37
40
37
39
-1
42
-1
40
37
44
37
42
40
51
40
44
35
44
-1
31
41
40
40
42
33
43
43
39
50
-1
36
32
29
45
-1
32
-1
-1
39
40
42
42
36
36
40
46
-1
46
37
42
-1
40
47
36
38
44
33
34
37
-1
38
-1
37
43
40
46
-1
35
45
48
39
37
40

result:

ok 80 lines

Test #18:

score: 0
Accepted
time: 0ms
memory: 3884kb

input:

80 80
47 61
14 52
32 55
61 16
24 21
40 44
57 41
64 47
48 65
34 73
66 59
65 62
9 33
21 28
31 46
6 45
7 27
5 76
33 68
28 36
62 43
80 79
45 20
8 71
39 11
54 12
46 40
43 67
42 22
58 6
17 60
76 23
55 57
19 61
71 35
15 25
10 54
11 77
53 19
38 30
30 42
23 17
4 66
37 34
41 1
50 4
69 72
12 56
51 69
78 39
20 ...

output:

64
58
60
-1
60
60
-1
56
59
58
57
58
55
58
58
63
58
63
-1
65
58
61
65
61
56
55
58
-1
62
58
67
58
57
64
56
55
56
61
58
57
-1
55
60
57
59
64
60
-1
56
62
57
68
61
61
58
56
-1
59
69
59
55
60
60
56
64
63
58
59
61
60
59
59
57
57
66
59
-1
63
63
57

result:

ok 80 lines

Test #19:

score: 0
Accepted
time: 1ms
memory: 3936kb

input:

50 80
20 38
47 39
15 36
1 9
29 23
25 13
11 43
37 12
33 2
21 45
31 8
19 29
14 33
37 5
13 30
43 26
23 24
27 49
7 1
12 40
3 25
7 15
25 34
12 20
9 14
17 50
30 4
50 31
13 11
44 27
10 49
10 37
45 18
22 49
45 32
48 47
3 27
32 3
32 17
42 6
5 48
39 35
1 10
44 6
40 41
34 19
18 28
38 46
16 7
30 21 40 16
30 45 ...

output:

39
16
14
16
39
16
39
39
39
39
39
39
39
15
39
16
39
15
39
15
39
15
15
39
14
39
15
16
39
39
14
15
14
39
39
16
15
15
39
15
14
15
15
39
39
39
15
14
14
14
39
15
39
39
39
39
15
39
39
16
16
15
15
39
15
15
15
15
14
15
39
14
39
15
14
39
39
16
15
16

result:

ok 80 lines

Test #20:

score: 0
Accepted
time: 1ms
memory: 3608kb

input:

60 80
27 52
21 11
46 34
9 26
31 14
16 10
7 31
58 30
1 27
23 49
52 3
37 36
25 1
52 32
35 38
26 45
25 54
16 6
31 24
32 5
2 55
24 20
59 12
45 21
42 56
3 29
34 9
28 48
8 22
41 15
46 40
40 19
27 59
10 39
48 51
4 46
15 28
30 37
41 32
3 58
18 17
49 35
44 23
51 43
1 2
15 7
4 13
55 33
7 60
34 41
60 18
43 42
...

output:

19
18
19
19
51
51
19
51
51
51
51
51
51
51
20
18
51
51
18
19
51
19
51
51
19
51
20
51
19
19
19
19
18
20
51
18
51
51
51
51
18
51
51
18
51
51
51
20
19
18
20
51
51
20
51
19
51
51
19
51
51
18
51
51
19
51
51
51
51
51
51
51
19
19
18
19
51
51
20
20

result:

ok 80 lines

Test #21:

score: 0
Accepted
time: 1ms
memory: 3652kb

input:

70 80
29 23
66 8
17 41
39 26
61 49
32 6
58 53
12 50
52 18
19 7
6 47
65 64
48 69
18 16
3 14
16 35
45 70
64 42
23 53
26 56
28 29
12 31
8 52
62 51
3 1
62 34
13 36
23 59
37 22
24 57
68 60
9 30
58 31
63 61
14 11
64 13
10 17
9 48
28 10
30 65
40 37
34 33
59 25
44 32
5 63
57 20
29 38
25 62
31 15
65 4
59 55
...

output:

23
23
54
54
54
54
21
22
22
22
23
22
22
54
54
21
54
22
54
54
54
54
21
21
54
54
54
23
22
54
54
22
22
22
54
22
54
23
22
54
54
54
54
22
22
54
54
23
54
22
21
22
22
22
22
22
23
22
23
22
21
23
54
54
22
23
21
54
54
54
22
54
54
23
54
21
54
22
21
21

result:

ok 80 lines

Test #22:

score: 0
Accepted
time: 1ms
memory: 3724kb

input:

80 80
48 77
62 71
51 61
50 77
34 65
78 8
20 24
36 55
23 46
61 20
37 52
42 80
66 12
57 53
68 41
55 10
32 21
16 64
31 28
50 36
65 23
45 13
11 32
3 75
14 4
18 1
8 17
49 19
72 22
34 62
26 27
52 7
27 74
2 60
47 2
59 44
75 79
38 43
59 69
53 40
21 54
80 6
76 73
69 31
7 39
60 45
44 33
10 14
15 78
9 72
46 15...

output:

28
70
27
28
28
28
70
28
29
70
27
28
70
28
29
28
29
70
70
28
28
28
29
27
70
70
29
28
28
29
28
29
28
70
27
29
70
70
70
70
28
27
29
70
70
70
70
70
28
70
29
27
70
70
70
70
70
70
70
70
28
28
29
29
70
70
29
28
29
70
28
70
70
29
29
70
29
70
27
70

result:

ok 80 lines

Test #23:

score: 0
Accepted
time: 0ms
memory: 3664kb

input:

70 80
37 8
51 18
2 12
8 59
31 36
52 21
1 53
44 34
38 15
24 26
68 5
27 16
33 49
19 6
56 52
54 14
12 54
50 20
55 65
29 44
63 57
40 16
70 4
15 32
25 20
5 62
8 11
69 34
9 22
48 25
14 47
61 28
2 3
53 60
27 37
68 25
57 25
33 17
36 64
4 7
64 26
59 58
43 20
67 7
56 33
12 27
15 1
42 25
32 55
25 46
7 34
1 56
...

output:

33
23
33
23
33
24
22
22
24
33
33
23
33
22
33
24
24
33
22
33
23
23
33
33
33
22
23
33
33
24
24
33
22
22
33
23
33
23
23
33
33
33
22
23
23
24
24
23
23
23
33
24
23
33
22
33
33
22
24
33
33
33
23
33
33
24
23
24
33
33
22
33
22
33
23
22
23
23
33
24

result:

ok 80 lines

Test #24:

score: 0
Accepted
time: 1ms
memory: 3740kb

input:

70 80
7 17
61 56
5 51
49 45
29 61
57 15
47 8
65 45
16 38
67 49
48 27
48 26
43 30
41 43
51 2
66 36
40 28
24 60
14 40
62 37
41 25
13 63
2 55
64 58
54 68
13 39
19 42
7 57
1 14
64 33
48 22
11 32
44 23
43 12
16 24
4 11
46 13
9 3
56 44
10 50
33 4
70 66
7 37
70 43
22 66
38 53
11 52
21 65
20 31
52 18
59 20
...

output:

28
16
28
28
15
14
28
15
14
15
15
28
15
15
28
28
28
15
28
28
15
28
16
15
14
28
15
15
28
28
14
15
28
14
28
14
28
16
14
28
28
28
15
28
28
15
28
28
14
28
28
16
28
15
14
14
16
28
14
15
16
15
28
28
16
14
14
28
28
15
28
28
28
15
28
28
28
15
28
28

result:

ok 80 lines

Test #25:

score: 0
Accepted
time: 1ms
memory: 3740kb

input:

80 80
5 58
1 68
31 25
78 74
28 13
64 36
49 23
72 19
32 39
12 74
4 7
2 37
40 27
67 6
22 8
44 76
39 28
11 69
49 64
59 42
31 20
65 68
18 33
31 5
34 66
41 42
77 73
38 54
74 68
9 41
80 48
2 11
17 56
21 75
75 18
71 15
30 35
1 27
78 35
41 22
15 24
68 42
46 20
4 3
60 67
29 80
42 38
69 29
69 49
56 72
19 79
2...

output:

33
33
15
15
15
15
14
15
14
33
33
33
14
15
33
33
14
33
33
33
33
15
33
33
15
33
33
33
33
15
33
33
14
14
15
15
14
33
15
14
15
14
33
33
33
33
33
14
14
33
33
14
33
15
33
14
14
14
33
14
33
15
14
33
14
15
15
33
15
15
15
14
14
15
15
14
33
15
33
14

result:

ok 80 lines

Test #26:

score: 0
Accepted
time: 1ms
memory: 3740kb

input:

80 80
44 37
7 14
58 41
21 19
60 62
27 55
56 6
42 36
21 65
65 71
30 61
19 39
19 50
16 7
34 42
49 12
20 5
79 20
25 46
26 54
32 63
14 43
11 44
54 48
62 26
77 9
40 28
45 1
72 11
61 13
50 17
48 23
46 57
25 72
53 29
60 45
39 73
8 47
64 73
6 51
12 70
80 53
49 74
76 4
36 79
43 40
10 77
59 18
24 16
51 15
64 ...

output:

39
39
15
15
39
39
39
39
39
15
15
39
39
39
39
15
16
15
14
39
15
15
39
15
39
15
39
16
15
39
16
15
39
39
39
15
15
39
16
16
39
16
39
15
16
15
15
39
16
39
39
39
15
15
39
16
14
39
39
39
39
15
39
15
39
15
16
39
39
15
15
39
39
39
14
16
39
39
15
39

result:

ok 80 lines

Test #27:

score: 0
Accepted
time: 0ms
memory: 3720kb

input:

80 80
71 12
42 37
29 47
6 18
43 56
64 1
11 55
26 51
23 33
58 61
79 26
72 73
29 56
62 79
37 23
40 46
52 69
50 63
75 27
56 24
29 4
38 20
54 4
40 30
46 70
21 6
42 58
49 74
69 42
9 72
38 7
73 19
21 15
44 31
67 10
69 76
6 53
1 59
34 2
38 44
68 43
74 36
78 45
22 32
13 65
17 67
78 15
64 52
66 48
79 39
76 1...

output:

22
23
22
22
46
21
46
22
22
23
46
46
46
21
46
46
21
23
46
22
46
23
46
22
46
46
46
46
22
23
46
46
46
46
46
22
23
46
22
46
46
46
21
46
46
46
46
46
23
46
46
21
21
46
46
46
23
23
22
46
21
46
46
22
46
46
46
46
22
46
21
46
46
46
46
46
21
21
21
22

result:

ok 80 lines

Test #28:

score: 0
Accepted
time: 0ms
memory: 3928kb

input:

8 8
1 2
2 3
3 4
3 7
5 6
6 7
7 8
2 4 8 6
1 4 5 8
6 8 4 2
5 8 4 1
1 3 6 3
5 6 1 2
2 4 5 7
1 3 7 5

output:

5
-1
5
-1
2
4
4
3

result:

ok 8 lines

Test #29:

score: 0
Accepted
time: 1ms
memory: 3644kb

input:

6 7
1 2
2 3
2 5
4 5
5 6
1 2 5 6
1 3 4 6
4 6 3 1
1 5 4 6
3 1 6 2
2 3 5 6
2 5 4 5

output:

2
-1
-1
-1
-1
2
1

result:

ok 7 lines

Test #30:

score: 0
Accepted
time: 1ms
memory: 3700kb

input:

22 5
1 2
3 4
4 5
5 6
7 8
8 9
2 6
6 9
9 10
6 11
11 12
12 15
13 14
15 16
16 17
17 18
19 20
20 21
13 15
15 19
19 22
2 10 13 22
22 13 10 2
3 6 15 18
5 12 22 13
4 11 10 2

output:

12
12
6
7
7

result:

ok 5 lines

Test #31:

score: 0
Accepted
time: 1ms
memory: 3728kb

input:

22 2
1 2
3 4
4 5
5 6
7 8
8 9
2 6
6 9
9 10
6 11
11 12
12 19
13 14
15 16
16 17
17 18
19 20
20 21
13 15
15 19
19 22
2 10 13 22
12 21 13 22

output:

10
6

result:

ok 2 lines

Subtask #2:

score: 18
Accepted

Dependency #1:

100%
Accepted

Test #32:

score: 18
Accepted
time: 165ms
memory: 3712kb

input:

8 240666
8 1
6 2
2 7
2 1
3 5
1 3
4 6
7 1 4 2
6 7 1 5
5 1 2 4
5 1 6 1
1 5 8 2
4 2 3 2
2 4 1 7
8 2 1 5
1 6 1 5
1 8 2 1
6 7 3 2
8 1 2 6
1 8 1 3
4 2 2 8
1 5 2 8
6 7 2 8
2 7 8 1
4 2 1 7
2 8 5 1
2 8 1 5
4 6 1 3
7 1 1 5
6 7 8 3
1 5 4 2
5 1 2 4
5 1 4 2
2 1 6 4
1 5 1 7
4 2 1 7
7 2 1 8
8 3 6 1
5 1 7 1
8 3 4 2...

output:

3
4
3
2
3
2
3
3
2
1
3
2
1
2
3
3
2
3
3
3
3
2
5
3
3
3
2
2
3
2
3
2
4
2
1
3
3
3
3
4
2
3
2
1
3
2
2
1
1
2
2
3
1
2
1
3
2
4
2
3
3
3
2
3
3
2
2
2
3
3
3
3
3
1
4
2
3
3
1
4
2
2
3
3
2
3
3
2
3
3
3
2
2
3
3
3
3
3
3
3
2
3
4
2
4
3
2
3
2
2
3
2
3
1
3
3
4
1
3
3
2
2
3
2
3
3
4
2
3
2
3
2
3
4
3
2
4
3
3
2
5
2
4
1
3
2
3
3
3
3
...

result:

ok 240666 lines

Test #33:

score: 0
Accepted
time: 181ms
memory: 3756kb

input:

79 250000
35 12
77 52
64 12
26 74
24 12
19 48
7 52
48 41
3 52
67 8
19 50
69 64
36 50
60 73
50 42
53 43
74 55
75 38
66 29
46 45
11 12
44 30
75 4
52 68
19 49
18 47
53 63
60 32
50 17
78 10
73 63
58 25
7 62
37 28
9 22
42 59
23 78
27 5
53 72
76 21
39 42
15 21
16 37
24 1
45 54
36 54
25 78
51 62
51 55
66 1...

output:

5
3
4
6
7
9
-1
10
4
2
5
10
3
-1
14
6
4
7
11
6
6
5
4
9
4
8
10
4
8
6
10
8
5
5
9
8
9
5
7
12
6
6
6
10
10
10
3
5
-1
9
7
7
7
10
6
12
7
5
1
11
4
5
7
7
10
12
8
6
10
3
9
6
4
9
7
6
12
7
7
7
5
8
5
11
3
7
6
6
9
3
5
7
8
6
5
3
7
2
8
6
4
4
9
8
5
5
8
6
4
7
9
9
8
2
13
-1
3
4
10
5
3
13
6
10
-1
5
3
10
2
-1
9
5
5
-1
4
...

result:

ok 250000 lines

Test #34:

score: 0
Accepted
time: 236ms
memory: 4052kb

input:

692 250000
215 452
610 279
211 523
669 163
414 25
559 539
552 56
682 390
74 28
482 142
10 51
398 220
505 531
555 158
295 591
558 471
350 352
466 223
145 362
372 375
139 102
343 40
146 345
338 327
325 662
670 299
457 575
433 617
37 291
670 309
326 520
358 215
657 628
269 676
184 555
364 495
331 158
6...

output:

32
31
32
11
21
12
34
26
21
15
26
33
17
18
25
31
10
19
12
25
22
10
21
15
28
32
23
-1
49
46
25
21
48
4
35
15
-1
27
3
19
6
12
27
7
26
3
12
40
40
21
15
8
19
29
20
19
30
15
-1
12
31
24
9
17
20
26
30
37
8
22
13
14
29
17
19
7
9
6
33
12
15
18
19
23
5
16
-1
11
45
35
23
28
10
28
37
45
36
34
12
7
25
31
8
18
29...

result:

ok 250000 lines

Test #35:

score: 0
Accepted
time: 356ms
memory: 6248kb

input:

9059 250000
7521 903
7352 3318
8064 5626
3985 1991
5019 5087
6384 6424
8863 3453
8950 7012
610 5849
676 6634
2330 8455
7003 6410
4643 3899
5690 8921
6127 5272
7433 8048
209 3512
2345 549
4854 4230
4654 2858
8713 5669
7765 6302
5510 5802
8330 6753
7903 1863
2990 3570
6751 2788
358 7756
1539 5049
2004...

output:

69
24
97
32
65
73
67
-1
100
96
103
70
31
25
70
42
34
82
100
18
65
73
62
39
98
83
29
94
111
35
-1
81
-1
68
102
91
-1
82
77
27
86
89
70
36
99
101
84
51
16
126
55
102
130
10
47
-1
110
52
103
79
54
96
71
21
121
66
47
91
122
61
40
88
92
44
102
47
59
39
72
87
32
64
50
110
69
60
17
113
86
59
71
73
73
106
9...

result:

ok 250000 lines

Test #36:

score: 0
Accepted
time: 781ms
memory: 14032kb

input:

38358 250000
31309 4942
30128 19764
14275 16879
16794 12458
1369 11834
3635 1100
7316 33494
12808 19470
8909 34217
14915 36477
24491 12973
10492 1569
32740 23283
31979 27213
18969 12003
24067 9789
26940 26721
14063 16635
5914 3440
14330 9224
9094 35191
2841 5774
7146 30784
24796 2696
23859 24627
968...

output:

143
53
132
185
44
113
129
107
183
116
98
74
67
177
65
36
102
134
64
105
223
130
77
151
185
85
129
133
-1
47
141
124
61
110
67
166
66
172
95
121
22
129
77
136
99
45
163
43
214
169
118
89
156
189
151
-1
160
98
87
113
43
159
172
176
84
96
227
174
32
141
116
75
164
114
38
131
114
161
44
-1
150
79
42
100...

result:

ok 250000 lines

Test #37:

score: 0
Accepted
time: 2157ms
memory: 48660kb

input:

162967 250000
14457 77337
162784 82676
94498 73460
15532 161607
43051 97543
25533 145353
5624 62458
1696 152643
151089 40176
103374 44088
100037 113431
160520 93778
89754 50689
147626 35215
59644 82795
35374 132069
152147 61651
120970 90767
67885 53818
111758 158717
19637 1079
102453 37776
51240 111...

output:

184
100
268
210
146
201
280
135
75
135
211
211
234
161
167
197
180
122
-1
98
217
48
246
203
109
216
260
133
186
178
199
250
298
156
95
336
63
210
96
270
28
252
166
207
106
157
256
128
-1
-1
60
313
306
262
281
229
222
101
47
139
247
291
154
187
209
100
300
294
288
337
180
125
95
128
128
192
111
291
2...

result:

ok 250000 lines

Test #38:

score: 0
Accepted
time: 2540ms
memory: 71576kb

input:

244586 250000
47140 194559
63872 227304
223667 105939
95193 150103
20077 86702
59212 218749
193539 50857
121074 147672
213730 163982
214640 124648
141843 62116
55608 149315
167150 237856
153992 65384
61811 191364
78530 81876
145990 235974
117248 242294
66872 139264
133741 220621
209327 135598
81160 ...

output:

263
96
91
186
322
50
153
292
307
123
326
203
252
189
-1
250
355
168
122
208
160
303
246
250
256
-1
360
196
225
221
90
102
78
272
202
259
269
182
147
119
318
354
210
259
334
117
280
259
223
56
254
74
123
211
48
295
33
278
75
173
112
329
158
96
177
286
151
114
292
243
157
243
169
92
132
115
64
125
240...

result:

ok 250000 lines

Test #39:

score: 0
Accepted
time: 2528ms
memory: 71596kb

input:

245242 250000
43927 169971
130553 147211
128633 139215
153759 161546
29920 131492
46863 225396
10183 22346
85426 14165
217105 85277
154373 63039
44117 28130
36837 165785
187502 214830
69902 186707
221887 117290
237151 150518
182351 26969
201713 42684
238241 210145
98844 159252
59566 9336
13719 11548...

output:

93
254
191
214
453
258
137
255
50
295
190
207
65
115
298
272
110
192
244
187
137
-1
175
230
-1
128
403
246
93
152
74
189
147
280
342
177
234
132
215
137
127
293
133
262
94
285
166
389
216
111
469
147
274
203
300
112
196
260
-1
276
189
156
109
139
151
258
203
133
248
160
280
125
114
177
228
286
285
3...

result:

ok 250000 lines

Test #40:

score: 0
Accepted
time: 2566ms
memory: 72020kb

input:

245858 250000
11823 175317
14581 85324
65727 71664
152205 145272
159998 204451
27249 191323
87672 2613
237224 76576
237576 152986
94584 94687
38882 12558
216039 73333
26421 111724
229379 159310
179615 6417
64782 58664
33778 213190
21208 165615
4384 111566
205701 205037
64021 5448
10303 184038
107299...

output:

72
-1
278
126
197
115
265
237
91
211
156
323
157
82
173
284
126
247
359
142
178
268
121
235
251
96
198
133
148
347
34
209
139
108
217
152
223
169
301
106
190
249
176
64
84
79
-1
250
277
198
249
403
218
215
209
172
323
109
265
122
140
-1
155
196
275
68
133
235
281
286
229
42
210
180
316
131
131
101
2...

result:

ok 250000 lines

Test #41:

score: 0
Accepted
time: 2591ms
memory: 72280kb

input:

247209 250000
133153 212243
70975 100699
180205 189056
131199 116184
6561 135145
41220 50747
10990 116553
31489 159985
7668 187742
96981 131780
43646 55650
239851 178290
146908 157774
181864 243391
216189 9153
97060 140070
67288 3631
194930 219911
130111 136248
227116 24991
204208 143327
200755 1390...

output:

-1
68
175
-1
131
111
251
225
160
202
84
208
271
108
246
369
186
266
80
275
222
266
120
242
145
255
250
41
319
251
296
105
178
219
140
284
266
237
322
241
58
255
97
246
198
187
107
256
-1
135
207
140
350
312
161
248
179
379
264
311
84
75
106
179
230
243
182
346
161
194
256
152
311
341
168
249
131
-1
...

result:

ok 250000 lines

Test #42:

score: 0
Accepted
time: 1632ms
memory: 39456kb

input:

100000 250000
9881 92153
99677 12348
59088 21386
28527 35345
59359 87118
53428 60445
64408 43938
46033 96713
23217 92074
38531 48732
49927 6569
58455 65311
29478 31014
2159 97480
94465 45536
98851 376
17954 88839
7730 90032
41125 60571
63138 7809
3271 27638
20915 72489
87944 57034
33137 37928
93205 ...

output:

1892
4085
61334
5925
111
52941
42173
69118
12576
57292
38928
59985
15118
67486
5350
24035
10660
1350
9855
9353
8365
4673
16927
25455
35086
7254
46965
9505
4022
16711
32242
30518
16321
323
12126
8734
4552
3747
15226
1093
23525
25907
78006
48891
2073
8775
17988
58880
20061
26586
23
23913
25051
55960
8...

result:

ok 250000 lines

Test #43:

score: 0
Accepted
time: 2665ms
memory: 105680kb

input:

250000 250000
243134 7404
232586 221155
221750 191689
37946 111240
63478 201769
29513 29403
90871 72411
239950 159024
108453 202883
54293 58784
71392 133593
217652 30042
80313 133716
18525 136035
10476 221579
109802 239184
72006 49108
136040 90916
103275 129601
93807 243286
59500 24474
4571 126777
2...

output:

14844
118314
10977
79906
84344
3115
39195
130643
29486
40401
63635
89298
34956
90772
11637
142246
213565
114009
64552
13503
38870
85924
15967
42567
57364
146190
26852
73641
139845
4167
63614
126620
24817
12341
219168
75612
171040
192124
55494
85907
53669
8345
132159
34069
9281
11844
20891
76789
2918...

result:

ok 250000 lines

Test #44:

score: 0
Accepted
time: 2700ms
memory: 102408kb

input:

250000 250000
32158 5357
101399 152903
236714 105080
213708 213628
180538 214065
132805 16732
102057 212674
246787 156274
21064 210537
220376 211753
197085 98123
155880 105585
220049 70323
137810 230976
212908 161369
32858 69014
94296 59986
116904 101106
238140 25137
26181 23561
182012 36610
14579 1...

output:

6076
23902
5026
17611
58461
167559
121441
141258
156059
26156
165438
3769
5470
53940
134981
16976
5304
4082
1087
211336
802
95098
105616
82034
49744
50990
83324
106840
4387
11735
69479
9538
101466
198812
6062
21883
138033
12241
147970
70
280
3066
8145
115424
134083
80418
178960
42883
104635
210118
2...

result:

ok 250000 lines

Subtask #3:

score: 34
Accepted

Dependency #1:

100%
Accepted

Test #45:

score: 34
Accepted
time: 3ms
memory: 3604kb

input:

11 6411
3 1
5 9
11 6
11 2
10 7
6 8
6 9
3 7
4 3
6 1
5 6 1 4
4 3 3 1
9 5 11 6
11 9 1 8
10 4 11 3
2 6 9 1
9 1 4 1
6 8 3 1
6 7 11 5
7 10 9 5
8 9 2 6
3 1 4 3
1 6 3 1
5 6 8 11
7 10 11 2
6 8 4 3
11 8 6 3
6 9 8 6
1 7 11 9
10 4 1 2
6 9 3 1
11 2 9 5
9 11 4 7
8 9 11 1
9 2 10 4
1 5 8 2
6 1 3 7
1 8 5 6
2 11 6 8
...

output:

3
1
2
4
-1
3
2
2
-1
5
3
1
1
3
5
3
3
1
4
-1
2
3
6
4
-1
-1
2
3
2
3
-1
5
2
2
5
2
-1
1
4
2
1
-1
1
3
4
3
1
3
-1
4
3
-1
1
1
3
4
3
1
2
-1
-1
5
1
4
2
4
4
4
-1
-1
2
3
-1
3
1
3
2
-1
3
2
3
2
3
3
3
5
2
2
1
2
1
1
4
3
-1
3
5
3
4
3
3
3
1
4
2
2
2
4
-1
3
3
2
1
3
2
4
2
3
3
-1
3
1
4
1
1
4
3
2
5
4
1
3
4
2
2
5
4
3
-1
-1...

result:

ok 6411 lines

Test #46:

score: 0
Accepted
time: 35ms
memory: 3836kb

input:

680 23904
355 289
317 581
357 219
365 499
261 268
482 131
228 58
113 647
479 551
82 451
333 126
239 630
327 297
58 428
542 479
490 206
58 214
536 651
251 416
302 530
305 40
259 278
347 605
241 135
99 142
425 128
368 8
74 480
207 121
232 324
301 606
44 310
333 420
674 23
475 604
46 219
236 588
592 48...

output:

39
16
-1
15
-1
16
-1
-1
-1
-1
18
37
-1
20
10
34
-1
-1
-1
32
-1
-1
-1
21
-1
7
-1
25
23
24
-1
21
18
-1
15
19
-1
18
16
-1
18
30
14
-1
21
-1
-1
7
-1
34
-1
27
-1
12
9
-1
-1
-1
38
-1
27
-1
17
35
14
14
-1
17
-1
-1
38
36
-1
3
-1
31
-1
20
39
28
21
16
50
-1
-1
38
38
28
44
-1
30
-1
30
-1
-1
8
-1
22
-1
-1
-1
-1...

result:

ok 23904 lines

Test #47:

score: 0
Accepted
time: 24ms
memory: 5532kb

input:

6614 9460
91 3955
6299 4567
1222 2114
1941 4834
5659 1475
3989 769
4580 6416
6313 1336
6056 6220
5855 3571
5925 2676
5276 4415
4237 3321
6205 6059
3697 384
1014 5875
6375 2237
3100 2593
516 2478
4568 5761
456 3366
4560 2022
1907 3105
3232 2725
1410 354
4868 1287
3336 3900
1 2401
6209 3576
1988 4230
...

output:

-1
-1
-1
-1
55
31
-1
23
40
109
-1
-1
-1
45
-1
-1
61
17
46
38
51
-1
-1
71
-1
79
66
61
64
123
26
75
-1
-1
-1
-1
66
-1
48
39
42
-1
-1
-1
-1
-1
-1
82
-1
-1
54
-1
-1
-1
38
-1
68
41
38
-1
101
35
-1
-1
85
-1
-1
-1
74
-1
60
18
33
-1
-1
-1
-1
39
-1
-1
-1
-1
-1
-1
-1
26
-1
-1
-1
-1
-1
-1
38
47
-1
80
-1
-1
92
...

result:

ok 9460 lines

Test #48:

score: 0
Accepted
time: 119ms
memory: 14396kb

input:

39905 6308
19676 17432
22243 10737
20575 9590
141 30769
10546 19847
23839 702
4139 36476
16226 30165
3491 15567
23177 39226
13470 34168
3738 831
12906 4557
28725 12302
33759 16453
21198 2828
35559 34815
20981 11665
12824 10853
4255 26707
8082 38208
3653 13381
12629 29962
31871 19809
30729 31978
3165...

output:

-1
48
136
37
-1
-1
-1
-1
-1
70
-1
101
-1
-1
-1
-1
-1
-1
52
-1
248
-1
-1
42
-1
-1
60
-1
133
-1
-1
133
-1
-1
-1
-1
-1
122
-1
107
-1
-1
91
-1
-1
138
-1
144
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
136
-1
-1
-1
-1
120
-1
142
132
-1
114
-1
-1
169
-1
-1
187
42
45
-1
-1
-1
44
-1
120
132
89
172
172
-1
-1
-1
-1
-...

result:

ok 6308 lines

Test #49:

score: 0
Accepted
time: 556ms
memory: 47660kb

input:

159565 5663
115159 1771
93070 99173
58159 101840
55132 22411
22680 144554
105529 153315
56476 149243
3667 142601
140306 98161
72057 43054
113619 117519
153218 17729
47110 104027
79986 149302
15414 139278
159096 142290
38163 109515
38164 88324
43562 86694
129360 78678
63904 99317
44085 154716
14217 3...

output:

-1
83
-1
-1
-1
-1
-1
-1
117
141
73
-1
-1
128
-1
98
-1
-1
-1
-1
-1
-1
-1
-1
190
149
-1
129
-1
-1
112
-1
195
170
204
-1
-1
-1
-1
-1
-1
102
-1
-1
-1
-1
249
-1
-1
-1
-1
-1
150
202
209
-1
-1
-1
163
-1
148
-1
206
-1
-1
124
-1
-1
-1
235
156
-1
-1
-1
-1
227
-1
198
147
87
288
115
-1
-1
-1
-1
149
271
142
113
...

result:

ok 5663 lines

Test #50:

score: 0
Accepted
time: 1097ms
memory: 71340kb

input:

244080 83440
205583 126867
94279 149633
9163 184815
146527 87745
195734 10415
147380 233806
136120 99079
60475 72069
37282 4166
77701 8369
61459 9126
35971 49808
168659 53180
203719 243537
163240 32166
102193 220032
238348 22863
57552 68351
199301 109857
61157 102703
174396 9517
103082 234041
34659 ...

output:

145
259
339
284
116
148
328
-1
211
378
126
247
-1
203
121
183
-1
181
247
121
175
212
207
-1
175
125
-1
353
205
91
108
244
180
435
-1
-1
244
389
324
288
283
208
172
140
125
194
164
-1
261
183
372
243
242
172
140
-1
67
-1
-1
198
-1
257
273
183
-1
191
140
260
123
377
-1
83
255
146
-1
296
-1
268
152
128...

result:

ok 83440 lines

Test #51:

score: 0
Accepted
time: 1011ms
memory: 70932kb

input:

242306 45493
236086 89023
93966 116840
148438 199010
149202 223897
217547 93560
86258 32075
180193 52059
158237 133106
177673 82401
156526 111363
226621 109696
75786 145607
182410 156445
82171 134181
163647 236011
46079 179682
121367 37886
92660 35983
95713 194985
215625 125542
118629 104919
161820 ...

output:

-1
234
-1
163
-1
-1
117
297
-1
-1
164
-1
354
46
81
-1
96
283
-1
200
227
-1
197
131
118
-1
-1
185
160
216
315
81
-1
324
124
160
293
55
256
36
151
154
76
-1
-1
273
265
-1
-1
105
-1
229
-1
-1
307
303
272
132
-1
-1
132
397
245
159
98
315
146
-1
-1
242
124
257
-1
-1
-1
318
-1
240
138
-1
163
133
215
-1
-1...

result:

ok 45493 lines

Test #52:

score: 0
Accepted
time: 930ms
memory: 64116kb

input:

218122 23844
151285 164425
69898 29102
97456 159505
139238 164215
125972 130966
153467 75821
1922 146028
77023 120942
100302 112080
84938 192248
68931 102586
198400 92140
140339 24883
167499 101990
91242 149359
47044 46139
31034 72633
127370 53740
111697 63231
214135 178865
61728 134476
118088 11750...

output:

-1
171
-1
268
78
133
226
196
-1
172
178
114
208
254
163
154
279
-1
214
-1
-1
162
93
-1
-1
143
133
-1
-1
199
136
132
204
218
-1
153
267
-1
-1
95
-1
228
217
177
231
77
112
267
-1
220
-1
-1
232
184
160
122
94
161
-1
78
56
-1
-1
174
69
-1
168
176
168
268
-1
127
203
-1
156
-1
-1
277
108
93
239
216
-1
-1
...

result:

ok 23844 lines

Test #53:

score: 0
Accepted
time: 764ms
memory: 60396kb

input:

204860 12198
88440 157487
91259 28526
97667 108377
165429 21006
9149 85661
146776 21269
52397 46415
46935 20090
158059 48002
128376 74484
58651 174015
158226 17531
146065 139373
14607 181243
94340 55472
33148 191750
74790 170287
156907 72766
32758 21755
98862 157061
53885 31335
110444 151597
112864 ...

output:

-1
-1
145
160
121
170
-1
262
406
-1
-1
-1
292
-1
-1
271
212
-1
72
214
-1
-1
-1
-1
-1
233
-1
-1
122
-1
86
-1
-1
224
37
-1
-1
-1
-1
94
275
190
-1
-1
225
-1
295
193
-1
-1
-1
-1
198
101
237
-1
-1
138
-1
161
117
269
-1
178
190
333
342
-1
115
-1
-1
142
-1
-1
143
-1
318
94
-1
-1
109
93
-1
-1
-1
291
-1
-1
1...

result:

ok 12198 lines

Test #54:

score: 0
Accepted
time: 812ms
memory: 67344kb

input:

229932 7751
63189 97867
178939 210164
94388 27862
979 169602
154927 135140
122521 51072
217511 67687
15964 7447
83684 5500
188907 158202
76205 206048
124867 138253
83942 220658
217141 32268
36798 20323
191469 17525
16454 68021
45195 132936
5793 166500
179373 223739
209393 225373
40675 9265
143300 53...

output:

-1
-1
-1
-1
-1
-1
-1
-1
174
-1
43
-1
224
337
57
-1
282
-1
-1
281
-1
-1
-1
376
292
-1
-1
163
-1
113
-1
443
392
-1
271
130
107
-1
-1
122
150
298
-1
291
-1
-1
-1
112
-1
-1
-1
-1
-1
182
161
174
146
-1
175
-1
-1
-1
-1
-1
312
-1
-1
-1
202
378
162
-1
255
-1
353
-1
-1
-1
-1
-1
-1
-1
-1
-1
279
-1
-1
-1
-1
-1...

result:

ok 7751 lines

Test #55:

score: 0
Accepted
time: 762ms
memory: 65144kb

input:

221666 5195
218400 63009
98816 95742
132260 5868
67358 133779
54879 18172
195630 69675
47297 111190
131726 27186
59119 54286
126559 108467
171205 63465
49331 157545
142664 28250
11720 3516
25784 49855
169176 63010
109641 80637
119942 97602
29879 81903
114124 47305
155101 36218
12 43211
106595 161886...

output:

-1
-1
-1
-1
111
-1
200
437
129
-1
-1
-1
-1
-1
-1
-1
-1
-1
183
355
-1
314
-1
119
-1
165
323
327
202
315
121
-1
425
-1
202
-1
-1
-1
281
-1
-1
-1
-1
161
-1
-1
-1
269
-1
-1
-1
108
153
-1
321
-1
-1
213
-1
-1
-1
-1
-1
-1
197
174
401
163
363
-1
268
-1
-1
-1
-1
-1
-1
-1
-1
-1
177
-1
-1
395
108
227
-1
-1
394...

result:

ok 5195 lines

Test #56:

score: 0
Accepted
time: 833ms
memory: 72912kb

input:

250000 5290
109598 7954
211767 107403
146343 27132
154779 19937
110418 5167
46542 140599
192436 84022
130701 54323
6338 87211
213131 181880
154909 145677
185544 87711
245994 167032
63543 138597
205999 142783
92731 233354
13096 167993
112945 68776
226979 125758
137256 129601
93709 1781
218482 40081
1...

output:

-1
-1
-1
-1
286
107
-1
-1
191
-1
137
-1
-1
-1
-1
-1
-1
179
-1
-1
-1
-1
182
-1
143
-1
-1
109
247
60
151
-1
-1
-1
-1
-1
104
236
-1
-1
-1
-1
285
103
-1
-1
-1
206
337
210
-1
105
266
325
-1
-1
337
236
-1
-1
-1
-1
-1
-1
310
-1
-1
130
-1
141
-1
-1
-1
286
-1
-1
-1
-1
-1
108
-1
-1
-1
190
247
214
288
-1
178
1...

result:

ok 5290 lines

Test #57:

score: 0
Accepted
time: 836ms
memory: 72948kb

input:

250000 5236
219742 171059
104829 202297
115650 146926
216356 86053
73765 103212
174647 103749
32923 160718
210841 4086
91006 117525
34090 109316
3377 40548
23850 45892
88731 50387
53693 224778
128260 163702
13795 37641
242522 195684
194660 7747
231756 209009
57250 218979
67790 39588
247344 149882
22...

output:

-1
155
-1
-1
150
267
211
-1
-1
-1
-1
286
-1
-1
191
236
-1
-1
304
-1
186
-1
236
-1
254
149
185
120
-1
-1
-1
72
184
-1
-1
-1
203
285
175
-1
23
-1
124
159
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
224
-1
-1
-1
-1
252
205
199
290
-1
-1
-1
124
120
371
83
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
314
-1
-1
236
-1
-1
209
-1
-1...

result:

ok 5236 lines

Test #58:

score: 0
Accepted
time: 351ms
memory: 39792kb

input:

100000 4932
17941 34352
12698 79971
73560 27464
50274 29699
55403 64321
80989 56010
89162 18463
11621 57984
87905 31403
19232 30575
64703 12725
59103 23665
38970 62748
13052 7306
14220 6042
30257 43339
42956 81894
9950 37354
7549 1563
90961 98042
78805 43642
28823 95206
3038 63644
41628 24830
408 45...

output:

1453
22480
28910
26243
42316
56218
57208
29448
57631
99
22959
8756
77376
20904
36455
17554
3433
40944
15705
15371
4167
2400
2397
28727
6912
63642
2696
73546
13056
26459
20024
50531
53304
49565
14907
10998
28564
21892
1718
68746
17645
13980
25454
1070
300
1811
12249
60946
9669
21749
16608
84328
24466...

result:

ok 4932 lines

Test #59:

score: 0
Accepted
time: 1091ms
memory: 104008kb

input:

250000 4880
227710 125453
44823 8413
35045 205877
37438 174387
145074 239733
202501 197145
78231 27069
99996 98587
120567 127910
242386 10565
52748 77136
217936 95876
170735 226067
195188 187355
165413 57902
150546 119599
161155 208825
56311 93768
150388 70366
50356 133159
158231 31526
105992 103144...

output:

3780
2637
40035
179598
191705
87122
22055
45180
49340
157484
22052
48276
60103
13726
2523
125937
11769
43111
13445
142786
25170
42987
21918
80032
42608
6879
25222
96849
87858
61562
109297
2425
225261
127205
46133
3919
4020
73477
58745
63270
9391
28054
218746
89779
3347
58530
23862
9049
170347
19252
...

result:

ok 4880 lines

Test #60:

score: 0
Accepted
time: 1102ms
memory: 102032kb

input:

250000 4961
183832 230830
158597 32801
114815 56025
195075 246889
224465 208627
118937 94716
184958 132949
194717 159048
174839 14491
188381 56111
220105 56023
34222 244229
60410 134829
179254 98484
240460 154429
85097 227232
147624 63426
111246 177227
150112 120152
197397 235015
60937 241906
1259 2...

output:

11020
42792
17596
63831
1341
14366
25468
58662
164570
166636
10349
10889
114352
12795
76373
10405
25645
70872
56711
43334
77827
86000
129680
27297
115261
6261
35007
1513
117205
66357
10889
55068
107519
46774
52500
14024
13239
7176
28730
113580
40671
14698
31972
66876
203231
11502
9125
120306
46798
4...

result:

ok 4961 lines

Test #61:

score: 0
Accepted
time: 21ms
memory: 5924kb

input:

8000 2996
2508 2652
6029 290
1923 1566
2481 6490
255 746
6197 6214
4054 4582
1046 1020
5888 3541
7319 1801
3162 7001
1905 3856
827 3817
7537 3754
6459 3263
236 4116
3210 2044
4111 2897
4843 6865
5768 4021
6575 6482
7261 7259
1086 3799
4313 3364
7472 1651
5307 3227
2882 4880
7648 6691
3782 5416
3560 ...

output:

1564
609
875
424
1564
876
1563
718
475
2596
611
7758
1564
1120
473
472
529
533
2596
1563
423
719
472
530
527
719
7758
526
877
1119
2596
474
873
532
423
875
470
715
609
7758
533
470
423
1122
470
1564
420
1563
422
875
7758
1121
1563
1564
611
2596
1121
610
2595
420
873
720
1563
465
874
1121
532
420
775...

result:

ok 2996 lines

Test #62:

score: 0
Accepted
time: 19ms
memory: 6116kb

input:

9000 2810
1307 6700
8590 6366
2055 7592
1207 3258
3414 8905
8455 2813
4281 1959
579 4257
7411 8741
3542 5634
805 3652
3300 7915
1232 2784
4578 6770
536 4786
5582 8440
5367 7119
6009 4145
1052 7260
7289 1289
7489 441
1473 6629
2091 3456
6352 4718
7872 1722
3687 216
3527 431
8573 1200
4630 5567
8922 1...

output:

811
990
2953
1776
8843
8843
991
1774
428
1775
526
596
988
474
811
808
594
2954
1774
1773
471
8843
1272
527
2952
600
474
988
2954
473
989
1271
811
8843
1777
597
2952
1269
989
688
527
990
990
810
470
426
2954
598
8843
1774
1774
691
2954
1269
1773
467
688
1777
988
471
430
1775
1775
8843
691
685
597
688...

result:

ok 2810 lines

Test #63:

score: 0
Accepted
time: 19ms
memory: 6700kb

input:

10102 2630
6987 7056
3758 3280
5749 6997
5450 8668
6216 8897
7587 8168
1660 2678
1671 8251
748 4646
3107 9882
4123 3930
4155 2013
8967 3879
1886 2148
1867 7432
4337 2396
5211 4951
167 6897
3260 3277
8097 9900
4345 3483
9580 506
2831 7270
2457 2213
6046 6306
7055 4196
6013 3421
9205 5996
9188 927
916...

output:

666
10001
587
769
1431
2002
478
527
771
2003
1111
2000
583
591
673
477
1111
2000
771
668
1428
482
10001
908
524
2001
669
1999
911
772
2003
526
476
3335
1114
771
1114
478
1112
3334
2001
480
10001
530
474
3336
915
3335
3335
2002
771
477
665
1430
672
531
768
1117
1430
3335
912
589
1111
671
590
530
3334...

result:

ok 2630 lines

Test #64:

score: 0
Accepted
time: 19ms
memory: 6772kb

input:

10303 2632
8517 8145
1955 6741
4788 7033
8240 6231
7554 8455
7775 3174
9814 2184
7261 7376
7162 2245
6979 8218
6389 3202
3847 239
92 635
824 9611
1551 819
6344 5190
1335 256
4259 1011
953 2510
3007 7304
3877 8367
7215 386
478 3132
885 1528
1460 4109
3085 5546
6725 998
9203 10154
4922 8382
9449 2214
...

output:

479
484
593
1435
1435
482
912
2004
1435
1117
1115
1436
10006
775
919
531
3340
10006
482
480
594
915
675
599
481
678
919
595
487
533
774
1118
2007
593
485
1435
1434
1122
530
2006
3340
1116
915
481
480
593
528
528
915
2007
531
10006
2008
1434
1118
675
597
2006
537
675
775
530
918
920
916
488
480
671
1...

result:

ok 2632 lines

Test #65:

score: 0
Accepted
time: 33ms
memory: 6464kb

input:

10000 2716
2886 684
4704 6974
2542 6230
7436 1374
1817 6890
5961 7328
6729 170
2849 8902
6019 1128
743 210
4184 2860
2549 3552
9829 4002
6229 5407
8792 6922
3499 4669
7341 7476
5887 5868
5983 8184
9030 7231
5309 5674
2642 9453
2590 3134
2173 5035
3915 3828
9263 1431
7487 2361
9695 346
534 5015
4886 ...

output:

1071
1371
3193
575
878
653
1366
470
1068
475
470
1371
3193
883
653
1368
1370
1368
-1
879
519
1370
3193
3192
1368
1371
651
1070
3194
653
881
654
650
748
580
1907
514
1067
1906
653
1367
576
1906
1904
-1
511
580
748
471
469
1069
748
1367
746
1071
-1
1371
3192
517
3192
1907
653
3192
473
470
3194
471
-1
...

result:

ok 2716 lines

Test #66:

score: 0
Accepted
time: 20ms
memory: 6500kb

input:

10102 2689
2186 633
6729 4137
9799 7449
7374 1622
3535 7335
9991 9502
6407 2167
8680 1725
3257 1120
3581 5082
3735 4954
2652 6079
8351 6191
6694 7328
5600 2567
2497 8181
3947 7235
805 5432
9748 5910
1005 438
1380 2578
7206 1797
9739 5651
2953 5004
2802 475
7855 9843
4736 2581
5880 5349
4384 6491
345...

output:

3225
9626
1392
590
9626
479
478
528
1090
1090
762
1395
479
1089
589
3224
896
1088
1393
899
9626
3224
584
9626
762
1392
3225
664
593
3224
762
481
588
479
900
762
476
1396
524
1395
899
1943
9626
1091
662
588
892
3224
9626
482
586
663
530
3223
762
896
9626
1393
9626
528
594
666
524
3224
3224
525
481
19...

result:

ok 2689 lines

Test #67:

score: 0
Accepted
time: 24ms
memory: 6780kb

input:

10303 2689
5920 3907
1514 9062
7730 6593
8823 3876
5131 8238
6291 8466
7317 3502
9260 617
6191 2569
4085 9457
6252 5958
3508 8991
9337 4024
1836 1508
6807 5063
6964 4958
7756 8665
7414 4341
194 2690
4160 9910
5968 5278
9529 7960
3424 7735
4502 2717
6528 1630
5258 7363
4643 794
3814 1433
3168 6604
73...

output:

1103
496
500
778
541
607
498
3240
494
498
909
9642
680
3240
543
496
9642
494
1106
679
1409
910
604
1107
541
9642
912
777
1411
607
1408
1409
9642
777
541
1959
1407
497
1107
1412
778
604
775
915
499
1959
678
775
1106
500
778
543
496
1409
915
1409
605
9642
9642
600
493
911
499
1959
9642
503
499
1960
14...

result:

ok 2689 lines

Test #68:

score: 0
Accepted
time: 20ms
memory: 6572kb

input:

10303 2686
2531 1431
2552 4
1199 3426
7188 7215
7767 5312
5724 2016
5058 10037
6496 8094
4429 4211
4790 2439
2323 9277
142 8182
5091 2542
747 8306
3112 1847
6123 2107
2717 5460
568 9303
7614 6099
1302 9055
7680 7884
1353 8292
4260 2781
140 5520
5077 1065
1616 1513
9899 4964
4252 6103
2543 2524
2549 ...

output:

884
3214
750
468
468
883
1380
3212
466
3213
1079
9615
513
515
888
888
511
751
1077
9615
1078
1383
9615
753
9615
1079
650
885
576
515
465
523
1933
752
3214
470
521
652
1932
885
1385
1382
519
888
465
572
576
1077
1381
3212
1075
1933
576
1079
1081
9615
518
9615
1082
1381
654
750
1932
1931
1077
573
1079...

result:

ok 2686 lines

Test #69:

score: 0
Accepted
time: 24ms
memory: 6784kb

input:

10303 2690
3491 404
2678 4958
6922 6171
1182 6360
7963 269
8652 10018
7284 4880
2381 5522
8930 1249
7345 9060
4579 8326
1699 254
6888 3036
2341 8363
5818 9909
9180 7439
7039 7452
7499 4014
4989 3711
511 144
3003 4145
6340 4231
8422 689
4129 8761
8437 9843
2623 5503
1110 10021
5660 9533
7914 3393
804...

output:

669
767
768
599
902
9633
899
591
3230
771
1093
490
9633
1403
905
535
591
1402
489
3231
770
488
540
1950
594
768
1100
771
540
1099
537
594
1398
595
596
671
1098
595
906
9633
1097
595
905
1095
536
667
767
1400
900
486
668
1950
594
1403
768
768
539
600
768
768
1402
668
599
1950
592
1399
1097
9633
672
6...

result:

ok 2690 lines

Subtask #4:

score: 36
Accepted

Dependency #1:

100%
Accepted

Test #70:

score: 36
Accepted
time: 3ms
memory: 3772kb

input:

224 1000
24 187
9 166
101 212
13 54
202 45
115 54
50 136
40 91
187 43
84 224
210 142
41 126
59 198
197 8
2 213
168 26
13 59
179 8
55 167
30 71
106 19
194 141
137 125
93 177
194 136
19 4
168 79
175 12
197 220
136 189
19 40
206 50
204 74
204 135
5 198
142 2
13 79
9 102
17 166
19 167
74 35
186 118
61 1...

output:

-1
-1
-1
-1
22
-1
-1
28
18
-1
22
26
-1
-1
25
-1
-1
-1
-1
16
-1
-1
21
-1
9
-1
5
26
-1
11
-1
-1
20
-1
21
17
8
30
19
12
17
-1
10
-1
20
19
-1
15
-1
-1
15
6
-1
7
35
15
11
-1
-1
19
-1
-1
5
-1
-1
-1
-1
-1
-1
-1
6
-1
-1
17
-1
-1
15
16
17
-1
-1
11
-1
-1
25
-1
-1
8
-1
10
21
20
11
-1
-1
-1
23
-1
21
21
-1
-1
12...

result:

ok 1000 lines

Test #71:

score: 0
Accepted
time: 2ms
memory: 3724kb

input:

253 1000
9 242
79 154
89 21
125 230
248 39
223 177
239 238
226 152
85 215
212 66
242 22
242 161
49 37
112 148
144 64
248 138
83 27
56 57
38 162
63 208
144 46
248 73
240 27
113 59
24 78
249 95
214 228
117 140
57 234
72 123
160 144
85 100
150 176
133 205
130 54
213 252
164 229
82 133
231 96
248 211
1 ...

output:

11
12
4
11
15
17
7
22
14
-1
-1
-1
-1
18
1
34
11
18
21
-1
23
-1
-1
-1
-1
8
-1
21
-1
22
-1
-1
-1
22
-1
29
26
-1
12
24
-1
-1
-1
14
-1
-1
-1
-1
9
-1
15
-1
39
16
6
13
-1
19
26
13
-1
28
32
34
23
-1
21
-1
14
6
26
-1
-1
14
-1
34
16
-1
24
-1
-1
-1
30
31
-1
-1
11
-1
-1
-1
13
-1
10
18
12
21
26
-1
-1
4
10
19
11...

result:

ok 1000 lines

Test #72:

score: 0
Accepted
time: 4ms
memory: 3872kb

input:

589 1000
505 559
524 153
40 246
131 336
174 534
572 29
124 204
495 69
218 9
565 579
204 4
448 92
244 481
584 28
529 412
317 257
398 407
249 104
120 133
572 24
569 353
395 513
225 339
376 176
69 128
269 377
493 181
216 437
519 312
371 544
583 556
73 3
267 26
104 473
228 587
73 300
176 534
124 102
429...

output:

36
-1
47
-1
-1
-1
-1
-1
-1
-1
-1
19
31
-1
-1
-1
-1
28
25
-1
-1
27
39
-1
-1
13
43
43
-1
-1
-1
-1
35
-1
-1
-1
-1
56
-1
-1
-1
-1
25
-1
-1
-1
-1
-1
4
31
-1
-1
30
-1
21
40
-1
-1
39
-1
-1
-1
-1
28
24
-1
-1
-1
-1
-1
-1
-1
-1
-1
21
-1
-1
24
-1
-1
23
17
-1
25
32
25
-1
25
-1
-1
-1
-1
-1
-1
33
46
-1
37
46
16
-...

result:

ok 1000 lines

Test #73:

score: 0
Accepted
time: 3ms
memory: 3984kb

input:

969 1000
385 84
562 756
602 76
314 257
18 550
265 169
344 106
653 233
809 772
717 25
457 967
653 177
414 519
256 389
952 954
261 458
705 313
153 393
699 964
229 416
53 921
670 224
234 177
678 893
341 742
381 139
726 93
57 715
160 730
56 701
670 318
904 26
212 708
87 437
59 430
547 66
789 412
272 443...

output:

-1
-1
26
34
-1
29
13
-1
-1
-1
27
35
57
-1
-1
-1
-1
25
28
22
-1
-1
26
-1
-1
-1
-1
-1
-1
-1
-1
14
12
36
43
32
-1
-1
-1
-1
-1
-1
-1
33
36
-1
23
-1
36
13
29
-1
-1
-1
39
-1
23
-1
-1
-1
15
41
-1
26
-1
-1
-1
-1
-1
-1
45
-1
36
-1
-1
36
-1
-1
-1
12
-1
-1
57
-1
-1
-1
39
-1
34
23
32
13
49
-1
30
20
32
-1
-1
-1
...

result:

ok 1000 lines

Test #74:

score: 0
Accepted
time: 3ms
memory: 4180kb

input:

927 1000
649 888
883 489
406 374
442 398
600 796
132 475
121 886
507 57
795 827
127 623
345 385
102 125
69 567
616 581
74 385
872 270
211 31
116 633
625 320
542 536
849 565
451 582
803 662
23 924
226 443
536 792
503 97
543 450
64 21
289 660
588 841
875 252
71 503
20 248
817 215
625 352
238 119
865 1...

output:

-1
13
81
-1
-1
-1
-1
-1
49
-1
-1
23
-1
24
42
34
-1
-1
-1
-1
-1
-1
-1
26
-1
33
-1
-1
-1
21
-1
-1
-1
36
-1
4
-1
27
-1
-1
-1
-1
20
-1
-1
55
-1
-1
18
-1
12
51
52
7
-1
46
-1
-1
-1
-1
-1
-1
-1
-1
19
-1
-1
-1
41
-1
-1
-1
45
-1
-1
-1
-1
28
-1
-1
-1
-1
-1
22
46
-1
35
37
-1
22
-1
23
-1
-1
-1
62
-1
-1
-1
-1
-1...

result:

ok 1000 lines

Test #75:

score: 0
Accepted
time: 0ms
memory: 3896kb

input:

900 1000
679 252
16 294
536 543
284 555
604 219
439 257
577 877
200 134
701 94
648 529
74 473
724 434
413 663
128 459
680 865
454 436
470 16
399 685
109 90
10 316
131 637
107 418
62 711
591 443
313 121
826 176
723 365
37 231
740 726
339 493
79 785
828 95
461 558
283 573
188 167
276 598
335 877
773 5...

output:

-1
30
-1
-1
-1
27
-1
34
-1
-1
29
-1
-1
-1
24
-1
-1
20
-1
-1
21
27
-1
-1
-1
20
-1
-1
-1
20
39
-1
-1
43
-1
36
43
-1
17
-1
45
-1
-1
-1
-1
-1
-1
13
31
-1
27
15
40
-1
-1
24
25
-1
16
-1
-1
-1
-1
-1
22
-1
-1
-1
-1
-1
-1
12
-1
23
-1
-1
-1
34
39
-1
28
-1
-1
-1
28
24
-1
-1
-1
39
-1
-1
-1
-1
16
-1
23
-1
-1
9
2...

result:

ok 1000 lines

Test #76:

score: 0
Accepted
time: 3ms
memory: 4144kb

input:

950 1000
386 766
574 262
585 820
580 759
367 343
267 628
505 344
28 84
335 289
652 497
567 208
282 161
81 321
748 653
634 105
145 345
22 599
365 773
423 445
263 640
64 239
101 920
322 49
460 379
491 61
537 843
194 695
590 65
162 563
30 839
4 658
322 254
147 371
830 323
847 636
193 908
292 736
168 76...

output:

-1
-1
-1
-1
-1
-1
-1
-1
52
-1
-1
-1
29
21
-1
-1
-1
45
-1
25
-1
-1
-1
29
37
26
-1
-1
-1
-1
-1
-1
-1
19
37
-1
27
-1
-1
-1
-1
-1
-1
39
-1
23
-1
18
-1
-1
63
-1
24
-1
48
35
45
-1
-1
-1
-1
22
24
-1
-1
33
-1
-1
50
-1
30
-1
47
-1
-1
-1
-1
20
35
45
-1
-1
-1
-1
52
24
-1
-1
47
-1
-1
-1
-1
4
-1
-1
-1
29
-1
-1
-...

result:

ok 1000 lines

Test #77:

score: 0
Accepted
time: 3ms
memory: 3904kb

input:

922 1000
557 107
804 596
529 905
502 393
247 129
758 323
643 367
198 658
462 887
211 560
240 867
108 423
456 169
79 227
357 827
599 790
438 182
85 398
891 639
539 496
287 488
586 922
621 421
107 561
730 259
184 911
50 265
662 265
4 355
457 790
914 629
572 250
787 877
655 849
772 178
24 34
445 678
29...

output:

24
34
-1
28
44
37
47
-1
35
50
-1
-1
-1
-1
28
-1
-1
16
-1
-1
-1
-1
-1
13
-1
-1
-1
-1
45
24
-1
13
-1
-1
22
65
-1
32
-1
-1
53
49
-1
-1
22
-1
-1
-1
-1
55
-1
-1
-1
16
17
24
26
-1
-1
-1
-1
-1
54
-1
-1
-1
30
-1
-1
-1
-1
-1
-1
-1
40
-1
-1
43
43
-1
-1
-1
39
-1
-1
22
13
-1
57
-1
35
-1
-1
39
-1
-1
-1
-1
41
-1
...

result:

ok 1000 lines

Test #78:

score: 0
Accepted
time: 2ms
memory: 4048kb

input:

1000 1000
308 537
957 406
639 400
973 174
738 270
888 621
429 438
473 295
818 923
971 73
755 13
2 595
544 173
555 339
445 949
481 978
828 137
68 534
241 515
637 411
73 753
598 640
587 138
800 10
654 62
875 336
925 230
460 191
157 153
484 893
915 225
962 301
174 355
736 488
559 869
140 865
289 520
37...

output:

443
481
471
475
489
495
497
462
443
507
450
493
441
515
495
501
473
479
417
528
495
427
474
529
453
432
432
490
494
502
448
467
467
446
495
458
437
481
500
474
479
436
420
475
408
478
443
458
490
497
439
446
448
459
436
415
467
434
467
483
489
498
485
500
483
496
474
457
474
481
499
542
494
480
488
...

result:

ok 1000 lines

Test #79:

score: 0
Accepted
time: 3ms
memory: 4056kb

input:

1000 1000
946 877
412 299
493 165
968 864
960 111
522 513
502 355
996 976
868 371
550 362
580 297
710 730
489 476
296 492
702 202
902 134
591 598
253 943
922 581
373 922
640 710
399 626
259 698
820 359
933 722
357 645
409 879
888 488
779 795
532 934
767 773
101 689
607 927
20 377
378 506
286 794
692...

output:

497
468
506
486
481
422
411
535
469
441
493
450
401
521
472
493
500
463
445
442
487
535
496
490
511
509
495
426
500
496
499
459
558
486
460
406
493
480
579
505
506
476
491
477
443
471
439
453
486
518
488
478
452
425
459
423
517
446
530
495
485
446
493
416
492
498
482
460
477
497
461
499
468
423
565
...

result:

ok 1000 lines

Test #80:

score: 0
Accepted
time: 2ms
memory: 3740kb

input:

102 1000
4 26
19 101
27 55
20 35
95 28
79 5
81 85
63 76
68 33
49 46
75 93
45 38
8 47
17 22
38 6
42 88
84 59
52 70
5 37
66 16
21 36
1 75
35 15
54 77
9 27
73 90
13 7
80 31
41 95
62 74
36 81
69 29
10 17
90 44
26 13
61 57
12 82
92 63
83 45
47 51
40 48
6 51
46 34
65 2
44 53
18 89
22 79
94 83
43 96
57 65
...

output:

49
-1
37
-1
-1
52
53
-1
41
-1
-1
49
-1
44
40
-1
-1
42
-1
36
-1
54
51
-1
42
-1
51
50
33
36
45
-1
-1
-1
-1
-1
29
40
44
37
-1
43
-1
-1
54
-1
-1
42
45
38
-1
-1
-1
-1
49
-1
52
41
48
51
50
-1
-1
40
31
-1
47
30
-1
-1
40
54
34
41
43
40
-1
-1
-1
-1
40
39
-1
-1
55
36
-1
52
-1
40
54
47
-1
-1
-1
-1
-1
46
32
50
...

result:

ok 1000 lines

Test #81:

score: 0
Accepted
time: 2ms
memory: 3904kb

input:

475 1000
296 361
9 435
396 254
283 141
450 165
366 124
89 408
93 197
24 461
51 211
150 463
237 247
279 127
37 227
266 475
365 181
80 23
238 217
453 360
221 43
440 293
102 308
126 437
361 37
127 107
378 364
236 46
315 113
60 146
48 271
87 154
333 291
321 81
17 281
304 209
50 164
314 334
222 119
323 1...

output:

-1
383
326
359
-1
295
-1
351
376
378
325
299
328
-1
-1
-1
-1
300
378
289
303
342
376
351
344
378
326
293
400
380
360
-1
-1
326
381
377
395
306
305
387
334
349
320
350
350
392
-1
340
317
365
-1
-1
305
332
348
-1
-1
338
339
292
409
-1
325
377
342
353
329
308
349
304
-1
-1
330
323
313
346
363
319
325
2...

result:

ok 1000 lines

Test #82:

score: 0
Accepted
time: 3ms
memory: 3888kb

input:

695 1000
644 507
647 668
529 182
261 86
537 508
324 142
499 441
295 71
82 468
336 514
663 472
240 399
350 294
258 214
538 45
303 216
614 386
597 53
30 12
681 490
195 437
123 271
532 598
458 280
342 313
409 137
150 684
6 304
301 464
174 518
31 328
394 266
186 62
507 95
607 483
474 258
389 416
313 376...

output:

538
-1
505
435
471
489
-1
-1
522
515
536
488
493
-1
425
455
437
459
391
521
513
516
470
509
415
512
495
506
420
503
454
512
-1
497
485
492
469
500
515
512
473
447
531
456
452
399
469
455
518
407
424
490
577
503
456
497
531
445
463
469
503
-1
459
454
425
506
491
444
467
392
495
408
522
526
-1
491
459...

result:

ok 1000 lines

Test #83:

score: 0
Accepted
time: 3ms
memory: 3980kb

input:

950 1000
803 701
333 85
587 271
766 366
443 440
521 922
512 395
385 247
493 611
553 339
114 757
65 690
83 520
444 831
439 792
695 596
79 619
784 335
343 499
119 116
573 280
847 437
648 873
232 923
323 836
431 812
624 248
51 542
740 99
145 642
282 70
169 364
783 822
502 58
688 571
175 888
378 117
14 ...

output:

653
628
684
666
634
683
667
612
703
692
601
664
713
676
716
671
668
781
693
594
688
648
560
749
639
712
640
656
682
663
590
-1
667
733
637
721
749
586
650
670
642
634
669
648
673
632
574
591
756
670
723
-1
652
666
671
638
653
699
640
-1
674
644
655
646
-1
673
651
593
580
711
660
603
642
685
657
707
...

result:

ok 1000 lines

Test #84:

score: 0
Accepted
time: 3ms
memory: 3992kb

input:

957 1000
908 440
716 11
934 317
381 132
193 867
259 563
375 309
635 677
781 538
946 388
897 13
351 646
135 114
806 691
453 241
342 707
361 931
554 906
156 955
327 376
223 255
912 576
175 605
48 146
836 187
333 419
307 692
237 80
284 553
2 130
87 504
760 128
922 276
77 770
513 34
39 196
755 165
691 1...

output:

581
512
595
-1
561
-1
681
632
-1
543
657
600
627
615
558
523
-1
677
587
446
532
535
564
526
657
618
489
455
646
621
699
545
579
600
572
491
569
548
527
575
549
616
636
552
565
486
537
640
598
663
512
701
633
613
586
-1
600
553
478
579
498
575
591
660
582
543
610
598
-1
-1
675
485
608
586
476
613
561...

result:

ok 1000 lines

Test #85:

score: 0
Accepted
time: 0ms
memory: 3916kb

input:

1000 1000
769 836
963 259
461 817
837 11
314 880
103 515
25 31
37 628
490 7
960 763
679 227
847 802
512 262
605 796
305 954
600 448
687 858
507 778
351 319
822 501
513 358
183 548
781 827
338 972
529 787
935 922
122 223
839 815
336 65
297 124
748 860
460 193
871 837
740 880
717 509
386 133
985 291
4...

output:

44
44
44
41
44
41
44
44
41
44
44
44
41
44
44
41
41
41
44
44
41
44
41
44
44
44
41
44
41
44
44
41
44
44
44
41
41
44
41
41
41
41
44
41
44
41
41
44
44
44
41
41
41
41
44
44
44
44
44
44
44
41
44
41
41
41
41
44
44
41
44
41
41
44
41
44
41
41
41
41
41
44
41
41
41
41
44
41
44
44
44
44
41
41
44
41
44
41
41
41
...

result:

ok 1000 lines

Test #86:

score: 0
Accepted
time: 0ms
memory: 4160kb

input:

1000 1000
402 741
579 526
55 562
701 761
688 513
171 487
98 905
112 786
282 939
396 26
139 276
195 249
242 677
898 67
388 81
634 571
666 101
54 540
1000 474
787 836
734 826
485 14
663 25
449 330
581 465
666 413
292 718
746 37
872 157
96 498
280 514
478 60
449 945
546 497
155 171
352 274
140 625
452 ...

output:

37
40
39
40
35
36
36
38
46
46
42
47
46
37
38
37
38
36
49
43
50
38
37
35
43
34
35
36
36
37
52
38
41
37
34
44
39
37
31
37
43
47
38
38
52
37
36
36
52
49
40
37
37
52
41
36
34
38
52
48
40
36
40
43
34
37
34
33
45
44
37
52
39
50
37
36
37
37
36
43
45
49
34
45
46
36
45
49
36
37
41
52
34
52
37
37
49
43
46
44
...

result:

ok 1000 lines

Test #87:

score: 0
Accepted
time: 0ms
memory: 3940kb

input:

1000 1000
839 809
973 559
201 307
455 803
121 564
105 71
958 767
853 675
49 889
268 155
976 761
515 200
937 80
370 609
737 94
648 378
128 784
814 464
440 727
1 719
597 283
657 216
118 722
671 315
714 28
541 737
304 412
136 131
536 402
547 26
278 995
467 893
870 192
662 313
369 903
701 443
461 780
86...

output:

28
49
92
62
47
12
25
-1
-1
52
53
31
51
25
46
48
40
41
-1
56
-1
43
-1
42
-1
91
34
58
37
45
84
-1
38
-1
22
-1
41
-1
50
88
47
53
-1
41
13
19
48
46
47
44
44
51
96
41
17
62
-1
79
35
20
88
-1
-1
35
-1
41
51
65
29
-1
38
-1
32
58
30
48
32
31
81
50
54
60
55
56
53
19
32
-1
-1
59
90
54
44
29
39
85
17
42
75
-1
...

result:

ok 1000 lines

Test #88:

score: 0
Accepted
time: 0ms
memory: 3932kb

input:

1000 1000
359 951
844 268
845 568
940 823
717 561
633 41
241 872
775 804
59 4
587 993
874 595
814 238
562 654
409 998
669 594
247 315
494 784
393 543
49 97
518 607
858 33
751 669
221 845
703 783
770 978
330 719
161 853
464 529
348 777
231 361
509 590
985 625
227 245
616 370
415 189
656 605
76 575
37...

output:

63
-1
77
-1
136
92
55
-1
105
-1
117
80
-1
-1
100
-1
73
131
120
-1
92
-1
33
45
57
-1
-1
87
-1
133
101
101
-1
46
-1
84
125
29
98
106
133
-1
83
99
71
139
104
-1
109
-1
68
-1
83
68
-1
49
-1
74
109
-1
-1
35
30
60
111
88
20
48
110
77
-1
89
-1
-1
-1
-1
-1
54
-1
87
110
-1
-1
101
51
29
78
57
-1
-1
49
78
80
-...

result:

ok 1000 lines

Test #89:

score: 0
Accepted
time: 3ms
memory: 3968kb

input:

1000 1000
25 1
192 980
872 758
551 388
455 709
869 644
427 657
741 477
969 381
656 823
559 777
635 761
137 560
53 38
946 814
709 972
387 687
601 238
971 480
877 879
761 592
374 833
638 357
549 70
11 837
967 121
569 545
95 204
230 508
311 675
236 451
684 85
148 64
605 580
630 860
204 894
864 933
78 2...

output:

163
192
83
133
129
-1
-1
40
-1
69
83
124
115
128
49
-1
177
-1
24
89
116
98
164
118
187
86
89
147
93
90
-1
59
123
91
128
80
100
115
71
93
102
119
-1
95
139
118
42
90
108
74
-1
108
125
131
128
172
126
102
102
103
106
-1
112
85
83
91
77
125
106
50
105
126
96
85
126
61
-1
134
95
-1
-1
71
-1
76
-1
69
-1
...

result:

ok 1000 lines

Test #90:

score: 0
Accepted
time: 4ms
memory: 4176kb

input:

1000 1000
415 364
163 63
836 53
419 302
376 771
984 543
747 487
955 566
191 858
340 338
725 276
576 533
912 402
216 886
874 427
907 504
677 988
360 665
472 559
766 257
956 675
83 294
582 970
347 919
288 217
108 124
778 176
821 850
890 20
660 5
226 359
247 966
25 382
412 340
849 695
476 293
149 270
5...

output:

124
107
150
86
-1
132
-1
-1
126
96
100
72
45
68
97
81
128
107
116
124
111
-1
131
107
92
115
-1
117
114
134
111
115
-1
-1
105
102
-1
149
107
129
-1
78
95
85
129
43
170
119
110
-1
81
102
129
101
94
86
-1
125
111
-1
118
106
149
96
-1
-1
116
112
-1
55
129
146
-1
52
-1
133
55
112
134
99
105
107
116
112
1...

result:

ok 1000 lines

Test #91:

score: 0
Accepted
time: 5ms
memory: 4032kb

input:

1000 1000
567 641
255 982
47 613
682 342
386 353
533 227
894 385
522 576
835 452
458 211
241 749
984 30
700 6
808 981
58 306
479 763
238 970
641 104
177 314
710 624
291 257
399 404
211 77
791 299
908 783
922 58
323 464
351 914
401 138
277 207
816 214
923 168
874 413
119 741
777 747
283 628
807 258
2...

output:

279
-1
212
238
-1
-1
-1
373
-1
-1
310
545
350
143
481
-1
275
288
-1
-1
-1
-1
362
-1
310
-1
216
228
381
150
-1
-1
-1
-1
296
-1
382
-1
418
331
-1
359
315
-1
-1
-1
323
-1
265
-1
-1
183
-1
455
366
387
221
346
228
-1
-1
199
361
432
403
275
322
252
249
331
403
186
304
186
402
553
-1
478
320
519
163
176
-1...

result:

ok 1000 lines

Test #92:

score: 0
Accepted
time: 4ms
memory: 4024kb

input:

1000 1000
574 559
534 146
223 96
341 816
328 202
87 441
318 176
995 402
675 458
237 383
372 765
567 756
245 370
622 44
504 440
9 14
424 835
224 653
17 567
156 505
577 572
470 562
657 691
546 296
357 200
580 848
757 459
667 837
303 163
950 415
817 658
127 319
744 301
272 640
472 809
583 112
619 589
7...

output:

-1
324
187
131
314
230
336
550
534
40
188
291
243
-1
331
453
281
289
252
324
480
161
-1
-1
-1
91
293
-1
372
317
-1
280
241
427
201
315
346
298
187
310
241
366
350
116
420
218
39
362
501
373
99
-1
360
407
97
244
332
282
329
237
333
312
406
335
190
-1
284
312
312
191
-1
297
136
135
334
303
251
413
357...

result:

ok 1000 lines

Test #93:

score: 0
Accepted
time: 5ms
memory: 4056kb

input:

1000 1000
123 727
571 24
691 161
675 617
335 517
317 674
945 350
568 776
385 364
96 334
711 929
708 411
820 169
590 610
908 598
19 12
928 787
704 202
9 697
391 725
320 286
257 346
451 993
960 856
229 52
810 734
988 604
2 736
952 696
991 263
659 828
452 67
915 437
529 885
550 239
919 799
458 705
330 ...

output:

193
219
236
237
127
241
203
187
318
187
104
-1
270
261
217
203
174
210
296
172
223
288
-1
-1
223
341
98
291
248
182
303
254
282
197
-1
190
-1
195
292
155
235
324
231
300
275
307
188
271
189
246
326
-1
224
226
262
298
319
268
234
232
117
-1
-1
-1
259
273
-1
108
186
167
172
304
147
-1
243
106
-1
229
2...

result:

ok 1000 lines

Test #94:

score: 0
Accepted
time: 4ms
memory: 4028kb

input:

1000 1000
653 964
81 83
6 939
787 405
235 961
734 230
77 971
87 628
864 713
295 999
558 760
222 66
362 54
989 410
126 137
197 238
151 397
868 937
489 332
796 610
753 535
404 883
265 345
400 524
158 667
30 110
612 921
201 98
359 709
227 797
794 44
977 683
79 416
790 647
48 126
276 706
926 588
607 894...

output:

-1
290
252
263
257
288
222
198
273
162
283
215
-1
375
-1
158
335
300
354
-1
-1
424
309
-1
244
-1
215
323
237
247
47
233
60
-1
356
268
365
349
93
-1
395
220
321
262
90
-1
193
203
-1
44
356
255
104
246
285
282
267
-1
389
95
-1
-1
376
332
-1
396
-1
314
-1
323
-1
315
-1
357
310
282
290
-1
307
224
191
-1...

result:

ok 1000 lines

Test #95:

score: 0
Accepted
time: 0ms
memory: 3792kb

input:

250 1000
141 163
100 11
248 17
89 240
118 224
173 175
125 220
83 169
45 236
97 151
181 84
231 144
169 188
108 101
210 12
199 27
216 247
95 15
120 29
220 168
18 166
102 248
202 13
119 37
128 239
250 139
221 71
29 135
195 115
191 146
94 51
227 55
104 124
184 58
14 4
215 203
155 199
192 9
102 2
164 191...

output:

49
229
79
229
80
79
79
79
47
48
78
229
80
229
51
51
80
229
229
49
229
79
229
229
79
80
49
48
79
229
49
48
48
48
229
50
79
48
50
78
78
79
229
50
79
229
229
79
80
229
229
47
50
79
229
49
51
229
80
229
48
229
78
79
49
229
80
229
229
229
78
49
229
79
229
229
78
79
48
48
50
229
49
79
47
229
229
79
78
229...

result:

ok 1000 lines

Test #96:

score: 0
Accepted
time: 3ms
memory: 3848kb

input:

500 1000
313 205
258 87
123 379
464 255
178 166
3 361
151 110
87 346
455 131
93 196
20 190
441 287
59 333
86 93
284 21
90 492
195 449
451 232
423 485
439 258
256 381
131 487
149 429
352 4
269 242
435 378
408 384
91 350
494 323
135 447
457 142
278 88
73 56
321 14
290 115
54 470
276 204
96 167
496 337...

output:

452
158
100
74
158
101
452
72
100
159
99
73
157
98
157
158
74
452
158
157
74
101
77
157
452
75
101
99
159
100
73
100
158
452
158
102
72
452
100
157
101
71
99
72
73
99
100
100
76
158
99
159
452
73
158
452
452
157
74
158
74
157
452
452
72
157
101
77
452
157
452
76
158
101
452
101
101
76
100
101
452
45...

result:

ok 1000 lines

Test #97:

score: 0
Accepted
time: 4ms
memory: 3860kb

input:

890 1000
375 776
453 510
179 696
421 7
580 363
563 685
405 782
700 366
845 358
526 607
742 790
468 53
472 200
99 772
149 463
507 230
75 406
73 737
359 647
731 837
707 435
264 641
705 662
688 223
616 79
316 225
854 693
371 374
813 301
158 528
680 560
783 694
658 304
104 823
239 494
298 680
561 136
17...

output:

846
127
172
285
846
174
846
846
126
285
286
287
286
174
126
846
286
846
124
174
129
846
846
128
175
126
174
846
846
174
174
846
173
124
846
172
124
846
126
846
846
286
286
846
123
285
287
285
172
125
286
172
287
287
125
846
175
125
285
176
126
846
286
846
285
286
175
128
123
846
127
286
286
128
846
...

result:

ok 1000 lines

Test #98:

score: 0
Accepted
time: 7ms
memory: 3980kb

input:

970 1000
296 212
116 426
583 377
225 741
477 897
790 144
121 964
352 206
122 475
153 252
314 827
27 886
857 696
825 215
133 535
592 177
855 428
659 699
320 830
538 806
703 594
466 940
194 500
297 932
822 684
156 41
586 900
459 352
24 472
452 857
418 276
284 466
326 927
422 139
227 211
950 885
110 40...

output:

191
190
137
140
192
311
910
138
192
141
311
910
192
139
192
310
309
189
910
310
191
189
910
311
910
311
310
910
138
309
139
191
910
910
190
140
310
140
910
137
910
138
910
192
191
189
139
910
309
309
310
910
190
137
139
910
910
190
188
139
139
310
139
140
191
140
910
910
910
910
910
309
188
910
309
...

result:

ok 1000 lines

Test #99:

score: 0
Accepted
time: 4ms
memory: 3904kb

input:

1000 1000
708 703
894 22
325 145
350 251
604 347
94 14
879 306
92 368
857 986
595 749
336 314
942 263
945 55
450 729
44 340
986 768
702 876
801 381
925 712
139 806
672 412
544 484
52 925
422 372
548 240
662 803
368 751
718 566
757 692
477 930
397 817
492 684
331 339
694 49
815 519
130 255
938 385
89...

output:

196
110
965
965
142
142
141
965
198
109
324
324
965
142
111
197
965
195
110
195
110
111
143
325
195
324
142
324
326
965
142
965
112
109
110
324
112
111
324
965
965
142
141
965
965
112
142
143
325
325
197
111
112
197
196
113
110
112
142
143
142
324
109
965
324
965
325
140
965
325
965
198
140
325
198
...

result:

ok 1000 lines

Test #100:

score: 0
Accepted
time: 4ms
memory: 3996kb

input:

1000 1000
344 239
555 816
641 517
218 56
23 539
206 926
336 823
983 328
4 195
675 483
961 306
781 155
122 672
655 337
784 888
225 452
65 232
436 973
5 575
589 636
518 168
931 960
755 15
464 915
867 185
455 641
724 646
158 102
438 854
306 868
19 132
398 368
215 601
622 656
301 229
933 562
208 624
310...

output:

305
182
181
304
-1
180
304
138
-1
180
-1
-1
135
134
135
181
303
181
-1
303
181
303
-1
180
-1
304
305
179
135
181
182
-1
-1
181
-1
182
305
136
181
-1
304
134
137
133
-1
-1
134
137
138
181
180
181
303
180
137
303
-1
181
135
-1
304
181
-1
181
-1
-1
181
305
136
305
181
-1
303
182
134
304
304
303
181
180...

result:

ok 1000 lines

Test #101:

score: 0
Accepted
time: 4ms
memory: 4132kb

input:

1000 1000
439 520
643 19
935 649
226 91
83 725
800 667
748 427
407 798
417 820
498 232
101 569
754 610
192 437
722 602
825 139
800 508
425 163
64 506
351 462
96 774
45 124
958 939
469 183
163 421
85 411
822 107
284 239
849 892
76 342
503 383
213 973
330 485
441 221
903 282
628 577
855 756
193 317
83...

output:

185
298
297
137
188
185
297
-1
137
298
139
187
-1
187
-1
-1
141
137
299
186
-1
-1
297
299
298
-1
141
186
188
188
136
188
187
140
135
-1
136
137
298
-1
186
185
135
-1
138
298
138
185
298
185
-1
298
298
-1
137
140
138
299
186
137
137
140
141
-1
298
188
187
-1
-1
186
188
184
186
185
186
186
139
297
138...

result:

ok 1000 lines

Test #102:

score: 0
Accepted
time: 0ms
memory: 3940kb

input:

1000 1000
835 492
67 350
544 535
797 150
298 909
405 641
577 867
894 988
411 11
297 12
414 612
792 59
265 820
132 816
795 655
826 731
244 857
672 465
63 316
546 492
647 296
855 215
570 250
499 520
856 802
115 388
321 826
427 969
86 233
396 589
487 625
279 456
282 222
415 757
520 674
370 593
780 728
...

output:

181
133
-1
181
181
131
180
-1
183
135
181
181
180
130
132
-1
135
132
294
293
180
181
131
292
294
-1
292
-1
181
133
135
-1
133
-1
181
-1
180
-1
135
-1
292
-1
134
-1
293
-1
-1
292
180
180
294
293
-1
132
292
-1
133
-1
-1
-1
-1
-1
293
133
131
180
-1
293
132
-1
180
133
135
181
181
181
183
131
181
132
135...

result:

ok 1000 lines

Subtask #5:

score: 51
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Test #103:

score: 51
Accepted
time: 16ms
memory: 3908kb

input:

100 22718
73 38
5 23
74 56
76 15
64 29
3 52
99 45
14 57
10 31
11 42
100 27
91 36
32 35
92 63
77 22
98 61
43 3
28 5
9 67
37 58
72 76
69 34
52 17
82 54
25 51
95 32
79 13
40 73
57 85
12 46
31 7
86 79
89 24
65 20
47 9
85 19
50 84
6 89
18 66
96 80
97 49
71 26
83 72
78 44
17 75
56 4
2 62
93 18
75 95
94 40...

output:

45
45
47
44
47
45
51
50
50
50
49
50
47
43
46
47
49
49
48
46
48
53
48
44
49
48
48
47
49
45
46
46
55
54
45
39
42
49
48
51
45
50
50
51
48
44
45
47
50
49
48
39
45
44
47
50
41
41
51
45
46
52
39
48
47
48
41
47
45
47
44
41
46
44
48
47
43
48
49
47
48
44
47
48
50
41
39
40
50
52
53
49
41
41
46
47
42
49
48
51
...

result:

ok 22718 lines

Test #104:

score: 0
Accepted
time: 4ms
memory: 4052kb

input:

1000 2231
314 686
108 697
38 127
672 142
331 874
73 562
774 457
60 620
31 185
809 594
375 843
725 647
698 717
527 370
580 812
783 93
288 939
611 677
413 867
32 805
858 828
344 287
769 472
191 831
819 237
966 52
612 311
516 121
970 363
722 369
920 473
110 700
622 2
310 806
559 592
326 931
903 338
281...

output:

535
474
439
499
518
432
457
450
531
500
479
483
493
479
465
426
485
485
468
438
414
434
443
468
460
467
506
475
414
444
508
496
482
463
438
478
476
471
456
441
481
499
476
492
478
465
493
467
474
453
488
463
479
496
440
490
499
490
517
473
478
439
446
479
510
494
462
481
461
431
470
477
489
496
451
...

result:

ok 2231 lines

Test #105:

score: 0
Accepted
time: 318ms
memory: 40380kb

input:

100000 22
44956 16007
81843 97996
72225 13188
91462 91005
62664 53716
80300 68025
83653 81083
19788 93313
86044 56114
79381 76124
52588 56355
56325 77020
59697 22159
82657 97851
71617 75419
27457 72581
126 9767
51795 7010
54290 79560
54306 85606
81875 1704
3782 96717
74141 73604
96096 24233
85925 24...

output:

43850
46524
50424
50011
49228
45762
46999
48935
44795
48863
48978
49742
48743
42598
48933
44486
45239
48007
50773
49592
43088
42195

result:

ok 22 lines

Test #106:

score: 0
Accepted
time: 747ms
memory: 79492kb

input:

200000 11
120097 199390
21366 116867
31782 127919
140204 115668
170616 134404
11129 111172
92801 107054
90244 96737
182674 109768
106063 122580
172117 148384
162807 57128
122880 130959
8585 172393
582 134249
178457 51506
196464 92026
97705 143616
14671 16510
130132 128778
102344 98781
98320 71726
10...

output:

82892
95096
84618
87598
90437
86821
97596
101230
94138
99596
98565

result:

ok 11 lines

Test #107:

score: 0
Accepted
time: 1159ms
memory: 109416kb

input:

250000 8
249401 240304
60948 81935
218853 84963
3595 61516
160549 4078
243943 124419
215521 49076
69319 79510
213769 203561
29700 38159
219998 83565
115113 64425
29820 164393
114877 106901
230945 159733
45464 4690
133597 167631
56724 143511
195287 99644
171000 171889
172970 144471
194995 175054
2213...

output:

123856
123114
116297
121024
116764
120680
122062
117703

result:

ok 8 lines

Test #108:

score: 0
Accepted
time: 19ms
memory: 3860kb

input:

673 8890
591 490
639 620
182 551
645 403
536 578
394 374
216 585
466 556
205 532
489 383
338 504
340 444
180 218
138 622
534 119
361 38
357 457
72 589
512 241
261 267
41 33
164 132
327 293
126 257
561 155
118 288
135 324
69 23
396 221
417 580
637 206
107 452
413 666
471 564
426 81
75 553
408 488
628...

output:

241
-1
-1
336
256
256
-1
-1
303
276
-1
257
-1
-1
-1
-1
-1
286
-1
-1
279
-1
272
-1
336
338
333
281
-1
265
305
279
324
-1
-1
265
250
363
-1
313
-1
332
303
-1
409
297
-1
-1
-1
335
-1
-1
307
-1
-1
-1
-1
-1
232
285
223
277
-1
-1
310
300
277
-1
251
351
273
-1
329
308
-1
246
232
-1
-1
-1
304
289
-1
-1
280
...

result:

ok 8890 lines

Test #109:

score: 0
Accepted
time: 11ms
memory: 4952kb

input:

2963 4020
216 1767
2350 1974
782 1605
57 2510
2188 1845
1459 2207
2307 987
761 1677
1487 1139
1615 2249
1843 964
1804 2709
1870 1901
2483 609
951 1096
2409 2751
2057 423
847 128
1745 2210
2006 2293
405 2300
1527 1904
1287 2640
893 263
2075 745
1929 1314
242 830
1909 2523
254 141
1067 2343
11 248
151...

output:

2230
2157
-1
2204
2439
-1
2357
2269
-1
2482
2472
-1
1992
-1
2152
-1
2276
-1
-1
-1
-1
-1
2162
2090
2106
2317
2486
2270
2278
2196
-1
2165
2145
2009
2456
2154
2012
2088
2377
2176
2116
2194
2345
2234
2164
2211
1939
-1
2070
2328
1995
2447
2145
2407
2425
2294
-1
2081
-1
-1
-1
2245
2103
2192
2301
2065
-1
2...

result:

ok 4020 lines

Test #110:

score: 0
Accepted
time: 242ms
memory: 30492kb

input:

83865 75
63077 31694
52534 22484
67740 30638
12751 7085
34412 15590
60345 40396
23425 55980
39928 37018
63324 56546
20966 82245
65482 48907
26803 72689
6285 48798
61426 61161
9062 73420
20025 20288
38914 21800
27663 32628
23385 76461
34938 80671
81595 43932
61491 22253
60651 29160
80798 58822
36378 ...

output:

-1
32592
-1
45030
39405
-1
26778
-1
-1
37731
32462
38987
-1
-1
-1
-1
-1
-1
37358
39503
-1
36088
-1
30784
33287
-1
38847
27352
34467
-1
32825
32330
34483
29837
38719
33649
-1
33693
41631
-1
32854
-1
-1
-1
-1
38314
33736
-1
-1
37305
-1
-1
-1
-1
-1
37047
35434
36857
-1
-1
38189
37865
43902
27632
-1
373...

result:

ok 75 lines

Test #111:

score: 0
Accepted
time: 408ms
memory: 46712kb

input:

111020 174
106323 37407
51413 69009
87955 98397
16781 30513
82009 88237
26968 11205
24089 107687
31875 50157
73281 25443
103883 46074
76073 20969
58580 99018
104379 65773
13822 3964
108779 23939
2863 49912
26492 72223
64153 15062
88121 72790
12104 95494
78493 57207
73373 52358
23322 103518
54304 726...

output:

96263
82669
-1
80522
82574
94066
82781
87983
96123
90720
85757
89153
-1
78255
-1
-1
85453
-1
-1
81274
85602
-1
96871
-1
-1
87004
88128
-1
-1
-1
98003
88291
89190
94349
83503
84016
93927
94813
84377
86531
82280
-1
86968
81828
88748
-1
95981
95908
-1
97549
79661
84618
88879
91090
82150
94083
97257
963...

result:

ok 174 lines

Test #112:

score: 0
Accepted
time: 991ms
memory: 90268kb

input:

227363 37
84764 89851
5208 148714
116642 201829
143108 195797
198945 90378
50688 178345
99488 154509
93907 118276
221792 36085
138153 34615
22578 14821
40565 86222
98493 192466
79194 221821
124818 142523
65540 28367
9445 129527
209555 108919
28848 58480
58349 80170
155236 159698
13381 207208
193266 ...

output:

143796
-1
133699
101077
147880
147066
-1
136968
129897
150136
121287
143586
98452
140467
-1
-1
-1
104131
103302
126895
121253
-1
149748
129261
150169
137202
128265
139415
131683
133179
-1
121892
-1
-1
-1
138751
121064

result:

ok 37 lines

Test #113:

score: 0
Accepted
time: 246ms
memory: 3652kb

input:

20 250000
5 2
11 4
13 20
10 9
14 10
19 15
17 5
11 1
3 4
17 13
15 16
18 19
9 12
18 8
6 18
8 13
3 13
7 17
8 14
17 7 8 14
14 18 2 17
6 8 17 2
14 18 2 17
17 7 14 8
5 2 14 8
6 14 7 2
17 7 14 8
7 5 18 14
7 2 6 14
7 2 14 6
6 18 5 17
6 14 2 7
17 2 8 6
2 5 8 14
2 7 6 14
6 14 2 7
2 17 14 18
7 2 6 14
14 6 2 7
...

output:

3
5
4
5
3
4
-1
3
6
-1
-1
4
-1
4
4
-1
-1
5
-1
-1
4
-1
5
3
-1
3
4
4
5
6
3
6
-1
4
5
5
3
5
6
-1
5
-1
4
-1
4
3
3
-1
-1
-1
4
3
6
4
5
3
-1
5
-1
-1
5
4
6
4
-1
-1
4
4
-1
-1
5
3
3
4
4
-1
5
5
-1
6
3
-1
3
3
3
4
3
5
4
4
3
-1
-1
5
-1
-1
-1
-1
-1
4
4
5
5
6
4
4
-1
3
6
6
-1
4
-1
3
4
4
4
5
4
5
-1
5
-1
6
-1
-1
4
5
-1
...

result:

ok 250000 lines

Test #114:

score: 0
Accepted
time: 214ms
memory: 3924kb

input:

1000 182025
332 505
214 751
786 127
703 69
922 859
32 848
1000 872
677 227
888 149
495 773
872 56
297 599
862 201
799 233
438 278
908 29
160 253
132 524
315 293
817 537
407 257
252 697
495 618
509 785
585 154
925 594
492 907
306 319
115 332
416 102
802 329
627 390
164 141
910 153
716 613
98 443
89 1...

output:

13
15
17
23
17
18
21
24
21
17
23
19
19
21
16
15
17
22
17
17
17
16
23
14
20
26
17
20
18
24
18
18
26
26
16
21
18
20
17
23
20
16
19
23
12
26
20
17
18
15
16
26
18
24
19
15
19
26
14
21
20
21
26
24
16
19
17
17
15
18
16
20
17
18
20
25
18
21
20
17
12
16
24
26
24
17
17
16
19
22
24
20
19
16
26
17
19
21
19
26
...

result:

ok 182025 lines

Test #115:

score: 0
Accepted
time: 288ms
memory: 30744kb

input:

100000 3043
67713 49347
58959 657
50603 77411
6570 85470
6853 58097
55145 35563
77743 62138
40403 8521
97108 80104
97522 64691
84254 5101
13981 99057
18021 88520
21625 7528
37749 94278
49740 37117
62511 43308
83509 94743
24829 26043
16012 57006
42998 85100
44559 15758
5980 10229
36604 39373
78689 48...

output:

477
524
568
646
568
-1
695
511
364
340
1587
702
736
613
573
495
429
564
783
-1
830
527
492
390
379
446
609
46
427
454
475
497
744
623
465
1712
1627
1667
407
706
353
529
548
520
-1
420
491
602
611
662
420
301
1679
785
537
599
516
590
480
487
507
661
496
395
555
570
521
1572
369
-1
440
457
249
567
-1
...

result:

ok 3043 lines

Test #116:

score: 0
Accepted
time: 888ms
memory: 72288kb

input:

250000 745
193662 118160
178943 39524
120686 61847
227162 92959
99102 203112
137715 174029
15188 236563
31367 95883
34349 105217
97344 189382
185976 122041
30627 167344
39188 150432
41442 114866
212277 18413
220251 245117
149721 175168
8469 198071
111132 112597
52276 205530
184410 74674
1830 128612
...

output:

2134
-1
1953
2727
2609
1197
-1
2247
1293
1845
1476
-1
2231
2616
1826
1900
2961
1741
2433
2306
-1
1815
-1
2069
2329
1686
-1
4090
-1
-1
1435
2293
2297
1878
2731
2171
-1
1397
-1
-1
2157
-1
2060
1565
-1
1069
2046
1435
-1
2378
2185
2006
-1
-1
-1
1189
380
2292
-1
1909
-1
1473
2556
986
494
-1
2327
1746
-1
...

result:

ok 745 lines

Test #117:

score: 0
Accepted
time: 839ms
memory: 72164kb

input:

250000 5268
100808 87765
169175 221359
176179 32360
48653 200818
116109 212164
221324 11910
226518 177698
51216 199701
99184 244787
108382 196877
59437 50953
83078 88097
155345 43115
5787 158916
137025 171737
39722 186249
187900 189053
176434 10966
135237 56439
202506 96950
178153 63276
161154 24239...

output:

409
478
527
609
398
235
386
460
207
512
527
243
515
520
388
471
447
367
479
460
520
330
371
367
419
352
519
406
453
470
517
456
529
450
441
400
300
316
363
425
364
423
291
362
306
219
531
355
473
390
434
496
316
501
452
390
446
534
388
519
543
511
611
438
214
420
263
429
533
380
452
436
413
366
350
...

result:

ok 5268 lines

Test #118:

score: 0
Accepted
time: 821ms
memory: 72308kb

input:

250000 8170
125134 36932
246295 244730
170402 31385
181704 224810
156456 5338
194745 118582
117628 29072
43366 28260
182413 131653
30362 188508
68291 124835
107285 43125
218544 64520
105082 124408
77161 8556
245991 189166
107247 65150
90875 185243
91198 162068
188025 60928
124221 20744
149229 79703
...

output:

479
335
311
295
591
325
237
264
323
387
406
472
406
292
350
607
528
306
254
479
344
461
330
415
329
356
578
330
413
303
594
535
419
368
359
457
338
632
314
345
352
379
426
336
510
418
266
600
257
319
351
402
451
368
561
548
600
479
352
370
367
326
571
547
320
312
346
388
343
346
425
402
388
307
462
...

result:

ok 8170 lines

Test #119:

score: 0
Accepted
time: 843ms
memory: 72912kb

input:

250000 20325
33047 170873
4730 80739
172077 37764
137360 102517
219224 242094
98635 44267
116143 3155
53073 226068
21231 220501
168036 17280
35576 7633
45705 147816
129857 181296
236129 31121
130681 172482
68226 139483
65021 89646
161644 7891
235480 81628
154223 34305
56081 47583
108139 145370
92738...

output:

235
260
236
296
212
238
253
191
193
210
204
208
248
224
218
194
201
237
202
223
199
177
214
211
275
201
202
199
202
164
274
255
217
257
222
221
207
220
246
246
187
231
257
209
202
178
193
265
229
211
177
227
254
198
250
228
244
205
295
173
160
209
226
168
223
164
185
212
219
244
292
239
257
294
190
...

result:

ok 20325 lines

Test #120:

score: 0
Accepted
time: 1007ms
memory: 72968kb

input:

250000 153657
176438 146846
217298 224475
193996 76779
203238 181511
5565 51401
104178 218201
166028 160664
24978 179018
212123 156169
61531 115275
216764 52141
123536 194701
148240 144247
103403 196445
57722 156690
164626 8925
60236 38868
219978 157925
166577 188639
225119 218144
237547 194509
1794...

output:

180
184
177
183
181
183
185
181
179
179
185
180
188
176
181
182
176
181
178
174
181
178
181
181
183
185
179
178
183
179
186
173
180
181
179
182
187
181
174
180
187
180
181
181
180
180
181
177
180
179
183
183
181
187
182
177
177
184
181
180
177
176
183
185
183
180
181
179
179
184
181
181
183
181
182
...

result:

ok 153657 lines

Test #121:

score: 0
Accepted
time: 316ms
memory: 35628kb

input:

100000 96
2579 13295
30190 62175
57878 56950
86737 51487
36344 3231
72330 28269
68072 98449
65616 26998
81784 22913
33819 69932
85255 94719
6800 39197
11329 80820
57160 29122
85837 84053
89575 88679
76490 88090
59289 33926
63579 15842
35659 94401
54757 69457
54427 43819
43049 5076
55260 69353
54194 ...

output:

20429
17243
15960
-1
21705
-1
8652
-1
8827
-1
-1
23909
20282
10890
-1
13879
12582
-1
13699
-1
23421
-1
6634
22983
23569
22585
12109
9885
-1
-1
-1
-1
22449
-1
-1
25758
20044
12591
8354
13639
18806
-1
-1
10585
26535
7531
28123
-1
-1
11972
15876
16270
-1
-1
-1
-1
15869
-1
-1
6544
22801
-1
11691
-1
-1
-...

result:

ok 96 lines

Test #122:

score: 0
Accepted
time: 975ms
memory: 74576kb

input:

250000 114
34975 19235
246481 71496
82304 177457
52729 156034
108901 76780
220190 145366
171702 6200
177944 112161
146840 225501
105769 9561
202044 204961
118941 185854
56359 155815
206225 193441
167328 120079
37366 240191
29700 122662
243200 186183
175441 120502
135917 6118
4344 129885
235142 60098...

output:

15468
14992
23984
5706
8597
14573
21380
-1
30579
10883
27769
6269
13091
15616
10937
-1
9771
-1
16551
7325
15648
14403
15618
17690
14528
-1
31417
18627
16357
13009
20249
20344
14896
18153
30934
18482
11245
19111
16465
19479
12923
17543
27928
14592
10066
-1
7197
16091
2317
13941
15350
-1
14808
16468
1...

result:

ok 114 lines

Test #123:

score: 0
Accepted
time: 1034ms
memory: 88044kb

input:

250000 38
219018 49559
76903 98446
154394 84177
34951 57948
238876 133278
159178 73328
143885 9985
186847 70669
149709 214145
113419 57679
96602 106544
128322 64194
189628 206067
244126 100951
141272 93418
211009 203566
140407 180017
236291 82752
4685 168648
76709 9398
193300 61771
155994 42765
1001...

output:

93330
17549
88046
10066
14872
81762
-1
80247
44940
-1
-1
-1
31263
-1
-1
-1
-1
36447
82942
31734
76016
68847
71858
69125
18550
87707
49439
-1
44030
48794
72312
51876
-1
63990
53630
40031
48568
-1

result:

ok 38 lines

Test #124:

score: 0
Accepted
time: 1021ms
memory: 77556kb

input:

250000 59
106727 205400
105562 43825
11448 58253
238121 151963
208422 141493
12353 88829
123068 92173
120687 162281
21481 9290
100628 37455
207205 46270
109641 154944
198200 85687
50144 215749
166894 122089
124349 114420
60036 106630
162537 120541
171852 247301
70900 85744
2191 109532
61122 171502
1...

output:

49001
52241
20593
60160
24720
28512
6704
-1
13976
-1
51451
10265
16444
60481
23121
31272
16681
61982
27126
59948
20173
31948
7414
-1
14117
15497
62213
44811
53925
51304
22028
-1
-1
28700
45842
24504
-1
60503
15185
21782
22698
15628
38725
17016
61481
63409
53414
41312
21978
16072
12177
61301
-1
17375...

result:

ok 59 lines

Test #125:

score: 0
Accepted
time: 1059ms
memory: 89988kb

input:

250000 31
113345 128405
113148 133765
91898 34902
133211 213755
126115 206979
191825 138411
244985 178589
21519 58164
187760 51682
43535 195616
48758 195618
166211 47229
155679 89782
97729 205080
65491 33247
29330 97638
125326 141633
179109 218315
215915 141305
138115 125757
191376 136030
245543 160...

output:

51906
-1
62947
54747
-1
47997
41305
66263
63552
54756
-1
77544
-1
74677
31720
31657
79654
37500
67324
88735
-1
69560
53211
60903
21217
85289
78498
53168
48636
-1
79286

result:

ok 31 lines

Test #126:

score: 0
Accepted
time: 1161ms
memory: 99760kb

input:

250000 28
70491 96071
174559 77979
71973 42932
231188 248805
102818 243347
19498 223533
54319 241329
36545 147300
157666 87332
220827 206678
209760 60566
97008 14392
104914 154786
159218 136075
215543 176924
133700 140362
228063 186218
1683 22776
158966 70602
77484 202719
49100 116977
76290 144654
9...

output:

143651
70045
76059
102372
67007
69283
29617
50728
94460
69528
64781
-1
95001
-1
-1
71328
75153
79478
40190
96753
80371
97283
90437
71080
-1
81281
35661
19131

result:

ok 28 lines

Test #127:

score: 0
Accepted
time: 1064ms
memory: 88696kb

input:

250000 34
22649 58157
140906 230455
157363 126086
200670 63589
132441 83496
229818 103881
198311 200629
137726 32145
20049 172564
48624 130341
183115 134779
170219 190739
140174 104408
134740 143595
211888 197786
203587 230092
133854 165024
80651 25028
196085 80535
116318 89085
243898 146039
17074 9...

output:

69476
52228
40145
-1
-1
68827
68608
51276
52706
64610
69939
34390
17550
72991
3266
73070
66464
57610
45801
71528
-1
32015
49128
58223
68231
35166
58752
10374
66739
56768
70057
13951
53467
65104

result:

ok 34 lines

Test #128:

score: 0
Accepted
time: 1026ms
memory: 83908kb

input:

250000 48
247379 109956
187445 186914
194005 214454
208890 128680
148502 8822
127973 86110
63546 228462
196713 9017
8549 91340
129077 211530
69254 79495
83819 161845
231140 148232
223454 99083
120657 125020
162776 32775
25774 110696
184351 131127
179486 21036
230870 53765
7945 22292
97487 204981
209...

output:

42802
29147
-1
67882
-1
15013
12661
37637
34941
24989
18331
31857
61178
41252
32540
-1
37251
73919
-1
24012
18140
-1
17036
-1
4348
-1
-1
21504
-1
14602
55379
21893
10534
-1
57859
-1
14055
34618
34438
37133
27711
28242
29790
35769
37649
16579
27747
-1

result:

ok 48 lines

Test #129:

score: 0
Accepted
time: 1007ms
memory: 85788kb

input:

250000 30
679 83150
122996 225437
87710 232657
177633 135833
163124 157323
15913 93601
21212 75300
101639 103540
42831 111274
96594 157620
24718 140510
235007 5176
239404 79436
134715 187761
136526 23954
91545 28176
173889 124643
187779 135974
214746 89375
52506 147536
149231 34538
63903 228598
1373...

output:

29179
61553
73012
67690
77350
88391
-1
37545
111048
-1
-1
63528
124615
47584
52167
76270
60241
61162
92672
-1
-1
-1
-1
49326
-1
107532
92547
69665
74671
51499

result:

ok 30 lines

Test #130:

score: 0
Accepted
time: 1055ms
memory: 87936kb

input:

250000 26
147214 171918
185939 56331
249694 222861
7756 176401
169540 31104
207488 18317
212729 121993
665 5497
231435 229173
23482 88953
116938 232753
101061 147315
75253 234423
143960 87692
49700 20246
35048 24129
63278 95768
149340 71425
179783 139270
25565 239330
7149 86280
67838 176292
74928 22...

output:

29340
81048
-1
-1
-1
72842
-1
90657
68861
29359
79312
97610
-1
88827
95965
67999
71849
95786
108194
57359
74702
34948
49036
50376
-1
11005

result:

ok 26 lines

Test #131:

score: 0
Accepted
time: 1057ms
memory: 92976kb

input:

250000 32
200447 180657
141680 168505
193790 248041
23656 111489
204401 17771
222999 245928
123659 96096
68516 85247
216412 586
16503 60107
227176 208297
37961 204200
43041 29267
143407 161465
207203 166198
200044 56609
18530 199558
111424 123932
237888 107788
185843 20027
87474 53133
5833 164553
43...

output:

90265
51561
108827
72629
56052
-1
51351
85885
98168
10740
46050
50092
-1
-1
-1
-1
-1
66382
90876
59955
111922
-1
92397
46621
53041
39713
-1
94696
-1
128289
42929
16589

result:

ok 32 lines

Test #132:

score: 0
Accepted
time: 0ms
memory: 3996kb

input:

224 1000
24 187
9 166
101 212
13 54
202 45
115 54
50 136
40 91
187 43
84 224
210 142
41 126
59 198
197 8
2 213
168 26
13 59
179 8
55 167
30 71
106 19
194 141
137 125
93 177
194 136
19 4
168 79
175 12
197 220
136 189
19 40
206 50
204 74
204 135
5 198
142 2
13 79
9 102
17 166
19 167
74 35
186 118
61 1...

output:

-1
-1
-1
-1
22
-1
-1
28
18
-1
22
26
-1
-1
25
-1
-1
-1
-1
16
-1
-1
21
-1
9
-1
5
26
-1
11
-1
-1
20
-1
21
17
8
30
19
12
17
-1
10
-1
20
19
-1
15
-1
-1
15
6
-1
7
35
15
11
-1
-1
19
-1
-1
5
-1
-1
-1
-1
-1
-1
-1
6
-1
-1
17
-1
-1
15
16
17
-1
-1
11
-1
-1
25
-1
-1
8
-1
10
21
20
11
-1
-1
-1
23
-1
21
21
-1
-1
12...

result:

ok 1000 lines

Test #133:

score: 0
Accepted
time: 5ms
memory: 3720kb

input:

253 1000
9 242
79 154
89 21
125 230
248 39
223 177
239 238
226 152
85 215
212 66
242 22
242 161
49 37
112 148
144 64
248 138
83 27
56 57
38 162
63 208
144 46
248 73
240 27
113 59
24 78
249 95
214 228
117 140
57 234
72 123
160 144
85 100
150 176
133 205
130 54
213 252
164 229
82 133
231 96
248 211
1 ...

output:

11
12
4
11
15
17
7
22
14
-1
-1
-1
-1
18
1
34
11
18
21
-1
23
-1
-1
-1
-1
8
-1
21
-1
22
-1
-1
-1
22
-1
29
26
-1
12
24
-1
-1
-1
14
-1
-1
-1
-1
9
-1
15
-1
39
16
6
13
-1
19
26
13
-1
28
32
34
23
-1
21
-1
14
6
26
-1
-1
14
-1
34
16
-1
24
-1
-1
-1
30
31
-1
-1
11
-1
-1
-1
13
-1
10
18
12
21
26
-1
-1
4
10
19
11...

result:

ok 1000 lines

Test #134:

score: 0
Accepted
time: 0ms
memory: 4040kb

input:

589 1000
505 559
524 153
40 246
131 336
174 534
572 29
124 204
495 69
218 9
565 579
204 4
448 92
244 481
584 28
529 412
317 257
398 407
249 104
120 133
572 24
569 353
395 513
225 339
376 176
69 128
269 377
493 181
216 437
519 312
371 544
583 556
73 3
267 26
104 473
228 587
73 300
176 534
124 102
429...

output:

36
-1
47
-1
-1
-1
-1
-1
-1
-1
-1
19
31
-1
-1
-1
-1
28
25
-1
-1
27
39
-1
-1
13
43
43
-1
-1
-1
-1
35
-1
-1
-1
-1
56
-1
-1
-1
-1
25
-1
-1
-1
-1
-1
4
31
-1
-1
30
-1
21
40
-1
-1
39
-1
-1
-1
-1
28
24
-1
-1
-1
-1
-1
-1
-1
-1
-1
21
-1
-1
24
-1
-1
23
17
-1
25
32
25
-1
25
-1
-1
-1
-1
-1
-1
33
46
-1
37
46
16
-...

result:

ok 1000 lines

Test #135:

score: 0
Accepted
time: 0ms
memory: 3972kb

input:

969 1000
385 84
562 756
602 76
314 257
18 550
265 169
344 106
653 233
809 772
717 25
457 967
653 177
414 519
256 389
952 954
261 458
705 313
153 393
699 964
229 416
53 921
670 224
234 177
678 893
341 742
381 139
726 93
57 715
160 730
56 701
670 318
904 26
212 708
87 437
59 430
547 66
789 412
272 443...

output:

-1
-1
26
34
-1
29
13
-1
-1
-1
27
35
57
-1
-1
-1
-1
25
28
22
-1
-1
26
-1
-1
-1
-1
-1
-1
-1
-1
14
12
36
43
32
-1
-1
-1
-1
-1
-1
-1
33
36
-1
23
-1
36
13
29
-1
-1
-1
39
-1
23
-1
-1
-1
15
41
-1
26
-1
-1
-1
-1
-1
-1
45
-1
36
-1
-1
36
-1
-1
-1
12
-1
-1
57
-1
-1
-1
39
-1
34
23
32
13
49
-1
30
20
32
-1
-1
-1
...

result:

ok 1000 lines

Test #136:

score: 0
Accepted
time: 3ms
memory: 3920kb

input:

927 1000
649 888
883 489
406 374
442 398
600 796
132 475
121 886
507 57
795 827
127 623
345 385
102 125
69 567
616 581
74 385
872 270
211 31
116 633
625 320
542 536
849 565
451 582
803 662
23 924
226 443
536 792
503 97
543 450
64 21
289 660
588 841
875 252
71 503
20 248
817 215
625 352
238 119
865 1...

output:

-1
13
81
-1
-1
-1
-1
-1
49
-1
-1
23
-1
24
42
34
-1
-1
-1
-1
-1
-1
-1
26
-1
33
-1
-1
-1
21
-1
-1
-1
36
-1
4
-1
27
-1
-1
-1
-1
20
-1
-1
55
-1
-1
18
-1
12
51
52
7
-1
46
-1
-1
-1
-1
-1
-1
-1
-1
19
-1
-1
-1
41
-1
-1
-1
45
-1
-1
-1
-1
28
-1
-1
-1
-1
-1
22
46
-1
35
37
-1
22
-1
23
-1
-1
-1
62
-1
-1
-1
-1
-1...

result:

ok 1000 lines

Test #137:

score: 0
Accepted
time: 0ms
memory: 3960kb

input:

900 1000
679 252
16 294
536 543
284 555
604 219
439 257
577 877
200 134
701 94
648 529
74 473
724 434
413 663
128 459
680 865
454 436
470 16
399 685
109 90
10 316
131 637
107 418
62 711
591 443
313 121
826 176
723 365
37 231
740 726
339 493
79 785
828 95
461 558
283 573
188 167
276 598
335 877
773 5...

output:

-1
30
-1
-1
-1
27
-1
34
-1
-1
29
-1
-1
-1
24
-1
-1
20
-1
-1
21
27
-1
-1
-1
20
-1
-1
-1
20
39
-1
-1
43
-1
36
43
-1
17
-1
45
-1
-1
-1
-1
-1
-1
13
31
-1
27
15
40
-1
-1
24
25
-1
16
-1
-1
-1
-1
-1
22
-1
-1
-1
-1
-1
-1
12
-1
23
-1
-1
-1
34
39
-1
28
-1
-1
-1
28
24
-1
-1
-1
39
-1
-1
-1
-1
16
-1
23
-1
-1
9
2...

result:

ok 1000 lines

Test #138:

score: 0
Accepted
time: 3ms
memory: 3964kb

input:

950 1000
386 766
574 262
585 820
580 759
367 343
267 628
505 344
28 84
335 289
652 497
567 208
282 161
81 321
748 653
634 105
145 345
22 599
365 773
423 445
263 640
64 239
101 920
322 49
460 379
491 61
537 843
194 695
590 65
162 563
30 839
4 658
322 254
147 371
830 323
847 636
193 908
292 736
168 76...

output:

-1
-1
-1
-1
-1
-1
-1
-1
52
-1
-1
-1
29
21
-1
-1
-1
45
-1
25
-1
-1
-1
29
37
26
-1
-1
-1
-1
-1
-1
-1
19
37
-1
27
-1
-1
-1
-1
-1
-1
39
-1
23
-1
18
-1
-1
63
-1
24
-1
48
35
45
-1
-1
-1
-1
22
24
-1
-1
33
-1
-1
50
-1
30
-1
47
-1
-1
-1
-1
20
35
45
-1
-1
-1
-1
52
24
-1
-1
47
-1
-1
-1
-1
4
-1
-1
-1
29
-1
-1
-...

result:

ok 1000 lines

Test #139:

score: 0
Accepted
time: 3ms
memory: 4136kb

input:

922 1000
557 107
804 596
529 905
502 393
247 129
758 323
643 367
198 658
462 887
211 560
240 867
108 423
456 169
79 227
357 827
599 790
438 182
85 398
891 639
539 496
287 488
586 922
621 421
107 561
730 259
184 911
50 265
662 265
4 355
457 790
914 629
572 250
787 877
655 849
772 178
24 34
445 678
29...

output:

24
34
-1
28
44
37
47
-1
35
50
-1
-1
-1
-1
28
-1
-1
16
-1
-1
-1
-1
-1
13
-1
-1
-1
-1
45
24
-1
13
-1
-1
22
65
-1
32
-1
-1
53
49
-1
-1
22
-1
-1
-1
-1
55
-1
-1
-1
16
17
24
26
-1
-1
-1
-1
-1
54
-1
-1
-1
30
-1
-1
-1
-1
-1
-1
-1
40
-1
-1
43
43
-1
-1
-1
39
-1
-1
22
13
-1
57
-1
35
-1
-1
39
-1
-1
-1
-1
41
-1
...

result:

ok 1000 lines

Test #140:

score: 0
Accepted
time: 3ms
memory: 4092kb

input:

1000 1000
308 537
957 406
639 400
973 174
738 270
888 621
429 438
473 295
818 923
971 73
755 13
2 595
544 173
555 339
445 949
481 978
828 137
68 534
241 515
637 411
73 753
598 640
587 138
800 10
654 62
875 336
925 230
460 191
157 153
484 893
915 225
962 301
174 355
736 488
559 869
140 865
289 520
37...

output:

443
481
471
475
489
495
497
462
443
507
450
493
441
515
495
501
473
479
417
528
495
427
474
529
453
432
432
490
494
502
448
467
467
446
495
458
437
481
500
474
479
436
420
475
408
478
443
458
490
497
439
446
448
459
436
415
467
434
467
483
489
498
485
500
483
496
474
457
474
481
499
542
494
480
488
...

result:

ok 1000 lines

Test #141:

score: 0
Accepted
time: 2ms
memory: 4040kb

input:

1000 1000
946 877
412 299
493 165
968 864
960 111
522 513
502 355
996 976
868 371
550 362
580 297
710 730
489 476
296 492
702 202
902 134
591 598
253 943
922 581
373 922
640 710
399 626
259 698
820 359
933 722
357 645
409 879
888 488
779 795
532 934
767 773
101 689
607 927
20 377
378 506
286 794
692...

output:

497
468
506
486
481
422
411
535
469
441
493
450
401
521
472
493
500
463
445
442
487
535
496
490
511
509
495
426
500
496
499
459
558
486
460
406
493
480
579
505
506
476
491
477
443
471
439
453
486
518
488
478
452
425
459
423
517
446
530
495
485
446
493
416
492
498
482
460
477
497
461
499
468
423
565
...

result:

ok 1000 lines

Test #142:

score: 0
Accepted
time: 2ms
memory: 3668kb

input:

102 1000
4 26
19 101
27 55
20 35
95 28
79 5
81 85
63 76
68 33
49 46
75 93
45 38
8 47
17 22
38 6
42 88
84 59
52 70
5 37
66 16
21 36
1 75
35 15
54 77
9 27
73 90
13 7
80 31
41 95
62 74
36 81
69 29
10 17
90 44
26 13
61 57
12 82
92 63
83 45
47 51
40 48
6 51
46 34
65 2
44 53
18 89
22 79
94 83
43 96
57 65
...

output:

49
-1
37
-1
-1
52
53
-1
41
-1
-1
49
-1
44
40
-1
-1
42
-1
36
-1
54
51
-1
42
-1
51
50
33
36
45
-1
-1
-1
-1
-1
29
40
44
37
-1
43
-1
-1
54
-1
-1
42
45
38
-1
-1
-1
-1
49
-1
52
41
48
51
50
-1
-1
40
31
-1
47
30
-1
-1
40
54
34
41
43
40
-1
-1
-1
-1
40
39
-1
-1
55
36
-1
52
-1
40
54
47
-1
-1
-1
-1
-1
46
32
50
...

result:

ok 1000 lines

Test #143:

score: 0
Accepted
time: 3ms
memory: 3832kb

input:

475 1000
296 361
9 435
396 254
283 141
450 165
366 124
89 408
93 197
24 461
51 211
150 463
237 247
279 127
37 227
266 475
365 181
80 23
238 217
453 360
221 43
440 293
102 308
126 437
361 37
127 107
378 364
236 46
315 113
60 146
48 271
87 154
333 291
321 81
17 281
304 209
50 164
314 334
222 119
323 1...

output:

-1
383
326
359
-1
295
-1
351
376
378
325
299
328
-1
-1
-1
-1
300
378
289
303
342
376
351
344
378
326
293
400
380
360
-1
-1
326
381
377
395
306
305
387
334
349
320
350
350
392
-1
340
317
365
-1
-1
305
332
348
-1
-1
338
339
292
409
-1
325
377
342
353
329
308
349
304
-1
-1
330
323
313
346
363
319
325
2...

result:

ok 1000 lines

Test #144:

score: 0
Accepted
time: 3ms
memory: 3952kb

input:

695 1000
644 507
647 668
529 182
261 86
537 508
324 142
499 441
295 71
82 468
336 514
663 472
240 399
350 294
258 214
538 45
303 216
614 386
597 53
30 12
681 490
195 437
123 271
532 598
458 280
342 313
409 137
150 684
6 304
301 464
174 518
31 328
394 266
186 62
507 95
607 483
474 258
389 416
313 376...

output:

538
-1
505
435
471
489
-1
-1
522
515
536
488
493
-1
425
455
437
459
391
521
513
516
470
509
415
512
495
506
420
503
454
512
-1
497
485
492
469
500
515
512
473
447
531
456
452
399
469
455
518
407
424
490
577
503
456
497
531
445
463
469
503
-1
459
454
425
506
491
444
467
392
495
408
522
526
-1
491
459...

result:

ok 1000 lines

Test #145:

score: 0
Accepted
time: 4ms
memory: 4256kb

input:

950 1000
803 701
333 85
587 271
766 366
443 440
521 922
512 395
385 247
493 611
553 339
114 757
65 690
83 520
444 831
439 792
695 596
79 619
784 335
343 499
119 116
573 280
847 437
648 873
232 923
323 836
431 812
624 248
51 542
740 99
145 642
282 70
169 364
783 822
502 58
688 571
175 888
378 117
14 ...

output:

653
628
684
666
634
683
667
612
703
692
601
664
713
676
716
671
668
781
693
594
688
648
560
749
639
712
640
656
682
663
590
-1
667
733
637
721
749
586
650
670
642
634
669
648
673
632
574
591
756
670
723
-1
652
666
671
638
653
699
640
-1
674
644
655
646
-1
673
651
593
580
711
660
603
642
685
657
707
...

result:

ok 1000 lines

Test #146:

score: 0
Accepted
time: 0ms
memory: 4056kb

input:

957 1000
908 440
716 11
934 317
381 132
193 867
259 563
375 309
635 677
781 538
946 388
897 13
351 646
135 114
806 691
453 241
342 707
361 931
554 906
156 955
327 376
223 255
912 576
175 605
48 146
836 187
333 419
307 692
237 80
284 553
2 130
87 504
760 128
922 276
77 770
513 34
39 196
755 165
691 1...

output:

581
512
595
-1
561
-1
681
632
-1
543
657
600
627
615
558
523
-1
677
587
446
532
535
564
526
657
618
489
455
646
621
699
545
579
600
572
491
569
548
527
575
549
616
636
552
565
486
537
640
598
663
512
701
633
613
586
-1
600
553
478
579
498
575
591
660
582
543
610
598
-1
-1
675
485
608
586
476
613
561...

result:

ok 1000 lines

Test #147:

score: 0
Accepted
time: 3ms
memory: 3920kb

input:

1000 1000
769 836
963 259
461 817
837 11
314 880
103 515
25 31
37 628
490 7
960 763
679 227
847 802
512 262
605 796
305 954
600 448
687 858
507 778
351 319
822 501
513 358
183 548
781 827
338 972
529 787
935 922
122 223
839 815
336 65
297 124
748 860
460 193
871 837
740 880
717 509
386 133
985 291
4...

output:

44
44
44
41
44
41
44
44
41
44
44
44
41
44
44
41
41
41
44
44
41
44
41
44
44
44
41
44
41
44
44
41
44
44
44
41
41
44
41
41
41
41
44
41
44
41
41
44
44
44
41
41
41
41
44
44
44
44
44
44
44
41
44
41
41
41
41
44
44
41
44
41
41
44
41
44
41
41
41
41
41
44
41
41
41
41
44
41
44
44
44
44
41
41
44
41
44
41
41
41
...

result:

ok 1000 lines

Test #148:

score: 0
Accepted
time: 3ms
memory: 3928kb

input:

1000 1000
402 741
579 526
55 562
701 761
688 513
171 487
98 905
112 786
282 939
396 26
139 276
195 249
242 677
898 67
388 81
634 571
666 101
54 540
1000 474
787 836
734 826
485 14
663 25
449 330
581 465
666 413
292 718
746 37
872 157
96 498
280 514
478 60
449 945
546 497
155 171
352 274
140 625
452 ...

output:

37
40
39
40
35
36
36
38
46
46
42
47
46
37
38
37
38
36
49
43
50
38
37
35
43
34
35
36
36
37
52
38
41
37
34
44
39
37
31
37
43
47
38
38
52
37
36
36
52
49
40
37
37
52
41
36
34
38
52
48
40
36
40
43
34
37
34
33
45
44
37
52
39
50
37
36
37
37
36
43
45
49
34
45
46
36
45
49
36
37
41
52
34
52
37
37
49
43
46
44
...

result:

ok 1000 lines

Test #149:

score: 0
Accepted
time: 3ms
memory: 3924kb

input:

1000 1000
839 809
973 559
201 307
455 803
121 564
105 71
958 767
853 675
49 889
268 155
976 761
515 200
937 80
370 609
737 94
648 378
128 784
814 464
440 727
1 719
597 283
657 216
118 722
671 315
714 28
541 737
304 412
136 131
536 402
547 26
278 995
467 893
870 192
662 313
369 903
701 443
461 780
86...

output:

28
49
92
62
47
12
25
-1
-1
52
53
31
51
25
46
48
40
41
-1
56
-1
43
-1
42
-1
91
34
58
37
45
84
-1
38
-1
22
-1
41
-1
50
88
47
53
-1
41
13
19
48
46
47
44
44
51
96
41
17
62
-1
79
35
20
88
-1
-1
35
-1
41
51
65
29
-1
38
-1
32
58
30
48
32
31
81
50
54
60
55
56
53
19
32
-1
-1
59
90
54
44
29
39
85
17
42
75
-1
...

result:

ok 1000 lines

Test #150:

score: 0
Accepted
time: 3ms
memory: 3928kb

input:

1000 1000
359 951
844 268
845 568
940 823
717 561
633 41
241 872
775 804
59 4
587 993
874 595
814 238
562 654
409 998
669 594
247 315
494 784
393 543
49 97
518 607
858 33
751 669
221 845
703 783
770 978
330 719
161 853
464 529
348 777
231 361
509 590
985 625
227 245
616 370
415 189
656 605
76 575
37...

output:

63
-1
77
-1
136
92
55
-1
105
-1
117
80
-1
-1
100
-1
73
131
120
-1
92
-1
33
45
57
-1
-1
87
-1
133
101
101
-1
46
-1
84
125
29
98
106
133
-1
83
99
71
139
104
-1
109
-1
68
-1
83
68
-1
49
-1
74
109
-1
-1
35
30
60
111
88
20
48
110
77
-1
89
-1
-1
-1
-1
-1
54
-1
87
110
-1
-1
101
51
29
78
57
-1
-1
49
78
80
-...

result:

ok 1000 lines

Test #151:

score: 0
Accepted
time: 0ms
memory: 3944kb

input:

1000 1000
25 1
192 980
872 758
551 388
455 709
869 644
427 657
741 477
969 381
656 823
559 777
635 761
137 560
53 38
946 814
709 972
387 687
601 238
971 480
877 879
761 592
374 833
638 357
549 70
11 837
967 121
569 545
95 204
230 508
311 675
236 451
684 85
148 64
605 580
630 860
204 894
864 933
78 2...

output:

163
192
83
133
129
-1
-1
40
-1
69
83
124
115
128
49
-1
177
-1
24
89
116
98
164
118
187
86
89
147
93
90
-1
59
123
91
128
80
100
115
71
93
102
119
-1
95
139
118
42
90
108
74
-1
108
125
131
128
172
126
102
102
103
106
-1
112
85
83
91
77
125
106
50
105
126
96
85
126
61
-1
134
95
-1
-1
71
-1
76
-1
69
-1
...

result:

ok 1000 lines

Test #152:

score: 0
Accepted
time: 3ms
memory: 4180kb

input:

1000 1000
415 364
163 63
836 53
419 302
376 771
984 543
747 487
955 566
191 858
340 338
725 276
576 533
912 402
216 886
874 427
907 504
677 988
360 665
472 559
766 257
956 675
83 294
582 970
347 919
288 217
108 124
778 176
821 850
890 20
660 5
226 359
247 966
25 382
412 340
849 695
476 293
149 270
5...

output:

124
107
150
86
-1
132
-1
-1
126
96
100
72
45
68
97
81
128
107
116
124
111
-1
131
107
92
115
-1
117
114
134
111
115
-1
-1
105
102
-1
149
107
129
-1
78
95
85
129
43
170
119
110
-1
81
102
129
101
94
86
-1
125
111
-1
118
106
149
96
-1
-1
116
112
-1
55
129
146
-1
52
-1
133
55
112
134
99
105
107
116
112
1...

result:

ok 1000 lines

Test #153:

score: 0
Accepted
time: 5ms
memory: 4004kb

input:

1000 1000
567 641
255 982
47 613
682 342
386 353
533 227
894 385
522 576
835 452
458 211
241 749
984 30
700 6
808 981
58 306
479 763
238 970
641 104
177 314
710 624
291 257
399 404
211 77
791 299
908 783
922 58
323 464
351 914
401 138
277 207
816 214
923 168
874 413
119 741
777 747
283 628
807 258
2...

output:

279
-1
212
238
-1
-1
-1
373
-1
-1
310
545
350
143
481
-1
275
288
-1
-1
-1
-1
362
-1
310
-1
216
228
381
150
-1
-1
-1
-1
296
-1
382
-1
418
331
-1
359
315
-1
-1
-1
323
-1
265
-1
-1
183
-1
455
366
387
221
346
228
-1
-1
199
361
432
403
275
322
252
249
331
403
186
304
186
402
553
-1
478
320
519
163
176
-1...

result:

ok 1000 lines

Test #154:

score: 0
Accepted
time: 4ms
memory: 4036kb

input:

1000 1000
574 559
534 146
223 96
341 816
328 202
87 441
318 176
995 402
675 458
237 383
372 765
567 756
245 370
622 44
504 440
9 14
424 835
224 653
17 567
156 505
577 572
470 562
657 691
546 296
357 200
580 848
757 459
667 837
303 163
950 415
817 658
127 319
744 301
272 640
472 809
583 112
619 589
7...

output:

-1
324
187
131
314
230
336
550
534
40
188
291
243
-1
331
453
281
289
252
324
480
161
-1
-1
-1
91
293
-1
372
317
-1
280
241
427
201
315
346
298
187
310
241
366
350
116
420
218
39
362
501
373
99
-1
360
407
97
244
332
282
329
237
333
312
406
335
190
-1
284
312
312
191
-1
297
136
135
334
303
251
413
357...

result:

ok 1000 lines

Test #155:

score: 0
Accepted
time: 4ms
memory: 3996kb

input:

1000 1000
123 727
571 24
691 161
675 617
335 517
317 674
945 350
568 776
385 364
96 334
711 929
708 411
820 169
590 610
908 598
19 12
928 787
704 202
9 697
391 725
320 286
257 346
451 993
960 856
229 52
810 734
988 604
2 736
952 696
991 263
659 828
452 67
915 437
529 885
550 239
919 799
458 705
330 ...

output:

193
219
236
237
127
241
203
187
318
187
104
-1
270
261
217
203
174
210
296
172
223
288
-1
-1
223
341
98
291
248
182
303
254
282
197
-1
190
-1
195
292
155
235
324
231
300
275
307
188
271
189
246
326
-1
224
226
262
298
319
268
234
232
117
-1
-1
-1
259
273
-1
108
186
167
172
304
147
-1
243
106
-1
229
2...

result:

ok 1000 lines

Test #156:

score: 0
Accepted
time: 4ms
memory: 4092kb

input:

1000 1000
653 964
81 83
6 939
787 405
235 961
734 230
77 971
87 628
864 713
295 999
558 760
222 66
362 54
989 410
126 137
197 238
151 397
868 937
489 332
796 610
753 535
404 883
265 345
400 524
158 667
30 110
612 921
201 98
359 709
227 797
794 44
977 683
79 416
790 647
48 126
276 706
926 588
607 894...

output:

-1
290
252
263
257
288
222
198
273
162
283
215
-1
375
-1
158
335
300
354
-1
-1
424
309
-1
244
-1
215
323
237
247
47
233
60
-1
356
268
365
349
93
-1
395
220
321
262
90
-1
193
203
-1
44
356
255
104
246
285
282
267
-1
389
95
-1
-1
376
332
-1
396
-1
314
-1
323
-1
315
-1
357
310
282
290
-1
307
224
191
-1...

result:

ok 1000 lines

Test #157:

score: 0
Accepted
time: 841ms
memory: 71460kb

input:

249000 2116
155014 3273
43160 222508
153235 83854
50903 8731
221987 35138
216933 189191
42916 239524
126884 154150
155506 23631
142357 195273
198575 152669
221897 139959
152540 133113
84971 181049
194908 196428
150472 94391
187861 243022
209472 108471
28499 45290
131296 110256
221141 202911
210789 2...

output:

3411
3329
16555
10804
10804
35450
5313
4523
4707
9209
4375
27577
9207
35448
3486
5791
2863
3605
8024
248025
4221
4892
4363
8575
11826
248025
6079
11835
2562
2510
5787
3497
2500
5537
2682
6395
4879
13073
19099
3937
49622
2979
16554
3150
2986
248025
4375
4229
3331
2802
3728
3841
2521
16555
16556
13073...

result:

ok 2116 lines

Test #158:

score: 0
Accepted
time: 834ms
memory: 71520kb

input:

249500 2114
122974 95787
78140 201686
45405 120965
156024 146147
90515 131094
21270 200557
136123 218818
160027 138583
61930 119651
59992 248997
171356 181792
76957 143334
190892 200092
30377 8067
57049 219817
14574 208590
201775 28618
228761 37003
12906 170673
147131 188133
106762 88049
164676 2227...

output:

4081
49623
2568
7116
10801
3008
8024
6077
3082
4705
3324
9949
35452
3167
5069
2994
3085
2467
2676
5079
5078
13080
4086
10804
4886
2454
248026
2510
3417
3239
82690
2687
3949
2989
4529
3249
2982
7533
5793
13072
3001
3951
6065
2457
3511
2624
3510
3832
35450
3616
7110
2790
4085
2808
4533
3253
3713
2692
...

result:

ok 2114 lines

Test #159:

score: 0
Accepted
time: 849ms
memory: 71624kb

input:

250000 2107
45309 61426
213348 205105
134625 20838
54219 160005
24567 234742
24819 213399
75027 200911
83570 12327
72983 156185
114108 113222
80478 217079
204472 82515
243070 193076
213460 122084
126776 159815
199111 228283
189106 157819
137417 238943
100534 229459
65914 100184
101389 206862
143049 ...

output:

9984
10852
2873
83026
10854
5561
2944
3431
10857
4911
3423
4544
3181
2528
2506
11888
13132
3739
10854
9980
2689
16624
6760
4722
5560
3530
2569
2576
3090
3342
2943
27693
5329
2516
3260
2929
4108
83025
3338
3729
6410
2815
3164
2763
4905
49825
2587
4896
3348
3515
6754
3427
10853
2875
4105
3626
9993
998...

result:

ok 2107 lines

Test #160:

score: 0
Accepted
time: 858ms
memory: 71596kb

input:

250000 2117
81132 210775
159253 134849
122608 246672
102266 142095
237993 235493
132952 91806
19263 46699
225713 178861
112530 1062
12594 235184
184521 14414
36699 203418
41690 70969
74907 22563
122366 200785
103608 134193
128785 121262
227814 24953
10951 199309
29068 216295
153934 137249
178155 690...

output:

9188
22491
9915
-1
3602
2802
4698
5301
49439
2750
4361
82373
5520
-1
2447
3495
3009
6373
6711
4368
2688
49439
-1
8554
2926
10775
4363
22489
8008
3948
7998
8556
10776
4370
2995
9916
8005
2790
6709
14568
4870
7096
7095
6049
49439
5291
2759
2508
2621
2564
27480
3609
4698
3161
6059
9913
27481
7532
8007
...

result:

ok 2117 lines

Test #161:

score: 0
Accepted
time: 835ms
memory: 71620kb

input:

250000 2118
109195 104584
68376 162951
243288 150584
40674 238547
55067 136556
38895 203590
220440 44699
89364 139674
115197 104770
69594 206005
77345 92048
172848 242887
147323 38587
83919 236760
204310 220304
155140 104955
158919 85983
79344 155936
79935 200684
37204 31281
203803 14579
135721 9015...

output:

8020
4114
3523
27509
49465
4390
2592
2952
10801
9944
2709
9214
6742
2767
27508
8031
9947
7548
10803
4904
49464
6742
6738
10803
6742
8029
5817
2953
7549
7114
9950
2541
2595
9938
82399
3861
4916
2821
2729
4912
3345
5552
16533
6738
3854
8032
9947
3428
11822
4907
3355
7547
3980
49463
49464
8037
11823
42...

result:

ok 2118 lines

Test #162:

score: 0
Accepted
time: 838ms
memory: 71696kb

input:

250000 2117
230611 101969
196017 144691
41023 153329
63848 127043
181096 6289
115603 87874
214638 189062
179428 180821
32025 103244
157115 105127
143832 138961
177366 218088
249385 170091
231384 190172
204253 61467
241072 161805
122254 105380
48673 185115
3835 103683
30775 178723
192191 148114
15295...

output:

82403
82403
4724
3760
3630
4391
2545
2719
3442
16531
2707
4545
13064
3762
9219
5811
10803
14597
7125
7124
14598
3548
11825
2777
3861
6750
6078
9208
3963
5108
3969
27510
3752
5321
4728
4541
4113
9946
3015
247074
3866
27510
8576
19067
2948
3179
6398
247074
6745
27512
4110
9942
3353
6095
5106
3012
7546...

result:

ok 2117 lines

Test #163:

score: 0
Accepted
time: 863ms
memory: 71740kb

input:

250000 2118
18931 221501
237747 238886
73231 133512
230757 148187
119895 110583
94546 124922
8359 240655
162745 29579
68613 28795
14378 16761
135382 237682
100641 16650
240267 173586
172069 19866
10319 92236
210866 183694
180663 222114
130243 96383
74567 8806
26437 147589
149634 145436
76529 234864
...

output:

3062
11796
3510
3248
3338
2817
4368
22496
5510
6050
4692
3949
2800
10777
4883
2620
3838
4691
11802
4077
7996
2869
3830
2509
4869
247046
10778
49440
7999
2684
7098
2569
3413
5778
4711
5282
82374
2994
6707
8559
2569
4700
4879
3324
2464
3162
3618
9192
14564
7523
4518
49439
2764
6366
5789
10780
8551
605...

result:

ok 2118 lines