QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#140430#1139. StationsQwerty1232#16 118ms4104kbC++201.7kb2023-08-15 21:52:122024-07-04 01:44:54

Judging History

你现在查看的是最新测评结果

  • [2024-07-04 01:44:54]
  • 评测
  • 测评结果:16
  • 用时:118ms
  • 内存:4104kb
  • [2023-08-15 21:52:12]
  • 提交

stations

#include "stations.h"

#include <cassert>
#include <vector>

constexpr int N = 1e3;

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
    std::vector<std::vector<int>> gr(n);
    for (int i = 0; i < n - 1; i++) {
        gr[u[i]].push_back(v[i]);
        gr[v[i]].push_back(u[i]);
    }
    std::vector<int> depth(n), tin(n), tout(n);
    auto dfs = [&](auto dfs, int v, int f, int d, int& e) -> void {
        tin[v] = e++;
        depth[v] = d;
        for (int t : gr[v]) {
            if (t != f) {
                dfs(dfs, t, v, d + 1, e);
            }
        }
        tout[v] = e;
    };
    int e = 0;
    dfs(dfs, 0, -1, 0, e);

    std::vector<int> res(n);
    // res[0] = N;
    for (int i = 0; i < n; i++) {
        // res[i] = depth[i] % 2 ? tin[i] : tout[i];
        res[i] = tin[i] + N * (tout[i] - 1);
    }
    return res;
}

int find_next_station(int s, int dest, std::vector<int> c) {
    assert(s != dest);
    for (int to : c) {
        if (to == dest) {
            return to;
        }
    }
    int tin_s = s % N;
    int tout_s = s / N + 1;
    int tin_d = dest % N;
    int tout_d = dest / N + 1;
    for (int i = 0; i < c.size(); i++) {
        int tin_t = c[i] % N;
        int tout_t = c[i] / N + 1;
        if (tin_s <= tin_t && tin_t < tout_s) {
            if (tin_t <= tin_d && tin_d < tout_t) {
                return c[i];
            }
        }
    }
    for (int i = 0; i < c.size(); i++) {
        int tin_t = c[i] % N;
        int tout_t = c[i] / N + 1;

        if (tin_t <= tin_s && tin_s <= tout_t) {
            return c[i];
        }
    }
    assert(false);
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3580kb

input:

0
10
10 1000
4 5
9 0
2 6
5 2
8 3
1 4
8 1
6 0
3 7
3 1000
0 1
1 2
998 1000
166 178
393 452
389 179
622 429
892 866
872 18
899 227
835 637
587 769
504 386
369 577
65 441
523 17
803 221
878 321
637 892
696 473
16 146
840 322
495 986
353 275
330 585
831 402
719 810
704 830
780 940
53 901
894 911
394 482
...

output:

10
9000
9006
9003
9008
9005
9004
9002
9009
9007
1001
3
2000
2001
2002
998
997000
997223
218053
218207
997508
997816
997365
997369
218086
218104
997329
997529
218138
997787
997608
218152
997447
997270
997680
997519
997863
997579
997434
997687
997402
997709
997718
997962
997818
997320
218011
997839
99...

input:

1
-1
0

output:


result:

FAIL Unexpected end of file - int32 expected (/opt/uoj/judger/uoj_judger/work/channel_2_answer.txt)

Subtask #2:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 2ms
memory: 3592kb

input:

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

output:

996
995000
511001
995512
256002
511257
767513
995768
129003
256130
384258
511385
640514
767641
895769
995896
66004
129067
193131
256194
321259
384322
448386
511449
577515
640578
704642
767705
832770
895833
959897
995960
35005
66036
98068
129099
162132
193163
225195
256226
290260
321291
353323
384354...

input:

1
-1
0

output:


result:

FAIL Unexpected end of file - int32 expected (/opt/uoj/judger/uoj_judger/work/channel_2_answer.txt)

Subtask #3:

score: 16
Accepted

Test #17:

score: 16
Accepted
time: 78ms
memory: 4092kb

input:

0
10
2 1000000
1 0
997 1000000
830 513
223 672
727 200
763 415
581 440
34 42
267 325
912 693
753 59
401 289
198 641
982 214
41 49
453 107
940 806
905 732
153 482
248 405
102 79
480 837
534 620
564 856
679 178
278 247
899 206
333 672
297 308
407 863
26 752
272 178
204 603
208 10
715 562
785 285
184 5...

output:

2
1000
1001
997
996000
863251
863427
863578
863071
863300
863525
863291
863380
863036
863659
863114
996886
863630
863484
863456
996936
996880
863045
996947
863161
863485
863182
863437
863172
996970
863670
863788
863620
863399
996891
863022
863075
863340
863605
863375
863396
863226
863082
863706
9969...

input:

1
59859
5001 5005 2
5002
9000
1001 1000 1
1000
1001 1000 1
1000
999031 999085 2
999030
999032
998293 998395 2
998292
998294
997265 997863 2
997264
997266
1000 1001 1
1001
9007 9000 2
9006
9008
999122 999328 2
999121
999123
1000 1001 1
1001
1000 1001 1
1001
1001 1000 1
1000
2001 2002 2
2000
2002
9968...

output:

5002
1000
1000
999032
998294
997266
1001
9006
999123
1001
1001
1000
2002
996896
999370
999510
5002
2001
863294
99030
997556
998385
996974
996977
2002
887715
887526
887696
2001
3002
887642
9000
997541
3001
1000
3002
997628
999326
997791
2002
863374
887700
999989
999642
5004
3001
998918
863455
998976
...

result:

ok 

Test #18:

score: 16
Accepted
time: 80ms
memory: 3884kb

input:

0
10
999 1000000
719 816
256 855
722 661
705 575
610 707
632 426
296 99
891 512
445 475
76 601
63 756
576 934
73 186
606 363
702 69
48 768
568 128
904 82
223 805
146 382
922 467
347 433
959 614
709 998
296 4
544 64
165 989
856 470
370 230
239 810
911 976
728 952
162 752
682 305
511 782
113 37
576 41...

output:

999
998000
998987
800629
800723
800546
800226
800341
800197
800749
998806
800415
998820
998952
800347
998880
800206
800317
800249
998802
800721
800610
800256
800736
800769
800526
800608
800542
800689
800374
800516
998979
800041
998902
800744
800510
800461
998951
800285
800507
800663
800792
800509
80...

input:

1
50048
930149 930561 2
930148
930150
743342 743487 2
743341
743343
995812 995856 2
995811
995813
930589 930169 2
930588
930590
800476 998929 2
800475
800477
800276 800583 2
800275
800277
990967 930183 2
990966
990968
930865 930655 2
930864
930866
743550 995971 2
743549
743551
961008 961430 2
961007...

output:

930150
743343
995813
930588
800475
800277
990966
930864
743549
961009
800529
996225
992982
961848
743502
604509
743473
684618
992653
991305
961616
961197
993379
996314
991129
684355
743236
604118
800261
604099
961808
991186
604313
604266
995966
991577
999864
604354
743188
604275
106055
993342
961804...

result:

ok 

Test #19:

score: 16
Accepted
time: 110ms
memory: 4100kb

input:

0
10
2 1000000
0 1
2 1000000
0 1
2 1000000
1 0
2 1000000
0 1
2 1000000
1 0
2 1000000
0 1
2 1000000
1 0
2 1000000
1 0
2 1000000
1 0
2 1000000
1 0

output:

2
1000
1001
2
1000
1001
2
1000
1001
2
1000
1001
2
1000
1001
2
1000
1001
2
1000
1001
2
1000
1001
2
1000
1001
2
1000
1001

input:

1
100000
1000 1001 1
1001
1000 1001 1
1001
1001 1000 1
1000
1000 1001 1
1001
1001 1000 1
1000
1000 1001 1
1001
1000 1001 1
1001
1000 1001 1
1001
1001 1000 1
1000
1000 1001 1
1001
1001 1000 1
1000
1000 1001 1
1001
1001 1000 1
1000
1001 1000 1
1000
1001 1000 1
1000
1001 1000 1
1000
1000 1001 1
1001
10...

output:

1001
1001
1000
1001
1000
1001
1001
1001
1000
1001
1000
1001
1000
1000
1000
1000
1001
1000
1000
1001
1001
1001
1001
1000
1001
1001
1001
1000
1001
1001
1000
1000
1001
1001
1001
1001
1000
1000
1001
1001
1001
1000
1001
1001
1000
1001
1000
1000
1000
1001
1000
1001
1000
1000
1000
1001
1000
1000
1001
1000
...

result:

ok 

Test #20:

score: 16
Accepted
time: 88ms
memory: 3804kb

input:

0
10
3 1000000
1 0
0 2
3 1000000
2 0
0 1
3 1000000
2 1
2 0
3 1000000
2 0
2 1
3 1000000
0 1
1 2
3 1000000
1 0
1 2
3 1000000
2 0
2 1
3 1000000
0 1
2 1
3 1000000
2 1
0 1
3 1000000
0 2
2 1

output:

3
2000
1001
2002
3
2000
2002
1001
3
2000
2002
2001
3
2000
2002
2001
3
2000
2001
2002
3
2000
2001
2002
3
2000
2002
2001
3
2000
2001
2002
3
2000
2001
2002
3
2000
2002
2001

input:

1
74899
2000 2002 1
2001
2002 2000 1
2001
2002 2001 1
2001
1001 2000 1
2000
2002 1001 1
2000
2000 1001 2
1001
2002
2001 2000 2
2000
2002
2000 2001 1
2001
2000 2002 1
2001
2001 2002 2
2000
2002
2000 2002 2
1001
2002
2000 2001 1
2001
2000 2001 1
2001
2002 2000 1
2001
2002 2001 1
2001
2000 2002 1
2001
...

output:

2001
2001
2001
2000
2000
1001
2000
2001
2001
2002
2002
2001
2001
2001
2001
2001
2001
2001
2000
2000
2002
2001
2001
2001
2001
2002
2002
2001
2000
2000
2001
2001
2001
2000
2001
2001
2001
2001
2002
2000
2002
2001
2000
2001
2001
2001
2002
2001
2000
2000
2001
2001
2000
2001
2002
2002
2000
2002
2001
2002
...

result:

ok 

Test #21:

score: 16
Accepted
time: 88ms
memory: 4064kb

input:

0
10
4 1000000
0 1
2 3
0 2
4 1000000
2 1
3 1
0 2
4 1000000
3 1
3 0
1 2
4 1000000
1 3
2 1
0 2
4 1000000
1 2
1 3
0 3
4 1000000
1 0
1 2
0 3
4 1000000
3 0
0 2
2 1
4 1000000
0 1
2 0
1 3
4 1000000
2 0
0 1
2 3
4 1000000
2 1
3 0
3 1

output:

4
3000
1001
3002
3003
4
3000
3002
3001
3003
4
3000
3002
3003
3001
4
3000
3002
3001
3003
4
3000
3002
3003
3001
4
3000
2001
2002
3003
4
3000
3003
3002
1001
4
3000
2001
3003
2002
4
3000
3003
2001
2002
4
3000
3002
3003
3001

input:

1
66495
3002 3003 2
3000
3003
3002 3001 2
3001
3003
2002 3000 1
2001
1001 3000 1
3000
1001 3002 1
3000
3003 3001 1
3002
2002 3000 1
2001
2001 3000 2
2002
3000
3003 3002 1
3002
3003 3001 1
3002
3003 1001 1
3002
3002 3000 2
3001
3003
3002 3000 2
3000
3003
3003 3000 1
3000
3003 3001 1
3002
3003 3000 1
...

output:

3003
3001
2001
3000
3000
3002
2001
3000
3002
3002
3002
3001
3000
3000
3002
3002
3000
3001
3003
3002
2002
3001
3002
3000
3000
3002
3000
3001
3000
3002
3002
3000
3000
3001
3000
2001
3001
2001
3000
2001
3002
3000
3001
3002
2001
3000
3002
3000
1001
3003
3002
3001
1001
2001
3002
2001
2002
3002
3001
3002
...

result:

ok 

Test #22:

score: 16
Accepted
time: 70ms
memory: 4104kb

input:

0
10
1000 1000000
526 757
286 227
877 883
484 370
847 13
425 107
166 745
276 357
746 21
304 131
462 834
317 58
942 423
375 631
977 908
229 838
549 167
518 60
51 772
419 970
909 386
362 829
470 46
218 986
82 787
919 307
947 691
348 900
233 650
253 762
90 850
144 627
954 103
602 268
187 746
568 992
31...

output:

1000
999000
723356
723347
723111
723710
723275
723686
999774
723084
999927
723116
723524
723220
723215
999965
999888
723113
723393
723286
999820
723041
723247
723370
723101
723669
723642
999903
999908
999806
999942
999823
999874
999993
723090
999752
723127
999924
723136
723255
723438
723151
723711
7...

input:

1
50050
293077 293275 2
293076
293078
339108 339110 2
339107
339109
999823 723433 2
999822
999824
999909 999225 2
999908
999910
999997 322029 2
999996
999998
999362 999425 2
999361
999363
999836 723420 2
999835
999837
999312 230183 2
999311
999313
999617 999462 2
999616
999618
723459 999995 2
723458...

output:

293078
339109
999822
999908
999996
999363
999835
999311
999616
723458
999692
999848
999734
999829
999602
999457
999672
999313
999740
293176
999455
999299
999846
999732
999566
723131
723120
723486
999502
999663
339264
999925
293257
999936
723106
999310
999678
999394
293184
999741
999414
999654
999947...

result:

ok 

Test #23:

score: 16
Accepted
time: 70ms
memory: 3868kb

input:

0
1
1000 1000000
622 589
830 829
709 500
278 363
20 230
963 181
768 29
857 332
787 757
897 285
480 939
855 617
959 84
687 755
667 30
553 1
213 98
987 780
47 851
107 764
130 863
326 832
872 636
85 159
119 330
672 210
134 576
224 282
570 387
53 941
723 69
694 642
707 49
260 390
525 768
78 273
811 220
...

output:

1000
999000
999956
999370
234138
234066
999564
999925
999824
234004
234111
999759
234011
999805
999875
999932
999996
234190
999656
999511
234089
234092
999796
999249
999900
999789
999533
999387
999326
234063
999722
999312
999634
234176
234007
999841
999882
999712
999979
999259
234184
234188
234039
9...

input:

1
50053
999445 999346 2
999444
999446
999619 999812 2
999618
999620
234052 234203 2
234051
234053
999877 999522 2
999876
999878
999568 999667 2
999567
999569
999896 999784 2
999895
999897
234195 999832 2
234194
234196
999490 999523 2
999489
999491
999693 999388 2
999692
999694
999410 999575 2
999409...

output:

999444
999620
234053
999876
999569
999895
234194
999491
999692
999411
234214
999793
999839
234044
999759
234108
234008
999916
999920
999439
999393
999646
999751
999616
999612
999518
234134
999669
234149
999292
999260
999799
999958
999700
999885
999403
999746
999483
999758
234187
999709
234059
999844...

result:

ok 

Test #24:

score: 16
Accepted
time: 2ms
memory: 3808kb

input:

0
10
4 1000000
0 1
1 2
2 3
4 1000000
0 1
1 3
3 2
4 1000000
0 2
2 1
1 3
4 1000000
0 2
2 3
3 1
4 1000000
0 3
3 1
1 2
4 1000000
0 3
3 2
2 1
4 1000000
1 0
0 2
2 3
4 1000000
1 0
0 3
3 2
4 1000000
1 2
2 0
0 3
4 1000000
1 3
3 0
0 2

output:

4
3000
3001
3002
3003
4
3000
3001
3003
3002
4
3000
3002
3001
3003
4
3000
3003
3001
3002
4
3000
3002
3003
3001
4
3000
3003
3002
3001
4
3000
1001
3002
3003
4
3000
1001
3003
3002
4
3000
2002
2001
3003
4
3000
2002
3003
2001

input:

1
120
3001 3003 2
3000
3002
3001 3002 2
3000
3002
3001 3002 2
3000
3002
3003 3002 1
3002
3002 3001 2
3001
3003
3000 1001 2
1001
3002
3000 3003 2
1001
3002
3000 3001 1
3001
3003 1001 1
3002
3002 1001 2
3000
3003
3001 3000 2
3000
3002
1001 3002 1
3000
3001 3000 2
3000
3002
3002 3003 2
3001
3003
1001 3...

output:

3002
3002
3002
3002
3001
1001
3002
3001
3002
3000
3000
3000
3000
3003
3000
3001
3003
2001
3003
3001
3001
3001
3003
3002
3002
3002
3001
3002
3000
3003
3002
1001
3001
3002
3000
3002
3002
2001
3000
3001
3002
3001
3000
3002
3002
3001
3002
3001
3001
3002
3000
2001
3003
3001
3000
3001
3000
3002
3000
3002
...

result:

ok 

Test #25:

score: 16
Accepted
time: 2ms
memory: 3816kb

input:

0
10
6 1000000
0 1
1 2
2 3
3 4
4 5
6 1000000
0 1
1 2
2 3
3 5
5 4
6 1000000
0 1
1 2
2 4
4 3
3 5
6 1000000
0 1
1 2
2 4
4 5
5 3
6 1000000
0 1
1 2
2 5
5 3
3 4
6 1000000
0 1
1 2
2 5
5 4
4 3
6 1000000
0 1
1 3
3 2
2 4
4 5
6 1000000
0 1
1 3
3 2
2 5
5 4
6 1000000
0 1
1 3
3 4
4 2
2 5
6 1000000
0 1
1 3
3 4
4 5...

output:

6
5000
5001
5002
5003
5004
5005
6
5000
5001
5002
5003
5005
5004
6
5000
5001
5002
5004
5003
5005
6
5000
5001
5002
5005
5003
5004
6
5000
5001
5002
5004
5005
5003
6
5000
5001
5002
5005
5004
5003
6
5000
5001
5003
5002
5004
5005
6
5000
5001
5003
5002
5005
5004
6
5000
5001
5004
5002
5003
5005
6
5000
5001
...

input:

1
300
5003 5002 2
5002
5004
5004 5003 2
5003
5005
5004 5000 2
5003
5005
5004 5005 2
5003
5005
5001 5005 2
5000
5002
5003 5000 2
5002
5004
5001 5003 2
5000
5002
5004 5001 2
5003
5005
5000 5001 1
5001
5002 5005 2
5001
5003
5000 5002 1
5001
5003 5005 2
5002
5004
5003 5004 2
5002
5004
5002 5003 2
5001
5...

output:

5002
5003
5003
5005
5002
5002
5002
5003
5001
5003
5001
5004
5004
5003
5003
5005
5003
5004
5004
5003
5002
5000
5002
5003
5001
5001
5001
5005
5003
5004
5003
5003
5001
5004
5003
5002
5001
5003
5004
5005
5004
5001
5004
5004
5005
5002
5001
5002
5002
5001
5003
5001
5002
5004
5005
5002
5001
5001
5003
5003
...

result:

ok 

Test #26:

score: 16
Accepted
time: 2ms
memory: 3884kb

input:

0
3
3 1000000
0 1
1 2
3 1000000
0 2
2 1
3 1000000
1 0
0 2

output:

3
2000
2001
2002
3
2000
2002
2001
3
2000
1001
2002

input:

1
18
2000 2002 1
2001
2000 2001 1
2001
2000 2002 2
1001
2002
2000 2002 1
2001
2002 2000 1
2001
2001 2002 2
2000
2002
2002 1001 1
2000
2002 2000 1
2001
2000 2001 1
2001
2001 2000 2
2000
2002
1001 2000 1
2000
2001 2000 2
2000
2002
1001 2002 1
2000
2002 2000 1
2000
2002 2001 1
2001
2000 1001 2
1001
200...

output:

2001
2001
2002
2001
2001
2002
2000
2001
2001
2000
2000
2000
2000
2000
2001
1001
2001
2002

result:

ok 

Test #27:

score: 16
Accepted
time: 72ms
memory: 3800kb

input:

0
10
4 1000000
2 1
1 0
3 2
4 1000000
1 2
0 1
1 3
4 1000000
1 0
2 0
0 3
4 1000000
1 3
1 0
2 0
4 1000000
3 2
0 3
3 1
4 1000000
0 1
1 3
2 1
4 1000000
0 1
0 3
3 2
4 1000000
0 3
1 2
0 2
4 1000000
0 2
3 2
2 1
4 1000000
2 0
2 3
0 1

output:

4
3000
3001
3002
3003
4
3000
3001
2002
3003
4
3000
1001
2002
3003
4
3000
2001
3003
2002
4
3000
3003
2002
3001
4
3000
3001
3003
2002
4
3000
1001
3003
3002
4
3000
3003
3002
1001
4
3000
3003
3001
2002
4
3000
3003
2001
2002

input:

1
66694
3000 3003 2
1001
3002
3002 3003 2
3000
3003
2002 3001 1
3001
3001 3000 3
2002
3000
3003
3003 1001 1
3002
2001 2002 2
2002
3000
1001 2002 1
3000
3003 2001 1
3000
2002 3001 1
3001
3003 1001 1
3002
3000 3003 1
3001
3003 1001 1
3002
1001 2002 1
3000
2001 3003 2
2002
3000
3001 3003 3
2002
3000
30...

output:

3002
3003
3001
3000
3002
2002
3000
3000
3001
3002
3001
3002
3000
3000
3003
3001
3000
3001
3001
3001
3001
3001
3001
3000
3001
3001
3001
2001
3001
3001
3000
3002
3001
3002
3000
3003
3002
2002
3000
3001
3001
3000
3000
3000
3003
3002
2001
3001
3000
3002
2001
3003
3001
3001
3002
3000
2002
3000
3001
3000
...

result:

ok 

Test #28:

score: 16
Accepted
time: 80ms
memory: 3820kb

input:

0
10
1000 1000000
802 637
810 172
802 781
109 293
802 724
488 524
73 802
802 312
108 985
802 594
305 802
802 620
382 747
841 535
802 690
987 387
269 559
201 219
982 319
228 802
802 977
291 962
657 597
69 757
321 555
825 299
802 694
363 827
802 265
475 796
600 891
802 16
802 116
487 167
150 335
175 5...

output:

1000
999000
279271
512471
625592
936928
838836
625532
338335
915915
957957
999034
700694
320320
512509
392392
700697
86086
838820
700693
143136
512462
625522
190190
385385
702702
512468
416416
512510
115115
388388
838827
345345
626626
383383
289287
925925
253253
300300
255255
907907
148148
999027
64...

input:

1
51340
752298 999790 2
752297
752299
999265 999051 2
999264
999266
646263 646509 2
646262
646264
349315 956946 2
349314
349316
999897 999497 2
999896
999898
625606 260260 2
625605
625607
700683 13007 2
700682
700684
143136 919913 2
143135
143137
609609 702702 1
609608
701701 684682 1
999002
752140 ...

output:

752297
999264
646264
349314
999896
625605
700682
143135
609608
999002
752141
752737
687673
999071
971965
662658
396331
999071
999002
838819
795724
833794
386381
752586
799794
999071
968942
396381
999655
999847
981923
999241
168161
246238
783487
999921
625569
286221
783455
894818
999857
999850
25003
...

result:

ok 

Test #29:

score: 16
Accepted
time: 84ms
memory: 3788kb

input:

0
10
1000 1000000
1 433
265 863
766 305
237 422
591 33
588 87
33 868
33 328
110 458
718 791
891 33
22 576
773 795
489 357
104 33
33 829
308 726
592 865
651 179
591 508
264 792
274 367
219 33
67 600
419 406
583 183
716 211
4 709
983 33
672 928
648 689
679 497
321 874
711 585
758 518
223 702
440 618
7...

output:

1000
999000
603601
512510
429429
290285
467461
383379
715715
53051
398398
863862
594593
171169
719719
874871
579578
780776
965959
398396
839836
258252
603598
874874
322320
970967
588587
517515
970970
664664
114113
495495
802802
436435
998003
773769
525525
223219
700700
841840
856853
445444
623618
35...

input:

1
51513
999767 999930 2
999766
999768
476437 33005 2
476436
476438
416416 618618 1
999001
486486 745745 1
999001
745740 533530 2
745739
745741
489486 154153 2
489485
489487
311011 999775 2
311010
311012
529449 850664 2
529448
529450
618600 108096 2
618599
618601
491491 387387 1
999001
902027 902612 ...

output:

999768
476436
999001
999001
745739
489485
311010
529448
618599
999001
902028
919914
997010
591578
978713
850019
998003
850571
902545
267260
253188
999561
997010
999583
820815
999326
999001
945922
69054
311213
999029
794792
902474
850697
790781
902169
978579
253039
902210
999001
290284
999368
999032
...

result:

ok 

Test #30:

score: 16
Accepted
time: 80ms
memory: 3872kb

input:

0
1
1000 1000000
394 768
598 218
369 360
414 385
909 666
948 524
272 868
110 348
723 672
225 409
312 213
865 469
207 711
779 480
303 958
946 880
22 137
265 787
595 9
193 865
661 869
680 238
708 770
389 82
828 35
881 49
138 749
220 975
452 201
641 269
734 497
155 159
324 778
105 650
882 621
519 319
4...

output:

1000
999000
308293
922922
213198
73073
351337
888854
999969
213204
308281
33016
640614
33032
122119
102076
351331
376372
567560
213180
213185
999982
540505
272267
151140
176156
308274
540506
966934
608594
245232
33029
122104
803788
272246
673665
540528
673659
736731
73047
640622
803789
848841
102094...

input:

1
49931
999997 736708 2
999996
999998
351322 736734 2
351321
351323
966001 438418 30
33002
73034
102074
122103
151123
176152
213177
245214
272246
308273
351309
376352
410377
438411
464439
500465
540501
567541
608568
640609
673641
703674
736704
774737
803775
848804
888849
922889
966923
999000
272246 ...

output:

999996
351321
438411
966001
438428
608598
736710
966963
308281
848809
102082
500486
33016
351318
966001
73065
410389
999981
888852
351332
567551
151144
803775
500480
774764
151150
540538
500495
966940
410393
966001
999967
774746
736731
608575
999000
803788
703689
540537
245231
73069
308297
999982
54...

result:

ok 

Test #31:

score: 16
Accepted
time: 26ms
memory: 3808kb

input:

0
10
96 1000000
0 36
27 0
95 0
7 0
0 70
59 0
72 0
83 0
22 0
25 0
18 0
92 0
0 88
87 0
0 75
0 68
39 0
0 84
0 43
0 24
28 0
19 0
5 0
0 80
37 0
0 33
77 0
15 0
0 38
3 0
0 60
11 0
74 0
89 0
52 0
79 0
0 73
81 0
44 0
76 0
41 0
21 0
57 0
0 85
40 0
49 0
0 45
0 46
16 0
14 0
0 66
29 0
20 0
32 0
0 1
0 51
0 47
0 3...

output:

96
95000
55055
86086
30030
92092
23023
83083
4004
76076
64064
77077
32032
94094
91091
50050
28028
49049
72072
11011
22022
53053
42042
9009
74074
20020
10010
71071
2002
21021
52052
62062
58058
54054
26026
65065
60060
1001
25025
29029
17017
45045
41041
75075
19019
39039
47047
48048
57057
90090
46046
5...

input:

1
4026
66066 94094 1
95000
17017 78078 1
95001
34034 84084 1
95000
50050 44044 1
95000
70070 77077 1
95000
95000 17017 95
1001
2002
3003
4004
5005
6006
7007
8008
9009
10010
11011
12012
13013
14014
15015
16016
17017
18018
19019
20020
21021
22022
23023
24024
25025
26026
27027
28028
29029
30030
31031
3...

output:

95000
95001
95000
95000
95000
17017
95000
95001
95001
95001
95001
95000
95000
95001
24024
95001
95000
95000
82082
95000
95000
95001
95000
95001
67067
95000
95001
61061
95001
95001
95001
95000
27027
95000
95000
95000
95001
95000
95000
95000
95001
95000
95000
95001
26026
95000
95001
95001
95000
95001
...

result:

ok 

Test #32:

score: 16
Accepted
time: 30ms
memory: 4104kb

input:

0
10
541 1000000
540 23
540 21
40 540
150 540
540 291
540 34
3 540
540 416
428 540
347 540
60 540
140 540
540 216
411 540
57 540
540 214
271 540
439 540
400 540
379 540
195 540
540 167
152 540
540 254
251 540
399 540
540 185
420 540
540 154
534 540
540 160
540 194
247 540
540 11
342 540
540 257
454 ...

output:

541
540000
59059
148148
8008
258258
42042
256256
51051
386386
382382
255255
35035
503503
328328
527527
514514
442442
230230
163163
274274
208208
3003
227227
2002
462462
387387
91091
84084
535535
504504
516516
123123
469469
207207
7007
55055
322322
346346
103103
138138
4004
44044
62062
251251
66066
3...

input:

1
5675
235235 168168 1
540000
201201 376376 1
540000
192192 468468 1
540001
207207 59059 1
540001
540001 403403 540
2002
3003
4004
5005
6006
7007
8008
9009
10010
11011
12012
13013
14014
15015
16016
17017
18018
19019
20020
21021
22022
23023
24024
25025
26026
27027
28028
29029
30030
31031
32032
33033
...

output:

540000
540000
540001
540001
403403
540001
540001
540001
540001
540000
540000
540001
540000
540001
540000
540001
540000
540000
540001
540000
540000
540001
540000
540001
540000
540001
540001
540001
540000
540001
540001
540001
540001
540001
540000
540000
540001
540001
540000
540001
540001
540001
540001...

result:

ok 

Test #33:

score: 16
Accepted
time: 34ms
memory: 4104kb

input:

0
10
1000 1000000
989 0
0 294
783 0
474 0
831 0
397 0
0 538
626 0
554 0
837 0
954 0
0 694
343 0
883 0
0 957
0 24
0 688
0 17
406 0
472 0
929 0
22 0
0 412
0 195
150 0
0 518
0 255
35 0
381 0
751 0
0 928
0 555
0 241
0 590
454 0
373 0
0 72
389 0
455 0
327 0
0 917
572 0
0 164
335 0
0 59
0 809
0 182
0 123
...

output:

1000
999000
491491
878878
521521
906906
468468
452452
440440
100100
610610
423423
160160
347347
343343
605605
98098
844844
18018
244244
211211
973973
689689
22022
597597
16016
701701
771771
58058
871871
574574
568568
320320
460460
229229
54054
28028
205205
430430
424424
260260
572572
715715
432432
1...

input:

1
10180
72072 388388 1
999001
47047 335335 1
999001
57057 340340 1
999001
123123 915915 1
999001
196196 718718 1
999000
971971 768768 1
999001
737737 590590 1
999000
403403 608608 1
999001
614614 256256 1
999001
105105 319319 1
999000
275275 805805 1
999000
775775 190190 1
999001
28028 667667 1
9990...

output:

999001
999001
999001
999001
999000
999001
999000
999001
999001
999000
999000
999001
999000
999000
999000
999001
999001
999000
999001
999001
999001
999001
999001
999000
840840
999000
999000
999001
999001
999000
999001
999000
999001
999000
999001
999001
999001
999001
999001
999001
999001
999001
999000...

result:

ok 

Subtask #4:

score: 0
Wrong Answer

Test #34:

score: 10
Accepted
time: 118ms
memory: 3804kb

input:

0
10
2 1000000000
0 1
2 1000000000
0 1
2 1000000000
1 0
2 1000000000
1 0
2 1000000000
0 1
2 1000000000
1 0
2 1000000000
1 0
2 1000000000
0 1
2 1000000000
0 1
2 1000000000
0 1

output:

2
1000
1001
2
1000
1001
2
1000
1001
2
1000
1001
2
1000
1001
2
1000
1001
2
1000
1001
2
1000
1001
2
1000
1001
2
1000
1001

input:

1
100000
1001 1000 1
1000
1000 1001 1
1001
1000 1001 1
1001
1001 1000 1
1000
1000 1001 1
1001
1001 1000 1
1000
1001 1000 1
1000
1001 1000 1
1000
1001 1000 1
1000
1001 1000 1
1000
1000 1001 1
1001
1001 1000 1
1000
1000 1001 1
1001
1001 1000 1
1000
1000 1001 1
1001
1000 1001 1
1001
1000 1001 1
1001
10...

output:

1000
1001
1001
1000
1001
1000
1000
1000
1000
1000
1001
1000
1001
1000
1001
1001
1001
1000
1000
1001
1000
1001
1001
1000
1000
1001
1001
1000
1001
1001
1000
1000
1000
1000
1000
1001
1000
1001
1000
1000
1000
1001
1001
1000
1001
1001
1001
1001
1000
1000
1001
1001
1000
1000
1000
1001
1001
1000
1001
1001
...

result:

ok 

Test #35:

score: 10
Accepted
time: 84ms
memory: 3864kb

input:

0
10
3 1000000000
2 1
2 0
3 1000000000
1 0
2 0
3 1000000000
2 0
0 1
3 1000000000
0 2
1 2
3 1000000000
1 2
1 0
3 1000000000
1 0
2 1
3 1000000000
0 2
1 2
3 1000000000
1 2
1 0
3 1000000000
0 2
1 0
3 1000000000
2 0
1 2

output:

3
2000
2002
2001
3
2000
1001
2002
3
2000
2002
1001
3
2000
2002
2001
3
2000
2001
2002
3
2000
2001
2002
3
2000
2002
2001
3
2000
2001
2002
3
2000
2002
1001
3
2000
2002
2001

input:

1
75069
2001 2002 2
2000
2002
2000 1001 2
1001
2002
2000 2002 1
2001
2000 2002 1
2001
1001 2000 1
2000
2000 2002 1
2001
2002 2001 1
2001
2001 2000 2
2000
2002
1001 2002 1
2000
2001 2002 2
2000
2002
2001 2002 2
2000
2002
2002 2000 1
2001
2001 2002 2
2000
2002
2001 2002 2
2000
2002
2002 2000 1
2001
20...

output:

2002
1001
2001
2001
2000
2001
2001
2000
2000
2002
2002
2001
2002
2002
2001
2001
2000
1001
2001
2001
2002
2002
2000
2001
2001
2001
2001
2000
2001
2000
2002
1001
2000
2001
2000
2001
2000
1001
2001
2000
2001
2001
2000
2001
2000
2000
2002
2001
2000
2000
2001
2002
2000
2001
2002
2002
2001
2001
2000
2001
...

result:

ok 

Test #36:

score: 10
Accepted
time: 80ms
memory: 4088kb

input:

0
10
4 1000000000
3 1
2 0
1 0
4 1000000000
0 3
1 2
3 1
4 1000000000
3 1
0 2
0 1
4 1000000000
2 1
2 3
1 0
4 1000000000
3 1
0 1
2 3
4 1000000000
0 1
3 0
2 3
4 1000000000
2 0
3 0
1 2
4 1000000000
0 2
2 3
1 3
4 1000000000
3 2
2 1
3 0
4 1000000000
2 3
3 0
0 1

output:

4
3000
3002
1001
3003
4
3000
3002
3003
3001
4
3000
3002
1001
3003
4
3000
3001
3002
3003
4
3000
3001
3003
3002
4
3000
1001
3003
3002
4
3000
2002
2001
3003
4
3000
3003
3001
3002
4
3000
3003
3002
3001
4
3000
3003
2002
2001

input:

1
66804
3000 2002 2
2001
3003
3000 2002 2
2001
3003
3002 3000 2
3000
3003
3000 3001 1
3001
3000 3003 2
1001
3002
3002 3003 2
3000
3003
3002 3003 2
3001
3003
3001 3002 2
3000
3002
3000 3002 1
3001
2001 3003 2
2002
3000
3000 3002 2
1001
3002
3002 3000 2
3000
3003
3002 3001 2
3001
3003
1001 3000 1
3000...

output:

2001
2001
3000
3001
3002
3003
3003
3002
3001
3000
3002
3000
3001
3000
3000
3000
3000
3003
3001
3002
3003
3000
3001
3002
3002
3000
3000
3002
3002
1001
3003
3002
3002
3000
3001
3002
3001
3002
3002
1001
3000
3002
3001
3002
3001
3000
3002
3002
3001
3002
2001
2001
1001
2001
2001
3002
3002
3002
3003
3000
...

result:

ok 

Test #37:

score: 10
Accepted
time: 2ms
memory: 3804kb

input:

0
10
4 1000000000
0 1
1 2
2 3
4 1000000000
0 1
1 3
3 2
4 1000000000
0 2
2 1
1 3
4 1000000000
0 2
2 3
3 1
4 1000000000
0 3
3 1
1 2
4 1000000000
0 3
3 2
2 1
4 1000000000
1 0
0 2
2 3
4 1000000000
1 0
0 3
3 2
4 1000000000
1 2
2 0
0 3
4 1000000000
1 3
3 0
0 2

output:

4
3000
3001
3002
3003
4
3000
3001
3003
3002
4
3000
3002
3001
3003
4
3000
3003
3001
3002
4
3000
3002
3003
3001
4
3000
3003
3002
3001
4
3000
1001
3002
3003
4
3000
1001
3003
3002
4
3000
2002
2001
3003
4
3000
2002
3003
2001

input:

1
120
3002 3001 2
3001
3003
2002 2001 1
2001
3003 3002 1
3002
3000 3003 1
3001
1001 3003 1
3000
3001 3002 2
3000
3002
3003 2002 1
3000
3000 3002 1
3001
3000 3001 1
3001
3003 3001 1
3002
3002 3000 2
3001
3003
3003 3002 1
3002
3000 3002 2
1001
3002
3002 3003 2
3001
3003
3001 3000 2
3000
3002
2002 3003...

output:

3001
2001
3002
3001
3000
3002
3000
3001
3001
3002
3001
3002
3002
3003
3000
2001
3001
3000
3002
3000
3002
3003
3002
3002
3000
2001
3002
3000
2001
3002
3001
3002
3002
3001
3001
3000
3001
3001
3001
3001
3002
2002
3003
3002
3002
3003
3002
3003
3002
3002
3002
3001
3000
3000
2001
3000
3001
3001
3002
3002
...

result:

ok 

Test #38:

score: 10
Accepted
time: 0ms
memory: 3800kb

input:

0
10
6 1000000000
0 1
1 2
2 3
3 4
4 5
6 1000000000
0 1
1 2
2 3
3 5
5 4
6 1000000000
0 1
1 2
2 4
4 3
3 5
6 1000000000
0 1
1 2
2 4
4 5
5 3
6 1000000000
0 1
1 2
2 5
5 3
3 4
6 1000000000
0 1
1 2
2 5
5 4
4 3
6 1000000000
0 1
1 3
3 2
2 4
4 5
6 1000000000
0 1
1 3
3 2
2 5
5 4
6 1000000000
0 1
1 3
3 4
4 2
2 ...

output:

6
5000
5001
5002
5003
5004
5005
6
5000
5001
5002
5003
5005
5004
6
5000
5001
5002
5004
5003
5005
6
5000
5001
5002
5005
5003
5004
6
5000
5001
5002
5004
5005
5003
6
5000
5001
5002
5005
5004
5003
6
5000
5001
5003
5002
5004
5005
6
5000
5001
5003
5002
5005
5004
6
5000
5001
5004
5002
5003
5005
6
5000
5001
...

input:

1
300
5000 5005 1
5001
5001 5005 2
5000
5002
5002 5001 2
5001
5003
5004 5005 2
5003
5005
5003 5000 2
5002
5004
5000 5001 1
5001
5001 5000 2
5000
5002
5000 5001 1
5001
5000 5001 1
5001
5001 5003 2
5000
5002
5003 5004 2
5002
5004
5000 5004 1
5001
5005 5002 1
5004
5003 5005 2
5002
5004
5000 5001 1
5001...

output:

5001
5002
5001
5005
5002
5001
5000
5001
5001
5002
5004
5001
5004
5004
5001
5003
5001
5003
5001
5004
5003
5002
5003
5002
5004
5002
5003
5001
5001
5002
5001
5003
5000
5004
5000
5004
5000
5002
5004
5002
5002
5002
5001
5002
5005
5001
5004
5003
5003
5004
5001
5001
5003
5004
5003
5003
5001
5002
5001
5003
...

result:

ok 

Test #39:

score: 10
Accepted
time: 2ms
memory: 3804kb

input:

0
3
3 1000000000
0 1
1 2
3 1000000000
0 2
2 1
3 1000000000
1 0
0 2

output:

3
2000
2001
2002
3
2000
2002
2001
3
2000
1001
2002

input:

1
18
2001 2002 2
2000
2002
2001 2000 2
2000
2002
2001 2000 2
2000
2002
2002 2000 1
2001
2002 2000 1
2000
1001 2000 1
2000
2002 2001 1
2001
2002 1001 1
2000
2001 2002 2
2000
2002
2000 1001 2
1001
2002
1001 2002 1
2000
2000 2002 1
2001
2000 2002 1
2001
2000 2001 1
2001
2002 2001 1
2001
2002 2000 1
200...

output:

2002
2000
2000
2001
2000
2000
2001
2000
2002
1001
2000
2001
2001
2001
2001
2001
2001
2002

result:

ok 

Test #40:

score: 10
Accepted
time: 88ms
memory: 4092kb

input:

0
10
4 1000000000
1 3
1 2
0 1
4 1000000000
2 3
3 0
1 3
4 1000000000
2 0
1 3
0 1
4 1000000000
1 2
3 1
1 0
4 1000000000
3 1
0 2
3 2
4 1000000000
2 0
2 1
2 3
4 1000000000
1 2
1 3
2 0
4 1000000000
0 2
2 3
2 1
4 1000000000
2 1
2 0
3 0
4 1000000000
3 0
3 2
1 0

output:

4
3000
3001
3003
2002
4
3000
3003
2002
3001
4
3000
3002
1001
3003
4
3000
3001
2002
3003
4
3000
3003
3001
3002
4
3000
2002
3001
3003
4
3000
3002
3001
3003
4
3000
3003
3001
2002
4
3000
2002
2001
3003
4
3000
3003
2002
2001

input:

1
66674
2002 2001 1
2001
2002 3003 1
3001
3001 2002 3
2002
3000
3003
2002 3003 1
3001
3001 3003 2
3000
3002
3001 2002 3
2002
3000
3003
3000 1001 2
1001
3002
3001 3000 3
2002
3000
3003
3001 2002 3
2002
3000
3003
3001 3002 2
3000
3002
3003 3002 1
3002
3002 1001 2
3000
3003
3000 3003 1
3001
3003 3000 1...

output:

2001
3001
2002
3001
3002
2002
1001
3000
2002
3002
3002
3000
3001
3001
3000
3000
3001
3000
3001
3001
3001
3001
3000
3001
3000
3003
3001
3001
3001
3003
2001
2001
3001
2001
3000
3001
3000
3001
3001
3001
3001
3001
3002
3002
3001
2001
3001
3001
3001
2001
3000
3000
3003
3001
3000
3001
3000
3001
3003
3001
...

result:

ok 

Test #41:

score: 10
Accepted
time: 116ms
memory: 3800kb

input:

0
10
2 1000000000
1 0
2 1000000000
0 1
2 1000000000
1 0
2 1000000000
1 0
2 1000000000
1 0
2 1000000000
0 1
2 1000000000
1 0
2 1000000000
1 0
2 1000000000
1 0
2 1000000000
0 1

output:

2
1000
1001
2
1000
1001
2
1000
1001
2
1000
1001
2
1000
1001
2
1000
1001
2
1000
1001
2
1000
1001
2
1000
1001
2
1000
1001

input:

1
100000
1001 1000 1
1000
1001 1000 1
1000
1000 1001 1
1001
1001 1000 1
1000
1000 1001 1
1001
1000 1001 1
1001
1000 1001 1
1001
1001 1000 1
1000
1000 1001 1
1001
1001 1000 1
1000
1001 1000 1
1000
1000 1001 1
1001
1000 1001 1
1001
1001 1000 1
1000
1001 1000 1
1000
1000 1001 1
1001
1000 1001 1
1001
10...

output:

1000
1000
1001
1000
1001
1001
1001
1000
1001
1000
1000
1001
1001
1000
1000
1001
1001
1001
1001
1000
1000
1000
1000
1001
1000
1001
1001
1000
1000
1001
1001
1001
1001
1001
1000
1000
1000
1000
1000
1000
1001
1000
1001
1001
1000
1001
1000
1001
1000
1001
1001
1001
1000
1000
1000
1000
1001
1000
1000
1000
...

result:

ok 

Test #42:

score: 10
Accepted
time: 88ms
memory: 3888kb

input:

0
10
3 1000000000
0 1
0 2
3 1000000000
0 1
0 2
3 1000000000
1 0
2 0
3 1000000000
1 0
0 2
3 1000000000
1 0
2 0
3 1000000000
1 0
2 0
3 1000000000
1 0
0 2
3 1000000000
1 0
2 0
3 1000000000
1 0
0 2
3 1000000000
0 1
0 2

output:

3
2000
1001
2002
3
2000
1001
2002
3
2000
1001
2002
3
2000
1001
2002
3
2000
1001
2002
3
2000
1001
2002
3
2000
1001
2002
3
2000
1001
2002
3
2000
1001
2002
3
2000
1001
2002

input:

1
75040
2002 1001 1
2000
2002 2000 1
2000
1001 2000 1
2000
2000 2002 2
1001
2002
1001 2002 1
2000
1001 2000 1
2000
2000 2002 2
1001
2002
2002 2000 1
2000
1001 2002 1
2000
2000 2002 2
1001
2002
1001 2002 1
2000
2000 1001 2
1001
2002
2000 2002 2
1001
2002
2000 2002 2
1001
2002
2000 1001 2
1001
2002
10...

output:

2000
2000
2000
2002
2000
2000
2002
2000
2000
2002
2000
1001
2002
2002
1001
2000
2000
2002
2000
2000
2000
2002
2002
2000
1001
2000
2000
2000
2000
2000
2000
2002
2000
2000
2000
2000
2002
1001
2000
1001
2000
2000
1001
2000
2000
1001
2002
2000
2000
1001
1001
2000
2000
1001
2000
1001
1001
2002
2000
2000
...

result:

ok 

Test #43:

score: 10
Accepted
time: 80ms
memory: 4096kb

input:

0
10
4 1000000000
0 1
2 0
1 3
4 1000000000
0 1
0 2
3 1
4 1000000000
0 1
0 2
3 1
4 1000000000
0 1
0 2
1 3
4 1000000000
0 1
0 2
3 1
4 1000000000
0 1
0 2
1 3
4 1000000000
0 1
0 2
3 1
4 1000000000
0 1
0 2
3 1
4 1000000000
1 0
0 2
1 3
4 1000000000
0 1
2 0
3 1

output:

4
3000
2001
3003
2002
4
3000
2001
3003
2002
4
3000
2001
3003
2002
4
3000
2001
3003
2002
4
3000
2001
3003
2002
4
3000
2001
3003
2002
4
3000
2001
3003
2002
4
3000
2001
3003
2002
4
3000
2001
3003
2002
4
3000
2001
3003
2002

input:

1
66554
2001 2002 2
2002
3000
3000 2002 2
2001
3003
3003 2001 1
3000
2002 2001 1
2001
3003 2002 1
3000
3000 3003 2
2001
3003
2002 2001 1
2001
2001 2002 2
2002
3000
3003 3000 1
3000
3003 2001 1
3000
2002 2001 1
2001
2002 2001 1
2001
2001 3000 2
2002
3000
2001 3000 2
2002
3000
2001 3003 2
2002
3000
30...

output:

2002
2001
3000
2001
3000
3003
2001
2002
3000
3000
2001
2001
3000
3000
3000
3000
3000
3000
3000
3003
2001
3000
3000
2002
3000
2001
3000
2001
3003
2001
2001
3000
3000
3000
2001
2002
2001
2002
3000
3000
3000
2001
3000
2001
3000
2001
2001
2001
3000
3003
2001
3000
3003
2001
3000
3003
2002
2001
2001
3000
...

result:

ok 

Test #44:

score: 0
Wrong Answer
time: 0ms
memory: 3832kb

input:

0
10
7 1000000000
5 3
6 3
0 3
4 3
1 3
2 3
7 1000000000
3 0
4 0
5 0
1 0
2 0
6 0
7 1000000000
4 0
2 0
3 0
6 0
1 0
5 4
7 1000000000
4 1
0 1
5 1
3 1
2 1
6 4
7 1000000000
3 1
2 1
5 1
4 1
6 1
0 3
7 1000000000
6 3
1 3
0 3
2 3
4 6
5 6
7 1000000000
5 0
4 0
3 0
2 0
6 5
1 5
7 1000000000
0 1
6 1
5 1
3 1
4 0
2 0...

output:

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

input:

1
420
2 4 3
0
1
5
4 1 1
5
1 3 2
0
6
3 6 1
5
3 5 1
6
0 5 1
2
1 2 1
3
1 5 1
2
2 3 1
5
4 3 5
0
1
2
3
5
2 6 1
5
6 5 1
5
5 6 5
1
2
3
4
6
0 4 1
1
0 1 1
3
0 4 1
5
3 1 1
5
2 5 1
4
1 6 1
6
2 4 1
3
4 3 1
6
5 2 2
4
6
5 0 1
6
6 0 5
1
2
3
4
5
0 3 1
6
1 4 1
4
2 1 1
5
6 0 1
5
1 2 2
0
6
4 6 5
0
1
2
3
5
5 4 1
6
6 3 ...

output:

5
5
6
5
6
2
3
2
5
3
5
5
6
1
3
5
5
4
6
3
6
4
6
1
6
4
5
5
6
5
6
3
5
6
4
6
1
6
1
1
5
2
4
1
3
6
2
6
3
6
4
4
3
6
6
6
0
6
6
4
5
4
6
5
6
6
6
5
1
5
4
6
0
5
2
3
6
5
6
5
2
4
4
3
3
6
6
5
1
5
4
4
5
6
3
2
6
6
3
6
5
5
6
5
6
5
4
6
3
6
6
5
0
4
6
1
2
6
6
6
5
2
2
6
4
1
4
4
6
1
4
4
3
2
2
5
5
6
1
2
6
6
6
5
6
5
1
2
5
6
...

result:

wrong answer Diff at 210-th number: read 2 but expected 6

Subtask #5:

score: 0
Wrong Answer

Test #54:

score: 0
Wrong Answer
time: 2ms
memory: 3736kb

input:

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

output:

996
995
510
994
254
509
765
993
126
253
381
508
637
764
892
992
62
125
189
252
317
380
444
507
573
636
700
763
828
891
955
991
30
61
93
124
157
188
220
251
285
316
348
379
412
443
475
506
541
572
604
635
668
699
731
762
796
827
859
890
923
954
975
990
14
29
45
60
77
92
108
123
141
156
172
187
204
21...

input:

1
-1
0

output:


result:

wrong output format Unexpected end of file - int32 expected