QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#372248#2552. PointsEcec243AC ✓160ms82996kbC++232.2kb2024-03-31 07:01:322024-03-31 07:01:33

Judging History

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

  • [2024-03-31 07:01:33]
  • 评测
  • 测评结果:AC
  • 用时:160ms
  • 内存:82996kb
  • [2024-03-31 07:01:32]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

#define mkp(x,y) make_pair(x,y)
#define pii pair<int,int>
#define lch (w<<1)
#define rch (w<<1|1)

const int N = (250020);
const int KEY = N * 2;
const int INF = N * 2;  //

int n;
multiset<pii> multibar[2][KEY];
struct rec{
   int ux, uy, vx, vy;
   int ans;
}tr[KEY<<2];

void update(int w, int l, int r, int key) {
   if (l == r) {
      if(!multibar[0][key].empty()){
        tr[w].ux = multibar[0][key].begin()->first;
        tr[w].uy = multibar[0][key].begin()->second; //
      }
      else tr[w].ux = tr[w].uy = INF;  //
      if(!multibar[1][key].empty()){
        tr[w].vx = multibar[1][key].begin()->first;
        tr[w].vy = multibar[1][key].begin()->second;
      }
      else tr[w].vx = tr[w].vy = INF;
      tr[w].ans = min(tr[w].vx+tr[w].ux, tr[w].uy+tr[w].vy); //
      tr[w].ans = min(tr[w].ans, INF);
      return;
   }
   int mid = (l + r)/2;
   if (key > mid) update(rch, mid+1, r, key);
     else update(lch, l, mid, key);
   tr[w].ux = min(tr[lch].ux, tr[rch].ux);  
   tr[w].uy = min(tr[lch].uy, tr[rch].uy);  
   tr[w].vx = min(tr[lch].vx, tr[rch].vx);  
   tr[w].vy = min(tr[lch].vy, tr[rch].vy);  
   tr[w].ans = min(tr[lch].ans, tr[rch].ans);
   tr[w].ans = min(tr[w].ans, min(tr[lch].vx + tr[rch].ux, tr[lch].uy + tr[rch].vy));
   return;
}

void build(int w, int l, int r){
   tr[w].ux = tr[w].uy = tr[w].vx = tr[w].vy = tr[w].ans = INF; 
   if (l == r) return;
   int mid = (l+r)/2;
   build(lch,l,mid);
   build(rch,mid+1,r);
   return;
}

inline int rd()
{
    int sign = 1, re = 0; char c = getchar();
    while(!isdigit(c)){if(c == '-') sign = -1; c = getchar();}
    while(isdigit(c)){re = re * 10 + (c - '0'); c = getchar();}
    return sign * re;
}

int main(){
    n = rd();
    build(1,0,KEY-1);
    for (int i = 1;i <= (n);++ i)
    {
        int ty = rd(), st = rd(), x = rd(), y = rd(); -- st; //
        int key = (st == 0)?x-y:y-x; key += N;
        if (ty == 1) multibar[st][key].insert(mkp(x,y));
          else multibar[st][key].erase(multibar[st][key].find(mkp(x,y)));
        update(1,0,KEY-1,key);
        printf("%d\n",(tr[1].ans == INF)?-1:tr[1].ans); //
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 8ms
memory: 71284kb

input:

6
1 1 100 100
1 2 30 130
1 1 120 170
2 1 100 100
1 2 70 100
2 1 120 170

output:

-1
230
230
300
270
-1

result:

ok 6 numbers

Test #2:

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

input:

1
1 1 1 1

output:

-1

result:

ok 1 number(s): "-1"

Test #3:

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

input:

500
1 1 222895 235626
1 1 67425 11081
1 2 96797 128675
1 1 220342 126964
1 2 51204 205285
1 2 166357 220580
1 1 104596 78785
1 1 232951 219082
1 1 228704 168809
1 1 8711 14221
1 1 205792 88129
1 2 137469 69368
1 1 48262 106488
1 2 3364 119121
1 1 38013 177666
1 1 47611 45197
1 1 106030 118375
1 2 88...

output:

-1
-1
164222
164222
164222
164222
164222
164222
164222
142896
142896
142896
142896
130202
130202
130202
130202
130202
130202
130202
130202
130202
130202
130202
30524
30524
30524
30524
30524
30524
30524
30524
30524
30524
30524
30524
30524
30524
30524
30524
30524
30524
30524
30524
30524
30524
30524
30...

result:

ok 500 numbers

Test #4:

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

input:

500
1 2 156512 200248
1 2 83628 71722
1 1 175886 89641
1 2 228410 207291
1 1 55754 35777
1 1 92012 77308
1 1 193756 100116
1 1 75379 249988
1 1 75836 187695
1 1 174085 21655
1 1 240070 181160
1 2 21475 189128
1 2 173013 159383
1 2 128936 128079
1 2 180285 160430
1 1 186528 45628
1 2 34903 121407
1 1...

output:

-1
-1
259514
259514
139382
139382
139382
139382
139382
139382
139382
139382
139382
139382
139382
139382
139382
139382
125994
125994
125994
125994
125994
125994
125994
125994
125994
125994
125994
125994
125994
125994
125994
125994
125994
125994
125994
125994
125994
125994
125994
125994
125994
125994
...

result:

ok 500 numbers

Test #5:

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

input:

500
1 1 163855 68630
1 1 75900 230957
1 2 77433 172447
1 2 111682 185609
1 2 156941 219664
1 2 238581 97140
1 2 56903 140113
1 1 24437 4306
1 2 204104 57771
1 1 138002 21346
1 2 183531 59829
1 1 129097 177736
1 2 26008 106291
1 2 144395 174230
1 2 148992 26986
1 2 158315 139853
1 1 139733 145193
1 2...

output:

-1
-1
241288
241288
241288
241288
220758
144419
144419
144419
144419
144419
110597
110597
110597
110597
110597
71703
71703
71703
71703
71703
71703
71703
71703
71703
71703
71703
71703
71703
71703
71703
71703
71703
71703
71703
71703
71703
71703
68930
68930
68930
68930
68930
68930
68930
68930
68930
689...

result:

ok 500 numbers

Test #6:

score: 0
Accepted
time: 8ms
memory: 71220kb

input:

5000
1 1 189391 74142
1 1 127554 108145
1 2 7520 35014
1 2 22014 84961
1 1 202614 2032
1 1 65070 178674
1 2 140104 205662
1 1 134778 243678
1 2 23613 88600
1 2 67706 220660
1 1 192832 230661
1 2 85323 77049
1 1 151450 210167
1 1 139271 5665
1 1 172346 205854
1 1 38719 114443
1 2 195123 206866
1 1 46...

output:

-1
-1
143159
143159
143159
143159
143159
143159
143159
143159
143159
143159
143159
143159
143159
143159
143159
54477
54477
54477
54477
54477
54477
54477
54477
54477
54477
54477
54477
54477
54477
54477
54477
54477
54477
35229
35229
35229
35229
35229
35229
35229
35229
35229
35229
35229
35229
35229
352...

result:

ok 5000 numbers

Test #7:

score: 0
Accepted
time: 8ms
memory: 71372kb

input:

5000
1 1 53976 195181
1 1 186475 218606
1 1 71077 94152
1 1 87896 85066
1 1 56010 8017
1 2 63908 54276
1 1 205734 24293
1 2 22837 82262
1 2 26563 222664
1 1 164335 6213
1 2 109349 167435
1 1 177377 30997
1 1 136387 107199
1 1 123890 147579
1 2 66251 141768
1 1 120574 61457
1 1 144050 32459
1 2 11494...

output:

-1
-1
-1
-1
-1
119918
119918
90279
90279
90279
90279
90279
90279
90279
90279
90279
90279
90279
90279
90279
90279
90279
90279
90279
90279
90279
90279
90279
90279
90279
90279
90279
90279
90279
68666
68666
68666
43583
43583
43583
43583
43583
43583
43583
43583
43583
43583
43583
43583
43583
43583
43583
4...

result:

ok 5000 numbers

Test #8:

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

input:

5000
1 2 118549 98237
1 1 130148 75606
1 1 30856 75540
1 2 85539 77251
1 2 73215 160002
1 1 105256 150437
1 2 31882 138629
1 2 94536 210352
1 2 160206 117346
1 1 240982 45666
1 2 216408 241055
1 2 165430 157595
1 2 51336 29545
1 1 210826 52291
1 2 103590 73868
1 1 80389 140338
1 1 101660 245247
1 2 ...

output:

-1
248697
173777
152791
152791
152791
152791
152791
152791
152791
152791
152791
105085
105085
105085
105085
105085
105085
105085
105085
105085
105085
105085
67867
67867
67867
67867
67867
67867
67867
60599
60599
60599
60599
60599
60599
60599
60599
60599
60599
60599
60599
60599
60599
60599
60599
60599...

result:

ok 5000 numbers

Test #9:

score: 0
Accepted
time: 12ms
memory: 71496kb

input:

10000
1 2 195812 228465
1 1 10656 207362
1 1 228284 210851
1 1 86126 170836
1 1 175936 145479
1 2 114934 122004
1 2 120298 128079
1 2 186991 170156
1 1 145764 9076
1 2 132691 145761
1 2 204320 122544
1 2 133890 8682
1 2 47597 238360
1 1 77290 46707
1 2 69361 97411
1 1 180749 186128
1 2 104831 132328...

output:

-1
435827
435827
399301
373944
290870
290870
290870
260698
260698
260698
216044
216044
192224
146651
146651
146651
146651
146651
146651
146651
146651
146651
146651
146651
146651
146651
146651
146651
146651
146651
146651
96835
96835
96835
96835
96835
96835
96835
96835
96835
96835
96835
96835
96835
96...

result:

ok 10000 numbers

Test #10:

score: 0
Accepted
time: 14ms
memory: 71488kb

input:

10000
1 1 53521 139157
1 1 219705 182473
1 1 58391 85953
1 1 143631 152040
1 1 203823 202271
1 1 177407 204743
1 1 204386 99982
1 2 90624 87664
1 2 158626 140066
1 2 189170 91011
1 1 98339 195783
1 2 162367 225840
1 1 6212 137612
1 2 16095 139630
1 1 46246 160598
1 1 76870 42275
1 1 15142 159900
1 1...

output:

-1
-1
-1
-1
-1
-1
-1
173617
173617
173617
173617
173617
173617
173617
173617
167494
167494
167494
167494
159463
159463
159463
159463
159463
159463
159463
159463
159463
159463
159463
159463
125466
125466
125466
125466
125466
125466
125466
125466
125466
125466
125466
125466
125466
125466
125466
125466...

result:

ok 10000 numbers

Test #11:

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

input:

10000
1 2 123534 23590
1 2 73236 67531
1 1 130620 174996
1 1 225193 45338
1 1 223730 135562
1 2 6592 173104
1 1 12864 109482
1 1 145241 115474
1 1 244489 95717
1 1 213425 120819
1 1 46236 4136
1 2 46299 42022
1 2 43098 37832
1 1 120402 45519
1 1 33251 187501
1 1 110688 105033
1 2 61767 201745
1 1 16...

output:

-1
-1
242527
242527
242527
231785
136398
136398
136398
136398
119472
92535
89334
89334
89334
89334
89334
89334
89334
89334
89334
89334
89334
89334
89334
89334
89334
89334
89334
89334
89334
89334
89334
89334
89334
89334
89334
89334
89334
75778
75778
75778
75778
75778
75778
75778
75778
75778
75778
757...

result:

ok 10000 numbers

Test #12:

score: 0
Accepted
time: 16ms
memory: 71508kb

input:

10000
1 2 147850 66866
1 1 187127 49506
1 2 244604 233286
1 1 88516 6927
1 1 43352 249581
1 2 186744 236053
1 2 130980 195171
1 2 16857 123185
1 1 127982 95061
1 2 203031 19733
1 1 147895 151868
1 1 152734 74626
1 2 149508 241099
1 2 144896 183295
1 2 15754 122625
1 2 91631 33741
1 2 193981 73377
1 ...

output:

-1
334977
334977
236366
236366
236366
219496
130112
130112
130112
130112
130112
130112
130112
129552
129552
129552
129552
129552
129552
129552
129552
129552
129552
129552
129552
129552
129552
71143
71143
69500
69500
69500
69500
66722
66722
66722
66722
66722
66722
66722
66722
66722
66722
66722
66722
...

result:

ok 10000 numbers

Test #13:

score: 0
Accepted
time: 12ms
memory: 71488kb

input:

10000
1 2 137953 13969
1 2 61174 13752
1 1 70449 35357
1 1 33394 42314
1 1 174021 205792
1 1 92175 51245
1 2 212662 152204
1 2 249804 16377
1 2 200330 24867
1 2 114736 105534
1 1 213383 42932
1 1 176443 149929
1 1 247986 205172
1 1 9806 143133
1 2 75298 22639
1 1 146033 64006
1 2 93565 175795
1 2 16...

output:

-1
-1
131623
94568
94568
94568
94568
94568
94568
94568
94568
94568
94568
94568
94568
94568
94568
94568
94568
94568
94568
78887
78887
78887
78887
78887
78887
78887
78887
78887
78887
43839
43839
43839
43839
43839
43839
43839
43839
43839
43839
43839
43839
43839
43839
43839
43839
43839
43839
16569
16569...

result:

ok 10000 numbers

Test #14:

score: 0
Accepted
time: 155ms
memory: 82820kb

input:

250000
1 1 1845 179115
1 1 70191 106235
1 1 199382 69999
1 2 99836 13834
1 1 140032 14127
1 1 232493 17723
1 1 144614 96583
1 2 141144 237927
1 1 164474 237268
1 1 208202 221945
1 2 15863 114098
1 1 124182 52945
1 2 1336 198229
1 2 183154 69640
1 1 123755 105109
1 1 201687 52737
1 2 48612 147636
1 2...

output:

-1
-1
-1
170027
170027
170027
170027
170027
170027
170027
155895
155895
155895
155895
155895
155895
155895
155895
155895
148213
148213
148213
148213
148213
148213
148213
134805
75997
75997
61202
61202
61202
61202
61202
61202
61202
61202
61202
61202
61202
61202
61202
61202
61202
61202
61202
61202
612...

result:

ok 250000 numbers

Test #15:

score: 0
Accepted
time: 156ms
memory: 82872kb

input:

250000
1 2 29096 116498
1 2 80673 31974
1 1 174636 27060
1 1 168166 41123
1 1 203939 148921
1 1 187891 177967
1 2 220365 129051
1 2 215732 177797
1 1 23120 156937
1 1 231335 10650
1 1 96375 53742
1 2 178072 34206
1 1 231105 245662
1 2 162442 224111
1 2 150868 108902
1 2 39120 134142
1 2 56699 164950...

output:

-1
-1
203732
197262
197262
197262
197262
197262
188911
188911
170240
170240
170240
170240
170240
170240
170240
170240
170240
170240
170240
119634
98691
98691
98691
98691
98691
98691
76197
76197
76197
76197
76197
76197
72445
58759
27755
27755
27755
27755
27755
27755
27755
27755
27755
27755
27755
2775...

result:

ok 250000 numbers

Test #16:

score: 0
Accepted
time: 139ms
memory: 82876kb

input:

250000
1 2 6462 105400
1 1 139403 7596
1 2 198139 184239
1 2 236496 166546
1 2 67729 235466
1 2 43521 187977
1 2 46115 163153
1 1 40320 19535
1 2 81884 76605
1 2 156335 147489
1 2 128637 243387
1 2 31844 15468
1 2 111106 43093
1 1 91846 230565
1 1 26114 14562
1 1 224686 15431
1 1 63151 134014
1 2 66...

output:

-1
145865
145865
145865
145865
145865
145865
124935
122204
122204
122204
72164
72164
72164
57958
57958
57958
57958
57958
57958
57958
57958
57958
57958
57958
57958
57958
57958
57958
57958
57958
38190
38190
38190
38190
38190
38190
38190
38190
38190
38190
38190
38190
38190
38190
38190
38190
38190
38190...

result:

ok 250000 numbers

Test #17:

score: 0
Accepted
time: 148ms
memory: 82996kb

input:

250000
1 1 33713 44417
1 2 149884 183335
1 2 173393 139665
1 1 54825 193836
1 2 130001 120258
1 1 199036 246237
1 2 171750 195621
1 1 163158 9289
1 2 142282 246274
1 2 179467 186195
1 1 9031 134781
1 2 37484 246730
1 1 42626 40642
1 2 21249 36902
1 2 53227 18355
1 2 62118 98472
1 2 121122 101444
1 2...

output:

-1
227752
207106
207106
164675
164675
164675
164675
164675
164675
164675
164675
164675
77544
77544
77544
77544
77544
77544
77544
77544
77544
77544
77544
77544
77544
77544
77544
77544
77544
77544
77544
77544
77544
77544
77544
77544
77544
77544
77544
77544
77544
77544
77544
77544
77544
77544
77544
775...

result:

ok 250000 numbers

Test #18:

score: 0
Accepted
time: 157ms
memory: 82868kb

input:

250000
1 1 11080 233436
1 2 160366 207207
1 2 196896 46842
1 2 123155 119141
1 1 243793 206803
1 2 102915 206363
1 1 247501 228089
1 2 237747 149277
1 1 929 165943
1 1 152716 24784
1 1 39658 24541
1 1 141258 179743
1 1 222512 38190
1 2 200654 43356
1 1 128590 22147
1 1 247684 179877
1 1 177458 11875...

output:

-1
440643
280278
280278
280278
280278
280278
280278
212785
212785
162813
162813
162813
162813
162813
162813
162813
162813
162813
162813
162813
162813
162813
103582
103582
103582
103582
103582
96048
96048
96048
96048
96048
96048
96048
96048
95972
95972
95972
95972
95972
95972
95972
95972
95972
95972
...

result:

ok 250000 numbers

Test #19:

score: 0
Accepted
time: 143ms
memory: 80044kb

input:

250000
1 2 206785 242457
1 1 80625 21218
1 1 211812 242602
1 1 95388 125892
1 2 136200 239254
1 1 173681 47002
1 2 165162 135532
1 2 142692 47861
1 2 101667 157196
1 2 110389 115434
1 1 126781 56211
1 1 146852 83739
1 1 8120 24454
1 2 239438 169028
1 1 76681 55314
1 1 18861 187962
1 2 61677 35080
1 ...

output:

-1
287410
287410
287410
260472
260472
245787
223317
182292
182292
182292
182292
139888
139888
139888
139888
69797
69797
69797
69797
69797
69797
69797
69797
69797
69797
69797
69797
69797
69797
69797
69797
69797
69797
69797
69797
69797
69797
69797
69797
69797
69797
69797
69797
69797
69797
69797
69797
...

result:

ok 250000 numbers

Test #20:

score: 0
Accepted
time: 147ms
memory: 77696kb

input:

250000
1 2 45933 101488
1 2 174185 186327
1 1 236923 190202
1 2 30560 124040
1 2 215047 42211
1 1 61028 174004
1 2 122965 63090
1 2 129986 204607
1 1 247398 138715
1 2 143300 191873
1 2 150809 219439
1 1 134478 182927
1 2 182327 18988
1 2 23675 79301
1 2 66096 35836
1 1 122459 151729
1 2 53860 10048...

output:

-1
-1
291690
291690
291690
275492
237094
237094
237094
237094
237094
237094
237094
237094
209840
188555
188555
188555
188555
188555
188555
188555
188555
188555
109774
109774
109774
109774
109774
109774
109774
109774
109774
109774
109774
109774
109774
109774
109774
109774
109774
109774
109774
109774
...

result:

ok 250000 numbers

Test #21:

score: 0
Accepted
time: 143ms
memory: 79460kb

input:

250000
1 1 71530 118174
1 2 248215 24855
1 1 3215 159332
1 1 121306 184252
1 1 137698 243153
1 1 237038 184221
1 2 116486 40325
1 2 196838 198747
1 2 43522 235259
1 1 234969 137059
1 1 213413 232830
1 1 79215 248310
1 2 158579 208294
1 1 115554 199503
1 2 21288 111767
1 1 23075 124363
1 2 51260 4348...

output:

-1
319745
251430
251430
251430
251430
188016
188016
188016
188016
188016
188016
188016
188016
188016
164688
161657
149160
149160
149160
149160
149160
149160
129053
129053
129053
129053
129053
129053
129053
129053
129053
129053
129053
129053
129053
129053
129053
129053
129053
105068
105068
105068
105...

result:

ok 250000 numbers

Test #22:

score: 0
Accepted
time: 146ms
memory: 76060kb

input:

250000
1 1 12074 202598
1 1 47930 79633
1 2 61125 206956
1 2 10196 181837
1 2 77570 220751
1 1 128767 164922
1 2 32712 103440
1 1 154482 65910
1 1 195681 46629
1 1 166381 59120
1 2 157638 204984
1 1 214904 167929
1 2 27893 178552
1 2 35844 91546
1 2 171525 120880
1 1 13381 97059
1 2 242410 184608
1 ...

output:

-1
-1
286589
261470
261470
261470
183073
183073
183073
183073
183073
183073
183073
171179
171179
171179
171179
171179
171179
171179
127642
127642
127642
127642
127642
127642
127642
121779
121779
121779
121779
121779
121779
121779
121779
121779
121779
121779
121779
121779
121779
53458
53458
53458
534...

result:

ok 250000 numbers

Test #23:

score: 0
Accepted
time: 153ms
memory: 77768kb

input:

250000
1 1 4993 1350
1 2 144606 130814
1 2 226675 114606
1 1 207344 58039
1 2 76534 189930
1 1 141705 117501
1 1 103192 94899
1 1 184860 234134
1 2 21735 34552
1 1 154434 140576
1 1 100839 64718
1 1 7639 218813
1 1 29890 229949
1 1 144830 75597
1 1 20268 119947
1 2 41860 136197
1 1 150274 168535
1 1...

output:

-1
149599
149599
149599
149599
149599
149599
149599
35902
35902
35902
35902
35902
35902
35902
35902
35902
35902
35902
35902
35902
35902
35902
35902
35902
35902
35902
35902
35902
35902
35902
35902
35902
35902
35902
35902
35902
35902
35902
35902
35902
35902
35902
35902
35902
35902
35902
35902
35902
35...

result:

ok 250000 numbers

Test #24:

score: 0
Accepted
time: 155ms
memory: 79732kb

input:

250000
1 2 121577 183032
1 2 164967 42869
1 1 98975 64630
1 2 195166 137782
1 1 133184 195843
1 2 13390 156996
1 1 192123 158040
1 2 173723 175388
1 2 205134 184929
1 1 220885 91859
1 1 63643 184914
1 1 10104 103945
1 1 10282 224883
1 1 49900 87057
1 1 194308 59597
1 1 48952 96807
1 1 112861 150899
...

output:

-1
-1
247662
247662
247662
221626
221626
221626
221626
221626
221626
175071
175071
175071
175071
175071
175071
175071
175071
175071
175071
175071
175071
175071
175071
175071
175071
175071
175071
175071
175071
175071
175071
175071
175071
175071
175071
175025
157611
157611
157611
103004
103004
103004
...

result:

ok 250000 numbers

Test #25:

score: 0
Accepted
time: 150ms
memory: 76988kb

input:

250000
1 1 127650 118275
1 2 130553 204958
1 2 56666 72972
1 1 104697 92183
1 1 213351 81960
1 2 60743 169131
1 2 237940 215982
1 1 192081 199182
1 1 122828 158138
1 2 131264 117535
1 1 17639 220670
1 1 215730 218170
1 1 156685 36702
1 2 27360 154837
1 1 103518 19912
1 2 53376 231865
1 1 230421 3327...

output:

-1
323233
191247
165155
165155
165155
165155
165155
165155
165155
165155
165155
165155
165155
160184
160184
160184
160184
160184
160184
160184
160184
160184
160184
160184
160184
160184
160184
160184
160184
160184
92769
92769
92769
92769
92769
51228
51228
51228
51228
51228
51228
51228
51228
51228
512...

result:

ok 250000 numbers

Test #26:

score: 0
Accepted
time: 152ms
memory: 78984kb

input:

250000
1 2 180116 58075
1 2 127161 148633
1 2 24975 43360
1 2 4636 90642
1 1 235065 98192
1 1 200899 157163
1 1 192853 27404
1 2 194298 166979
1 2 190575 149433
1 2 46104 35291
1 2 200608 56604
1 2 183974 59864
1 1 209742 60671
1 1 196736 46442
1 2 195028 221883
1 1 216181 96701
1 1 130380 126758
1 ...

output:

-1
-1
-1
-1
239701
225874
197489
197489
197489
197489
197489
197489
197489
197489
197489
197489
170118
170118
170118
130922
130922
130922
130922
130922
130922
130922
130922
130922
130922
130922
130922
130922
130922
130922
130922
130922
130922
130922
130922
130922
130922
130922
130922
130922
130922
1...

result:

ok 250000 numbers

Test #27:

score: 0
Accepted
time: 147ms
memory: 75324kb

input:

250000
1 2 137181 63586
1 2 42980 22348
1 1 209380 31102
1 1 101238 223599
1 1 164196 201712
1 1 246833 178962
1 2 82997 55160
1 2 40687 207770
1 2 151274 205323
1 1 119269 6788
1 1 88400 165577
1 1 166974 141731
1 2 187550 3137
1 1 144377 137924
1 1 66756 73817
1 1 35276 157271
1 1 239293 152738
1 ...

output:

-1
-1
252360
245947
224060
224060
224060
224060
224060
162249
162249
162249
162249
162249
109736
109736
109736
109736
109736
109736
54282
54282
54282
54282
54282
54282
54282
54282
54282
54282
54282
54282
54282
54282
54282
54282
54282
54282
54282
54282
54282
54282
54282
54282
54282
54282
54282
54282
...

result:

ok 250000 numbers

Test #28:

score: 0
Accepted
time: 137ms
memory: 75120kb

input:

250000
1 1 17649 168143
1 2 237483 123929
1 2 65561 208632
1 2 80167 128047
1 2 241113 33248
1 2 20957 61936
1 2 44948 162522
1 2 75282 209796
1 2 54591 104719
1 2 242293 159312
1 2 4979 7029
1 2 89588 190930
1 2 7234 206056
1 2 77414 239264
1 1 134603 45659
1 1 170371 116770
1 2 12310 91918
1 2 194...

output:

-1
292072
292072
292072
258762
230079
230079
230079
230079
230079
175172
175172
175172
175172
139582
139582
139582
139582
139582
30907
30907
30907
30907
30907
30907
30907
30907
30907
30907
30907
30907
30907
30907
30907
30907
30907
30907
30907
30907
30907
30907
30907
30907
30907
30907
30907
30907
309...

result:

ok 250000 numbers

Test #29:

score: 0
Accepted
time: 152ms
memory: 76776kb

input:

250000
1 2 132818 52291
1 1 52401 112198
1 1 180000 131357
1 2 37840 242020
1 2 140705 49097
1 2 187497 55195
1 1 240312 215313
1 1 230366 90114
1 2 208649 129879
1 2 85267 119533
1 1 139499 40646
1 2 222634 28390
1 1 99213 86366
1 1 81890 50397
1 1 94980 158035
1 1 18811 84028
1 2 56703 66502
1 2 1...

output:

-1
185219
185219
185219
185219
185219
185219
185219
185219
185219
185219
185219
185219
169930
169930
151629
138593
138593
138593
120680
120680
120680
120680
120680
120680
120680
120680
120680
120680
104417
104417
104417
104417
104417
104417
104417
104417
104417
104417
104417
104417
104417
104417
104...

result:

ok 250000 numbers

Test #30:

score: 0
Accepted
time: 147ms
memory: 79856kb

input:

250000
1 2 6254 235945
1 2 141436 116771
1 2 202109 219553
1 2 159592 210702
1 2 122717 246669
1 2 182128 139345
1 1 158683 243434
1 1 246597 58842
1 2 52159 228811
1 1 238553 161577
1 2 127072 37701
1 1 201524 136696
1 2 67710 212890
1 2 218504 132668
1 2 37963 44055
1 2 190615 47703
1 2 118631 182...

output:

-1
-1
-1
-1
-1
-1
360205
294787
294787
294787
285755
285755
285755
285755
239487
239487
239487
239487
227045
227045
227045
183983
183983
183983
183983
183983
183983
183983
183983
183983
171933
171933
171933
171933
171933
171933
132775
132775
132775
132775
132775
132775
132775
132775
132775
89326
893...

result:

ok 250000 numbers

Test #31:

score: 0
Accepted
time: 147ms
memory: 76312kb

input:

250000
1 2 198280 230767
1 1 199912 76239
1 2 155511 89830
1 2 80192 39868
1 1 140217 222005
1 1 221428 76200
1 1 206593 4361
1 2 32710 54899
1 1 68547 216495
1 1 103906 62925
1 2 238248 15005
1 1 16941 221159
1 1 10437 142017
1 2 169506 237178
1 1 113135 19228
1 1 184790 6584
1 1 198582 42232
1 2 1...

output:

-1
398192
355423
280104
261873
261873
261873
232622
232622
136616
136616
136616
136616
136616
136616
136616
136616
136616
136616
132402
132402
132402
132402
132402
132402
132402
132402
132402
132402
132402
132402
132402
132402
132402
132402
132402
132402
132402
132402
132402
132402
132402
132402
132...

result:

ok 250000 numbers

Test #32:

score: 0
Accepted
time: 143ms
memory: 78400kb

input:

250000
1 2 204862 43746
1 1 169798 160862
1 2 227295 155057
1 2 165200 9272
1 2 91748 240604
1 2 35654 208210
1 2 154323 220798
1 2 215062 238362
1 2 215249 207216
1 2 120575 21058
1 1 206405 149024
1 1 131684 149610
1 2 232521 147095
1 1 89796 60118
1 1 175849 109344
1 2 75389 48683
1 1 27943 12604...

output:

-1
374660
374660
334998
334998
334998
334998
334998
334998
290373
290373
252259
252259
210371
210371
165185
148518
148518
148518
148518
148518
148518
148518
148518
148518
148518
148518
148518
148518
148518
148518
82704
82704
82704
82704
82704
82704
82704
82704
82704
74321
74321
50643
50643
50643
506...

result:

ok 250000 numbers

Test #33:

score: 0
Accepted
time: 143ms
memory: 79804kb

input:

250000
1 2 159307 50988
1 1 241149 47385
1 2 57375 13090
1 2 196482 209206
1 2 209800 6976
1 2 179382 124807
1 1 65136 136942
1 2 74078 89802
1 1 227803 36867
1 2 204439 239653
1 2 208731 104033
1 1 36671 168720
1 1 178622 249861
1 1 218008 29234
1 1 19114 197227
1 1 98691 55575
1 2 7234 20936
1 1 1...

output:

-1
400456
298524
298524
298524
298524
150032
150032
150032
150032
150032
150032
150032
150032
150032
150032
105925
105925
105925
105925
105925
105925
105925
105925
105925
105925
105925
105925
105925
35283
35283
35283
35283
35283
35283
35283
35283
35283
35283
35283
35283
35283
35283
35283
35283
35283...

result:

ok 250000 numbers

Test #34:

score: 0
Accepted
time: 134ms
memory: 75160kb

input:

250000
1 2 3501 211580
1 2 216220 204427
1 2 72129 213929
1 2 157440 3051
1 2 45389 190880
1 1 190361 249960
1 2 209939 85672
1 2 218157 111042
1 1 10041 100408
1 2 204740 154805
1 1 32981 30209
1 1 165432 23144
1 2 133875 223655
1 1 85803 68822
1 1 126585 140467
1 1 164562 181789
1 1 155234 151647
...

output:

-1
-1
-1
-1
-1
347801
347801
347801
167481
167481
167481
167481
167481
167481
167481
167481
167481
167481
167481
135531
135531
110962
110962
110962
110962
110962
110962
110962
110962
110962
110962
110962
110962
110962
110962
110962
110962
110962
110962
110962
110962
110962
70726
70726
70726
70726
70...

result:

ok 250000 numbers

Test #35:

score: 0
Accepted
time: 135ms
memory: 75240kb

input:

250000
1 2 121464 68506
1 2 206824 246686
1 1 124785 199502
1 1 241158 22024
1 1 2202 136096
1 1 194278 243425
1 2 84733 153259
1 2 59211 109537
1 1 164761 221097
1 1 63825 51585
1 1 145651 47763
1 2 131048 110553
1 2 150071 186305
1 1 149743 112513
1 2 93678 206136
1 1 126269 173307
1 1 60126 83303...

output:

-1
-1
268008
268008
204602
204602
204602
204602
204602
161122
161122
161122
161122
161122
161122
161122
161122
161122
161122
161122
161122
161122
161122
161122
161122
117059
117059
117059
117059
117059
117059
117059
117059
117059
117059
117059
117059
117059
117059
117059
117059
117059
117059
114422
...

result:

ok 250000 numbers

Test #36:

score: 0
Accepted
time: 146ms
memory: 74956kb

input:

250000
1 2 241060 207393
1 2 199409 92189
1 2 194784 199405
1 2 222249 236667
1 2 141136 126980
1 1 31071 104493
1 1 156539 129371
1 2 171530 243981
1 2 215956 75516
1 1 153404 131745
1 2 184241 152380
1 2 115847 240701
1 1 237279 139185
1 1 118173 122793
1 1 222848 74732
1 2 178132 114708
1 2 22040...

output:

-1
-1
-1
-1
-1
230480
230480
230480
230480
230480
230480
230480
230480
230480
230480
219201
219201
219201
219201
219201
219201
219201
219201
188896
113337
113337
113337
113337
113337
113337
113337
113337
113337
113337
113337
113337
113337
113337
113337
113337
113337
113337
113337
113337
113337
11333...

result:

ok 250000 numbers

Test #37:

score: 0
Accepted
time: 146ms
memory: 74244kb

input:

250000
1 1 145644 206923
1 1 238687 227059
1 2 156515 205269
1 2 208804 35205
1 1 116727 14433
1 2 224686 96917
1 2 142386 87616
1 2 33884 133041
1 1 150169 78500
1 2 979 215867
1 1 47620 229660
1 1 199247 110786
1 1 248074 93380
1 1 81985 152970
1 2 86524 144787
1 1 16097 172224
1 1 151781 238389
1...

output:

-1
-1
412192
354448
273242
273242
259113
150611
150611
150611
150611
150611
150611
150611
150611
150611
150611
150611
150611
150611
150611
150611
150611
120388
120388
120388
120388
120388
79686
79686
79686
79686
79686
79686
78041
78041
78041
78041
78041
78041
78041
78041
78041
78041
78041
78041
7804...

result:

ok 250000 numbers

Test #38:

score: 0
Accepted
time: 136ms
memory: 74812kb

input:

250000
1 1 191842 27168
1 1 124605 154607
1 1 10431 197330
1 2 115378 96137
1 2 229622 17512
1 2 134955 19281
1 1 206012 129747
1 1 193888 234764
1 2 116543 216793
1 1 31489 245164
1 1 107732 210831
1 1 161654 191940
1 2 11374 113926
1 1 141359 204172
1 2 191884 185578
1 1 234792 170175
1 2 158453 2...

output:

-1
-1
-1
250744
240053
216611
216611
216611
216611
216611
216611
216611
203216
203216
203216
203216
203216
199205
199205
199205
199205
199205
195604
131203
131203
131203
131203
131203
131203
131203
131203
131203
131203
131203
108122
108122
108122
108122
85956
85956
85956
85956
85956
85956
85956
8595...

result:

ok 250000 numbers

Test #39:

score: 0
Accepted
time: 128ms
memory: 74988kb

input:

250000
1 2 232179 169635
1 1 107278 28754
1 1 80563 68425
1 2 117294 160047
1 1 44986 97624
1 1 202603 34927
1 1 153693 112317
1 2 66466 13485
1 1 123510 111813
1 2 234891 237248
1 1 161119 15597
1 2 201239 42505
1 1 106694 224671
1 1 224906 154395
1 2 71462 99850
1 1 25172 164704
1 1 190538 165840
...

output:

-1
339457
312742
224572
224572
224572
224572
111452
111452
111452
111452
111452
111452
111452
111452
111452
111452
111452
111452
111452
111452
111452
111452
111452
111452
111452
111452
111452
111452
111452
111452
111452
111452
111452
98337
98337
98337
98337
91033
91033
91033
91033
91033
91033
91033
...

result:

ok 250000 numbers

Test #40:

score: 0
Accepted
time: 141ms
memory: 74124kb

input:

250000
1 2 144840 33581
1 2 49935 167574
1 1 81876 44029
1 2 82663 96570
1 2 143529 196419
1 1 100451 48105
1 1 12428 4609
1 2 234356 224593
1 2 75376 75039
1 1 179644 89338
1 1 91309 60463
1 2 9064 131088
1 2 75154 242327
1 1 152155 161154
1 1 173551 182376
1 1 145393 198186
1 1 126311 188051
1 1 2...

output:

-1
-1
211603
164539
164539
164539
101179
101179
87804
87804
87804
87804
87804
87804
87804
87804
87804
87804
87804
87804
87804
87804
87804
87804
87804
87804
87804
87804
87804
87804
42788
42788
42788
42788
42788
42788
42788
42788
42788
42788
42788
42788
42788
42788
42788
42788
42788
42788
42788
42788
...

result:

ok 250000 numbers

Test #41:

score: 0
Accepted
time: 139ms
memory: 75332kb

input:

250000
1 2 10341 198263
1 1 119111 132018
1 2 200195 73544
1 2 124276 92708
1 1 214130 80479
1 2 161582 118311
1 1 43696 78435
1 2 6663 88043
1 1 9234 115964
1 2 167191 86586
1 2 81335 6111
1 2 195213 209641
1 2 201857 249121
1 1 128141 231696
1 1 63930 132810
1 2 108458 149670
1 1 243713 103607
1 1...

output:

-1
330281
319306
243387
243387
243387
171143
166478
166478
166478
122075
122075
122075
122075
122075
122075
122075
122075
122075
122075
122075
122075
122075
122075
122075
122075
122075
122075
111751
111751
83746
83746
83746
83746
83746
83746
83746
83746
83746
83746
83746
83746
83746
83746
83746
8374...

result:

ok 250000 numbers

Test #42:

score: 0
Accepted
time: 149ms
memory: 74532kb

input:

250000
1 2 177151 118218
1 1 100302 167570
1 1 135173 175987
1 2 173681 41264
1 1 24799 151421
1 1 6234 47971
1 2 97342 219294
1 1 215638 186578
1 2 208096 41288
1 2 190204 22469
1 1 177841 12862
1 2 95760 199051
1 1 203873 155474
1 2 187111 202668
1 1 144371 83953
1 1 93 71609
1 1 15527 165406
1 1 ...

output:

-1
285788
285788
273983
198480
179915
179915
179915
179915
179915
179915
179915
179915
179915
179915
173774
173774
173774
173774
173774
173774
173774
173774
173774
173774
173774
173774
173774
173774
173774
173774
173774
173774
173774
173774
173774
173774
135163
135163
135163
135163
135163
135163
135...

result:

ok 250000 numbers

Test #43:

score: 0
Accepted
time: 137ms
memory: 74928kb

input:

250000
1 2 225025 54141
1 2 83604 169205
1 1 22002 190651
1 2 56731 31142
1 1 224711 175761
1 1 200099 148298
1 2 195081 122999
1 2 28432 89566
1 2 71495 107508
1 2 127611 184981
1 2 207408 158375
1 1 133794 249055
1 2 238147 116196
1 1 138464 150779
1 1 81508 172111
1 1 238006 39496
1 1 158265 2654...

output:

-1
-1
247027
221793
221793
221793
221793
221793
221793
221793
221793
221793
221793
195195
195195
195195
186697
186697
155115
126767
126767
126767
126767
122377
122377
122377
122377
122377
122377
122377
122377
122377
74199
74199
74199
74199
74199
74199
74199
74199
74199
74199
74199
74199
74199
74199
...

result:

ok 250000 numbers

Test #44:

score: 0
Accepted
time: 157ms
memory: 77512kb

input:

250000
1 2 32850 158604
1 1 9749 32349
1 2 237366 213085
1 1 249741 227017
1 1 156604 91892
1 1 43754 28095
1 1 48916 159269
1 1 139395 139395
1 2 27426 27426
1 2 181892 181892
1 2 76783 90617
1 1 198017 198017
1 2 59978 59978
1 2 75303 75303
1 2 80417 54248
1 1 196663 198370
1 2 85592 103103
1 2 25...

output:

-1
190953
190953
190953
190953
186699
186699
186699
59775
59775
59775
59775
59775
59775
59775
59775
59775
59775
59775
59775
59775
59775
59775
59775
59775
59775
59775
59775
59775
59775
59775
59775
59775
59775
59775
59775
59775
59775
59775
59775
59775
59775
59775
59775
59775
59775
59775
59775
59775
59...

result:

ok 250000 numbers

Test #45:

score: 0
Accepted
time: 142ms
memory: 75912kb

input:

250000
1 2 236282 236282
1 2 70462 70462
1 2 166718 166718
1 1 190608 190608
1 1 217300 217300
1 2 75152 1247
1 1 155997 155997
1 1 47751 74878
1 1 211721 60097
1 2 25339 25339
1 2 195307 45274
1 2 154471 154471
1 1 198019 198019
1 2 170988 170988
1 2 55435 55435
1 2 162876 101332
1 2 90095 148761
1...

output:

-1
-1
-1
261070
261070
261070
226459
122903
122903
100217
100217
100217
100217
100217
100217
100217
100217
100217
100217
100217
100217
100217
100217
100217
100217
100217
85074
85074
27171
27171
27171
27171
27171
27171
27171
27171
27171
27171
27171
27171
27171
27171
27171
27171
27171
27171
27171
2717...

result:

ok 250000 numbers

Test #46:

score: 0
Accepted
time: 143ms
memory: 77856kb

input:

250000
1 2 173630 173630
1 2 199978 199978
1 1 215863 219202
1 1 223573 223573
1 1 226701 226701
1 2 6285 6285
1 1 216830 198535
1 2 238765 238765
1 2 61934 61934
1 2 80355 242526
1 1 53228 194149
1 2 169972 64584
1 1 86638 86638
1 1 103934 232297
1 1 30669 30669
1 2 1046 67356
1 2 68226 68226
1 2 1...

output:

-1
-1
392832
392832
392832
225487
223115
223115
223115
223115
200434
200434
92923
92923
36954
36954
36954
36954
36954
32552
32552
26283
26283
26283
26283
14904
14904
14904
14904
14904
14904
14904
14904
14904
14904
14904
14904
14904
14904
14904
14904
14904
14904
14904
14904
14904
14904
14904
14904
14...

result:

ok 250000 numbers

Test #47:

score: 0
Accepted
time: 159ms
memory: 78040kb

input:

250000
1 2 104954 104954
1 1 107008 237157
1 2 138069 138069
1 2 145545 145545
1 2 122185 225658
1 2 85415 85415
1 1 146838 173872
1 1 26286 26286
1 2 216283 244484
1 1 11482 56708
1 2 43588 43588
1 2 57274 214483
1 1 26394 26394
1 2 28726 66918
1 1 237783 179916
1 1 134668 150112
1 1 41503 245551
1...

output:

-1
342111
342111
342111
342111
322572
259287
111701
111701
111701
69874
69874
69874
69874
69874
69874
69874
69874
69874
69874
69874
69874
69874
69874
38594
38594
38594
38594
38594
38594
38594
38594
38594
38594
38594
38594
38594
38594
38594
38594
38594
38594
38594
38594
38594
38594
38594
38594
38594
...

result:

ok 250000 numbers

Test #48:

score: 0
Accepted
time: 156ms
memory: 77744kb

input:

250000
1 1 77267 77267
1 1 155732 155732
1 1 108487 108487
1 2 163322 163322
1 1 233750 233750
1 2 236745 174796
1 1 24485 24485
1 2 82147 143015
1 1 23821 23821
1 2 43438 28126
1 1 205237 205237
1 2 134527 134527
1 1 132340 50562
1 2 186277 186277
1 2 210805 210805
1 1 34399 134752
1 1 42741 42741
...

output:

-1
-1
-1
240589
240589
240589
187807
167500
166836
67259
67259
67259
67259
67259
67259
67259
67259
67259
67259
67259
67259
54652
54652
54652
54652
54652
54652
54652
54652
54652
54652
54652
54652
54652
54652
54652
54652
54652
54652
54652
27155
27155
7418
7418
7418
7418
7418
7418
7418
7418
7418
7418
7...

result:

ok 250000 numbers

Test #49:

score: 0
Accepted
time: 145ms
memory: 76216kb

input:

250000
1 1 45836 45836
1 2 222475 119466
1 2 117038 136705
1 1 153474 153474
1 2 46330 46330
1 1 99089 99089
1 2 182844 42419
1 1 149903 177796
1 2 13728 172421
1 2 147151 189307
1 1 40075 40075
1 2 239750 218818
1 1 154884 132302
1 1 95914 147974
1 2 101336 44720
1 1 21656 85546
1 2 110474 110474
1...

output:

-1
268311
182541
182541
92166
92166
92166
92166
92166
92166
86405
86405
86405
86405
86405
86405
86405
63392
63392
63392
63392
63392
63392
63392
63392
63392
63392
63392
63392
63392
63392
63392
63392
63392
63392
26775
26775
26775
26775
26149
26149
26149
26149
26149
26149
26149
18524
18524
18524
18524
...

result:

ok 250000 numbers

Test #50:

score: 0
Accepted
time: 153ms
memory: 78376kb

input:

250000
1 2 106270 106270
1 2 112290 103201
1 1 25842 25842
1 2 124140 124140
1 1 241392 241392
1 2 11839 169006
1 1 80720 80720
1 1 230127 205906
1 1 41748 41748
1 2 84357 84357
1 1 245065 153870
1 2 240227 240227
1 2 19263 19263
1 2 232633 232633
1 1 37551 37551
1 1 245455 193352
1 2 183028 2728
1 ...

output:

-1
-1
132112
132112
132112
132112
132112
132112
132112
110199
110199
110199
45105
45105
45105
45105
45105
45105
45105
45105
45105
45105
42030
42030
42030
42030
42030
42030
42030
42030
42030
42030
42030
42030
42030
42030
42030
42030
42030
42030
42030
42030
42030
42030
42030
42030
42030
24182
13535
13...

result:

ok 250000 numbers

Test #51:

score: 0
Accepted
time: 155ms
memory: 77316kb

input:

250000
1 1 115330 115330
1 2 227618 202477
1 2 193156 11453
1 2 150822 150822
1 1 202319 202319
1 2 87598 87598
1 1 174271 174271
1 2 153547 46710
1 1 213146 237666
1 1 55650 55650
1 1 186113 219327
1 1 52841 106468
1 2 28966 28966
1 2 80710 80710
1 2 74059 53086
1 2 205071 123328
1 2 158873 183775
...

output:

-1
342948
308486
266152
266152
202928
202928
202928
202928
143248
143248
143248
84616
84616
84616
84616
84616
45905
45905
45905
45905
45905
45905
45905
45905
45905
45905
45905
45905
45905
45905
45905
45905
45905
45905
45905
45905
45905
45905
45905
45905
45905
45905
45905
45905
45905
45905
45905
4590...

result:

ok 250000 numbers

Test #52:

score: 0
Accepted
time: 152ms
memory: 77220kb

input:

250000
1 2 205066 56343
1 2 12899 12899
1 2 126178 126178
1 2 131297 5629
1 1 132046 132046
1 1 52801 52801
1 2 170470 170470
1 1 148997 148997
1 2 47265 47265
1 1 118304 118304
1 2 30238 108527
1 2 53356 53356
1 2 197992 197992
1 1 178605 196898
1 1 11274 117919
1 2 74782 74782
1 1 172017 209088
1 ...

output:

-1
-1
-1
-1
144945
65700
65700
65700
65700
65700
65700
65700
65700
65700
65700
65700
65700
65700
65700
65700
65700
65700
65700
65700
65700
65700
14885
14885
14885
14885
14885
14885
14885
14885
14885
14885
14885
14885
14885
14885
14885
14885
14885
14885
14885
14885
14885
14885
14885
14885
14885
14885...

result:

ok 250000 numbers

Test #53:

score: 0
Accepted
time: 123ms
memory: 75256kb

input:

250000
1 2 64533 20353
1 1 181746 181746
1 1 196811 196811
1 2 208913 51167
1 2 81703 81703
1 1 116332 116332
1 2 231166 245443
1 2 211568 211568
1 1 212940 212940
1 1 172758 183898
1 1 89274 36726
1 1 191159 191159
1 2 232266 232266
1 2 41662 35144
1 1 44331 44331
1 1 177872 155800
1 2 58562 103193...

output:

-1
246279
246279
246279
246279
180865
180865
180865
180865
180865
153807
153807
153807
130936
85993
85993
85993
74698
74698
53909
53909
53909
53909
53909
53909
53909
53909
53909
53909
53909
53909
53909
53909
41509
41509
41509
41509
22796
22796
22796
22796
22796
22796
22796
22796
22796
22796
22796
22...

result:

ok 250000 numbers

Test #54:

score: 0
Accepted
time: 151ms
memory: 76720kb

input:

250000
1 2 20706 109119
1 1 59655 59655
1 2 206502 80165
1 2 205997 205997
1 1 56529 53231
1 2 32296 247423
1 2 162031 96878
1 1 184209 116779
1 1 115787 115787
1 1 245727 245727
1 1 187162 187162
1 1 220933 221705
1 2 21493 235951
1 2 100340 215615
1 2 80537 237317
1 1 88300 88300
1 1 15037 140480
...

output:

-1
168774
168774
168774
162350
162350
162350
162350
162350
162350
162350
162350
162350
162350
162350
162350
162350
162350
104018
104018
76953
44825
44825
44825
44825
44825
44825
44825
44825
44825
44825
44825
44825
44825
44825
44825
44825
44825
44825
44825
44825
44825
44825
44825
44825
44825
17806
17...

result:

ok 250000 numbers

Test #55:

score: 0
Accepted
time: 158ms
memory: 78236kb

input:

250000
1 2 89549 98914
1 1 95919 211488
1 2 179423 179423
1 2 155579 155579
1 2 175319 63344
1 1 86812 179328
1 2 153923 90720
1 2 127598 120109
1 1 88135 88135
1 1 5094 160877
1 2 245894 49499
1 2 149915 149915
1 1 125109 6162
1 2 196106 97122
1 2 35080 35080
1 1 131810 131810
1 2 45707 45707
1 1 6...

output:

-1
310402
310402
310402
274832
262131
262131
262131
187049
187049
187049
187049
187049
187049
123215
123215
123215
123215
123215
123215
123215
123215
123215
88187
88187
88187
70407
70407
70407
70407
70407
70407
70407
70407
70407
70407
70407
70407
70407
70407
70407
70407
70407
70407
70407
70407
70407...

result:

ok 250000 numbers

Test #56:

score: 0
Accepted
time: 136ms
memory: 75144kb

input:

250000
1 2 133693 133693
1 2 124005 124005
1 2 85235 85235
1 2 77230 77230
1 2 149258 149258
1 2 190343 76288
1 2 44788 181922
1 2 185538 185538
1 2 227191 71738
1 2 53037 53037
1 2 68613 84141
1 2 224660 67479
1 2 202409 92562
1 1 13545 13545
1 2 115923 44751
1 1 59124 59124
1 1 241822 241822
1 1 1...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
66582
66582
66582
66582
66582
66582
66582
66582
66582
66582
66582
66582
66582
66582
66582
66582
66582
66582
66582
66582
66582
66582
66582
66582
66582
66582
66582
65177
65177
65177
65177
65177
65177
65177
65177
65177
65177
65177
65177
65177
65177
65177
65177
651...

result:

ok 250000 numbers

Test #57:

score: 0
Accepted
time: 140ms
memory: 75480kb

input:

250000
1 2 61476 61476
1 2 227961 235345
1 2 95569 95569
1 2 90749 9715
1 2 52299 54413
1 2 154818 174392
1 2 148845 123366
1 2 45144 45144
1 1 161499 112486
1 1 141254 141509
1 1 60455 60455
1 1 141480 141480
1 2 163280 163280
1 2 149469 169926
1 1 64895 64895
1 2 113697 113697
1 2 105128 174656
1 ...

output:

-1
-1
-1
-1
-1
-1
-1
-1
206643
186653
105599
105599
105599
105599
105599
105599
105599
104180
104180
104180
104180
68909
68909
68909
68909
68909
68909
68909
68909
68909
68909
68909
68909
68909
68909
60499
60499
60499
60499
60499
60499
60499
60499
60499
60499
60499
60499
60499
60499
60499
60499
60499...

result:

ok 250000 numbers

Test #58:

score: 0
Accepted
time: 149ms
memory: 77404kb

input:

250000
1 2 218973 218973
1 1 49158 49158
1 2 103129 103129
1 2 10181 10181
1 1 109333 116517
1 1 3330 28857
1 1 202465 171062
1 2 57232 57232
1 2 196497 196497
1 1 166538 166538
1 2 202123 202123
1 2 16762 16762
1 2 80443 80443
1 2 49408 49408
1 1 42625 42625
1 1 23021 218787
1 2 73272 31820
1 2 997...

output:

-1
268131
152287
59339
59339
39038
39038
39038
39038
39038
39038
39038
39038
39038
39038
39038
39038
39038
39038
39038
39038
17265
17265
17265
17265
17265
17265
17265
17265
17265
17265
17265
17265
17265
17265
17265
17265
17265
17265
17265
17265
17265
17265
17265
17265
17265
17265
17265
17265
17265
1...

result:

ok 250000 numbers

Test #59:

score: 0
Accepted
time: 148ms
memory: 75748kb

input:

250000
1 1 217003 216018
1 2 249020 245454
1 2 39148 233068
1 2 155582 234592
1 2 138500 185800
1 2 33378 224513
1 1 197879 217829
1 1 174054 175542
1 1 231943 149348
1 2 216714 18159
1 1 43945 104483
1 2 215344 188854
1 2 16932 121899
1 2 95983 55270
1 1 113735 219131
1 2 7814 107058
1 2 197410 182...

output:

-1
466023
449086
449086
401818
401818
401818
361342
361342
361342
260659
260659
226382
159753
159753
159753
159753
159753
159753
159753
159753
104483
33550
33550
33550
33550
33550
33550
33550
33550
33550
33550
33550
33550
33550
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 250000 numbers

Test #60:

score: 0
Accepted
time: 139ms
memory: 76444kb

input:

250000
1 1 161327 180858
1 2 77577 221456
1 2 0 0
1 1 41657 174207
1 2 131320 49040
1 1 224670 101635
1 2 123285 115914
1 2 176612 31242
1 1 188856 165323
1 2 197949 59363
1 2 92862 173138
1 1 209738 117773
1 2 195978 101415
1 2 4539 122193
1 1 125716 54939
1 2 13183 227681
1 2 7169 72810
1 1 153926...

output:

-1
402314
180858
174207
174207
174207
174207
174207
174207
174207
174207
174207
174207
174207
125716
125716
125716
125716
125716
125716
125716
125716
125716
125716
125716
125716
125716
125716
125716
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 250000 numbers

Test #61:

score: 0
Accepted
time: 137ms
memory: 76460kb

input:

250000
1 1 57286 97028
1 2 191891 163831
1 1 200021 101365
1 1 214646 188174
1 2 156240 150296
1 1 125732 128360
1 2 248342 212377
1 1 27141 232999
1 2 103889 174519
1 2 205092 197192
1 2 19682 176948
1 2 187337 35489
1 2 206088 247109
1 2 240556 147462
1 1 12041 21382
1 2 80939 223301
1 1 191412 22...

output:

-1
260859
260859
260859
247324
247324
247324
247324
247324
247324
247324
244623
244623
244623
171678
171678
171678
171678
171678
171678
171678
171678
171678
171678
156240
156240
156240
136055
136055
136055
136055
136055
136055
136055
136055
136055
136055
136055
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 250000 numbers

Test #62:

score: 0
Accepted
time: 141ms
memory: 75624kb

input:

250000
1 2 32824 148490
1 2 151730 7146
1 1 35166 40320
1 2 31940 105625
1 2 246583 222506
1 1 110466 152764
1 1 0 0
1 2 245133 153077
1 2 40434 16236
1 1 103821 185596
1 1 214698 110712
1 1 204245 115109
1 2 70460 85980
1 2 42872 39691
1 2 38855 238575
1 1 178059 84543
1 1 228058 85426
1 1 145078 1...

output:

-1
-1
186896
145945
145945
145945
105625
105625
40434
40434
40434
40434
40434
40434
40434
40434
40434
40434
40434
40434
40434
40434
40434
40434
40434
40434
40434
40434
40434
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 250000 numbers

Test #63:

score: 0
Accepted
time: 134ms
memory: 75668kb

input:

250000
1 2 77552 175269
1 1 35995 38665
1 1 169177 158818
1 1 46923 98072
1 1 202400 26311
1 1 200118 138984
1 2 92510 121284
1 1 0 0
1 1 12336 10072
1 1 189284 64566
1 1 156890 132966
1 1 8046 116811
1 1 132217 46904
1 1 232088 177000
1 2 1990 52661
1 2 179739 221456
1 2 17982 193489
1 1 131752 653...

output:

-1
213934
213934
213934
213934
213934
159949
121284
121284
121284
121284
121284
121284
121284
52661
52661
52661
52661
52661
27623
27623
27623
27623
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 250000 numbers

Test #64:

score: 0
Accepted
time: 136ms
memory: 75520kb

input:

250000
1 2 0 0
1 2 0 0
1 1 0 0
1 2 37778 39427
1 1 124942 154078
1 1 174756 121384
1 1 58664 185114
1 1 0 0
1 2 248950 49150
1 2 0 0
1 2 232649 198720
1 2 116161 171335
1 2 188621 91941
1 1 214543 140013
1 2 138432 239885
1 1 0 0
1 1 0 0
1 1 0 0
1 2 208226 165828
1 1 158173 22366
1 2 115591 143032
1...

output:

-1
-1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 250000 numbers

Test #65:

score: 0
Accepted
time: 134ms
memory: 75308kb

input:

250000
1 1 176302 246215
1 2 34303 153004
1 2 48611 179114
1 2 136502 54656
1 1 0 0
1 1 166230 82287
1 1 14527 1313
1 1 53715 195239
1 1 142018 89322
1 2 31949 26166
1 2 196101 60031
1 1 230437 8609
1 1 49937 168725
1 1 219241 164710
1 2 239730 125675
1 2 231496 203432
1 2 239243 116645
1 2 225470 1...

output:

-1
399219
399219
312804
136502
136502
136502
136502
136502
31949
31949
31949
31949
31949
31949
31949
31949
31949
31949
31949
31949
31949
31949
31949
31949
31949
31949
31949
31949
31949
31949
31949
31949
31949
31949
31949
31949
31949
31949
31949
31949
31949
31949
31949
31949
31949
31949
31949
31949
3...

result:

ok 250000 numbers

Test #66:

score: 0
Accepted
time: 134ms
memory: 77660kb

input:

250000
1 1 15527 242733
1 1 217302 247156
1 2 212839 41651
1 1 1772 15155
1 2 70006 48164
1 1 116982 27670
1 2 210243 222879
1 1 1218 57375
1 2 6351 237062
1 2 72514 38267
1 2 110538 188718
1 1 115939 23052
1 2 170402 128649
1 2 10819 201072
1 1 0 0
1 2 211806 42485
1 2 0 0
1 2 71236 16824
1 1 61148...

output:

-1
-1
284384
214611
71778
71778
71778
71778
71778
71778
71778
71778
71778
71778
70006
70006
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 250000 numbers

Test #67:

score: 0
Accepted
time: 138ms
memory: 76956kb

input:

250000
1 1 136314 86429
1 2 219558 165514
1 1 161321 189292
1 2 0 0
1 1 94995 18895
1 2 226673 152687
1 1 31815 182629
1 2 84725 39024
1 2 222827 247557
1 1 153779 129681
1 1 73701 82356
1 1 41771 29960
1 1 97697 139639
1 1 206189 113363
1 1 51284 41903
1 1 0 0
1 1 52255 47763
1 1 204512 110706
1 1 ...

output:

-1
355872
355872
136314
94995
94995
94995
94995
94995
94995
82356
41771
41771
41771
41771
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 250000 numbers

Test #68:

score: 0
Accepted
time: 138ms
memory: 76712kb

input:

250000
1 1 6548 92995
1 2 99675 208945
1 1 0 0
1 1 14682 150901
1 2 83603 82627
1 1 107405 186295
1 2 0 0
1 1 0 0
1 1 152628 3322
1 1 119675 133020
1 2 70705 239181
1 1 228835 188574
1 2 19793 115089
1 1 93870 83621
1 1 0 0
1 1 50741 149525
1 2 142966 13004
1 2 113019 112290
1 2 68776 135768
1 2 130...

output:

-1
301940
208945
208945
83603
83603
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 250000 numbers

Test #69:

score: 0
Accepted
time: 124ms
memory: 75256kb

input:

250000
1 1 232265 17681
1 1 50376 200158
1 1 249181 813
1 2 129045 121338
1 2 222100 27989
1 2 86438 163733
1 2 24614 225464
1 1 129064 120836
1 2 194711 55527
1 1 208833 41039
1 1 218594 31393
1 1 214921 34924
1 1 238442 11459
1 2 154661 95688
1 2 95101 155041
1 2 160086 90253
1 1 131592 118364
1 2...

output:

-1
-1
-1
321496
272476
272476
256879
256879
255685
255685
255685
255685
255685
255685
255685
255685
255685
250549
250522
250522
250522
250522
250522
250522
250522
250522
250522
250522
250522
250522
250522
250522
250522
250522
250522
250522
250522
250258
250258
250258
250258
250258
250258
250258
2502...

result:

ok 250000 numbers

Test #70:

score: 0
Accepted
time: 150ms
memory: 75276kb

input:

250000
1 2 132819 116948
1 1 86827 162723
1 1 198825 51107
1 1 190479 59421
1 2 120241 129684
1 2 243538 6450
1 1 184350 65772
1 1 83425 166217
1 2 241043 8964
1 1 182930 67184
1 1 153156 96909
1 1 111880 137741
1 2 75066 174425
1 2 52539 196885
1 1 60790 188901
1 1 181789 68443
1 2 161985 88063
1 2...

output:

-1
279671
279671
279671
279671
279671
279671
279671
279671
279671
273397
254689
254689
251364
251364
251364
250786
250786
250786
250786
250786
250786
250786
250786
250786
250786
250786
250786
250786
250786
250786
250786
250786
250137
250137
250137
250137
250137
250137
250137
249738
249738
249738
249...

result:

ok 250000 numbers

Test #71:

score: 0
Accepted
time: 142ms
memory: 75048kb

input:

250000
1 2 98402 151817
1 1 91346 158451
1 1 228513 21562
1 2 244358 5720
1 1 100972 148613
1 1 85477 164069
1 1 32040 217910
1 2 143692 106007
1 1 197414 52317
1 2 215510 34610
1 1 195942 53845
1 1 218106 31702
1 1 129753 119757
1 2 171302 78323
1 2 213729 36421
1 1 230888 19241
1 1 79318 170402
1 ...

output:

-1
310268
310268
310268
300430
300430
276398
254620
254620
252520
252520
252520
252520
252520
252520
252520
250620
250620
250620
250620
250620
250620
250620
250620
250620
250620
250326
250326
250326
250326
250326
250326
250326
250326
250326
250326
250326
250326
250326
250326
250326
250326
250326
250...

result:

ok 250000 numbers

Test #72:

score: 0
Accepted
time: 141ms
memory: 74180kb

input:

250000
1 1 192553 57679
1 1 180160 69833
1 1 150481 100096
1 2 36025 214190
1 2 194960 54311
1 1 40067 210131
1 1 196469 53655
1 1 83975 166453
1 2 215926 33824
1 1 64855 185174
1 2 219090 30734
1 2 228888 21290
1 2 224706 25159
1 1 220614 29445
1 1 7649 242146
1 1 124686 125349
1 1 58305 191851
1 1...

output:

-1
-1
-1
271869
271869
264442
264442
264442
255993
255993
255993
255993
255993
255993
255993
255993
253265
252188
252188
252188
252188
252188
250098
250098
250098
250098
250098
250098
250098
250098
250098
250098
250098
250098
250098
250098
250098
250098
250098
250098
250098
250098
250098
250098
2500...

result:

ok 250000 numbers

Test #73:

score: 0
Accepted
time: 144ms
memory: 75516kb

input:

250000
1 2 3567 246282
1 2 77346 172326
1 2 153606 95651
1 1 112071 137831
1 2 233380 16066
1 2 179399 69917
1 1 75600 174358
1 1 20250 229795
1 1 159198 90678
1 2 242541 7152
1 2 214343 35385
1 2 136458 113112
1 1 27042 222895
1 1 40652 209428
1 2 146353 103157
1 1 19782 230255
1 1 11456 238806
1 1...

output:

-1
-1
-1
265677
265677
265677
254999
253630
253630
253630
253630
250943
250943
250943
250943
250943
250943
250943
250943
250943
250943
250943
250943
250943
250943
250943
250943
250943
250943
250943
250943
250943
250943
250943
250943
250191
250191
250191
250191
250191
250191
250191
250191
250191
2501...

result:

ok 250000 numbers

Test #74:

score: 0
Accepted
time: 150ms
memory: 75432kb

input:

250000
1 1 190989 59160
1 1 156862 93453
1 2 243067 6929
1 2 104297 145421
1 1 176310 74144
1 1 212149 38038
1 1 138248 112015
1 1 180362 70006
1 2 38321 211669
1 2 38544 211451
1 2 168989 81000
1 1 107518 142294
1 1 206904 43236
1 1 30097 220222
1 1 15342 234705
1 1 165355 85059
1 1 92407 157364
1 ...

output:

-1
-1
399929
261159
261159
261159
257436
257436
250470
250470
250470
250470
250470
250470
250470
250470
250470
250470
250470
250470
250470
250470
250470
250470
250470
250470
250470
250470
250470
250470
250470
250470
250470
250470
250470
250470
250470
250470
250470
250470
250470
250470
250470
250470
...

result:

ok 250000 numbers

Test #75:

score: 0
Accepted
time: 143ms
memory: 74216kb

input:

250000
1 1 16881 232622
1 2 108157 142146
1 1 64034 185524
1 2 220054 30295
1 1 107683 141650
1 1 21401 228272
1 2 12741 237421
1 1 137461 112060
1 2 37332 212694
1 1 164896 85002
1 2 7805 242384
1 2 95992 154340
1 2 910 249153
1 2 82593 167949
1 2 41726 208512
1 1 210090 40109
1 1 9357 240349
1 1 4...

output:

-1
374768
327670
262917
262917
258567
258567
254206
254206
254206
254206
254206
254206
252951
252951
251816
251816
251816
251816
251816
250559
250559
250559
250559
250559
250559
250559
250559
250559
250559
250559
250559
250559
250559
250559
250559
250559
250559
250559
250559
250559
250559
250559
250...

result:

ok 250000 numbers

Test #76:

score: 0
Accepted
time: 135ms
memory: 75344kb

input:

250000
1 2 134704 114958
1 2 245390 4767
1 1 176642 73607
1 1 196579 53600
1 2 113334 136190
1 1 141769 108729
1 1 38831 211077
1 1 225636 24533
1 2 155763 94018
1 1 166285 83967
1 1 63799 186400
1 2 31649 218144
1 2 16260 233513
1 2 5776 244165
1 1 30884 218901
1 1 144659 105841
1 1 19409 230517
1 ...

output:

-1
-1
311346
311346
289976
255103
255103
255103
255103
255103
255103
255103
255103
255103
255103
255103
255103
255103
255103
255103
250887
250887
250887
250887
250887
250887
250887
250887
250887
250723
250723
250723
250293
250293
250293
250293
250293
250293
250293
250293
250293
250293
250293
250158
...

result:

ok 250000 numbers

Test #77:

score: 0
Accepted
time: 160ms
memory: 75492kb

input:

250000
1 1 104007 146533
1 2 122821 126197
1 1 54477 195948
1 1 214761 35040
1 1 230985 18754
1 1 149092 101129
1 1 82953 167163
1 1 166181 84059
1 1 83057 167067
1 2 108798 140378
1 2 191371 57992
1 2 57939 191474
1 1 36018 213944
1 1 15000 234679
1 1 127543 122601
1 1 149343 100898
1 1 45942 20428...

output:

-1
272730
272730
272730
272730
271913
271913
271913
271913
257890
253940
253940
253940
253940
250364
250364
250364
250364
250364
250364
250364
250364
250364
250364
250364
250364
250364
250364
250364
250364
250364
250364
250364
250364
250234
250234
250234
250234
250234
250214
250214
250120
250120
250...

result:

ok 250000 numbers

Test #78:

score: 0
Accepted
time: 145ms
memory: 75012kb

input:

250000
1 1 172908 77164
1 2 234755 15487
1 2 6497 243680
1 1 162745 87128
1 2 175885 73952
1 1 23261 226856
1 2 20468 229274
1 1 160045 89804
1 1 16846 233302
1 1 16108 233960
1 2 70155 179957
1 1 2795 247300
1 1 69142 180881
1 2 149068 100418
1 1 66029 184023
1 1 97902 152159
1 1 38163 212161
1 1 1...

output:

-1
407663
320844
320844
320844
258016
258016
258016
251601
250863
250863
250863
250863
250863
250863
250863
250863
250863
250863
250863
250863
250863
250863
250863
250863
250863
250863
250863
250863
250863
250863
250863
250059
250059
250059
250059
250059
250059
250059
250059
250059
250059
250059
250...

result:

ok 250000 numbers

Test #79:

score: 0
Accepted
time: 101ms
memory: 74372kb

input:

250000
1 2 0 0
1 2 122517 126855
1 2 0 0
1 2 66081 183259
1 2 13210 236630
1 2 81829 167722
1 2 0 0
1 2 148092 100978
1 2 30794 219029
1 2 0 0
1 1 78812 170374
1 2 0 0
1 2 83526 166027
1 2 0 0
1 2 0 0
1 2 0 0
1 1 35781 214169
1 2 188618 60099
1 2 44597 205205
1 2 0 0
1 2 0 0
1 2 0 0
1 2 127894 12140...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
170374
170374
170374
170374
170374
170374
170374
170374
170374
170374
170374
170374
170374
170374
170374
147612
147612
147612
147612
147612
147612
147612
147612
147612
147612
147612
147612
147612
147612
147612
147612
147612
147612
147612
147612
141356
141356
141356
1413...

result:

ok 250000 numbers

Test #80:

score: 0
Accepted
time: 107ms
memory: 74508kb

input:

250000
1 2 0 0
1 2 151137 98772
1 2 123667 126225
1 2 0 0
1 2 31714 218101
1 2 0 0
1 2 201161 49234
1 2 0 0
1 2 0 0
1 2 0 0
1 1 216400 33227
1 1 220328 29353
1 2 143608 106411
1 2 0 0
1 2 0 0
1 2 149943 99894
1 1 164542 85404
1 2 57047 192853
1 2 202523 47881
1 2 0 0
1 2 219774 30328
1 2 0 0
1 1 773...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
216400
216400
216400
216400
216400
216400
164542
164542
164542
164542
164542
164542
164542
164542
147286
147286
147286
147286
147286
147286
147286
147286
147286
147286
147286
147286
147286
147286
147286
147286
147286
147286
126228
126228
126228
126228
126228
126228
1262...

result:

ok 250000 numbers

Test #81:

score: 0
Accepted
time: 111ms
memory: 74296kb

input:

250000
1 1 0 0
1 1 0 0
1 1 0 0
1 1 76835 173338
1 2 116002 133907
1 2 208617 41320
1 2 156201 93905
1 1 0 0
1 1 0 0
1 1 146667 103243
1 2 74717 175252
1 2 191863 58106
1 1 0 0
1 1 0 0
1 1 0 0
1 2 64934 185024
1 1 0 0
1 1 0 0
1 1 214353 35589
1 1 0 0
1 1 0 0
1 1 105633 144459
1 1 0 0
1 2 32607 217688...

output:

-1
-1
-1
-1
133907
133907
133907
133907
133907
133907
133907
133907
133907
133907
133907
133907
133907
133907
133907
133907
133907
133907
133907
133907
133907
133907
133907
133907
133907
133907
133907
133907
133907
133907
133907
133907
133907
133907
133907
133907
133907
133907
133907
133907
133907
1...

result:

ok 250000 numbers

Test #82:

score: 0
Accepted
time: 113ms
memory: 74480kb

input:

250000
1 1 243779 6224
1 2 39366 210597
1 2 0 0
1 2 0 0
1 2 0 0
1 2 0 0
1 2 0 0
1 2 81361 168380
1 2 49487 200675
1 1 249874 68
1 1 163540 86734
1 2 0 0
1 2 0 0
1 2 145638 103600
1 2 0 0
1 2 0 0
1 1 191464 59075
1 2 0 0
1 1 83409 166960
1 2 17641 232381
1 1 83537 166832
1 2 195683 54200
1 2 0 0
1 2 ...

output:

-1
283145
243779
243779
243779
243779
243779
243779
243779
243779
163540
163540
163540
163540
163540
163540
163540
163540
163540
163540
163540
163540
163540
163540
142031
142031
142031
142031
142031
142031
142031
142031
142031
142031
142031
142031
142031
142031
142031
142031
142031
142031
142031
138...

result:

ok 250000 numbers

Test #83:

score: 0
Accepted
time: 122ms
memory: 75532kb

input:

250000
1 2 0 0
1 2 0 0
1 2 206405 44044
1 2 0 0
1 2 0 0
1 2 0 0
1 2 0 0
1 1 80595 168955
1 2 0 0
1 1 36543 213310
1 1 46404 203211
1 1 42470 207245
1 1 66908 182630
1 1 191562 58094
1 2 0 0
1 2 0 0
1 2 0 0
1 2 0 0
1 1 101504 147953
1 2 0 0
1 2 109068 141655
1 1 187651 61963
1 2 117427 133490
1 2 0 0...

output:

-1
-1
-1
-1
-1
-1
-1
168955
168955
168955
168955
168955
168955
168955
168955
168955
168955
168955
147953
147953
147953
147953
147953
147953
147953
132432
132432
132432
132432
132432
132432
132432
132432
132432
132432
132432
132432
127230
127230
127230
127230
127230
127230
127230
127230
127230
127230...

result:

ok 250000 numbers

Test #84:

score: 0
Accepted
time: 104ms
memory: 74812kb

input:

250000
1 1 93891 156126
1 1 153174 96586
1 2 0 0
1 2 0 0
1 2 0 0
1 2 0 0
1 2 0 0
1 1 113437 136564
1 2 0 0
1 1 192401 57554
1 2 231113 18917
1 1 61616 188331
1 2 0 0
1 2 0 0
1 1 207159 42510
1 2 0 0
1 1 67730 182295
1 2 0 0
1 1 28743 221403
1 2 241414 8779
1 2 0 0
1 2 0 0
1 2 0 0
1 1 221796 27985
1 ...

output:

-1
-1
153174
153174
153174
153174
153174
136564
136564
136564
136564
136564
136564
136564
136564
136564
136564
136564
136564
136564
136564
136564
136564
136564
136564
136564
136564
136564
136564
136564
136564
136564
136564
136564
136564
136564
136564
136564
136564
136564
136564
136564
136564
136564
...

result:

ok 250000 numbers

Test #85:

score: 0
Accepted
time: 107ms
memory: 74880kb

input:

250000
1 1 0 0
1 2 239524 10527
1 1 121826 127757
1 2 179658 70157
1 2 120721 128862
1 2 201713 48413
1 2 223132 26983
1 1 126541 123046
1 1 0 0
1 1 0 0
1 1 58300 191621
1 1 0 0
1 1 10971 239077
1 1 0 0
1 1 155885 93973
1 1 0 0
1 1 0 0
1 2 200167 49833
1 1 0 0
1 1 213815 36012
1 1 0 0
1 2 178030 718...

output:

-1
239524
239524
179658
128862
128862
128862
128862
128862
128862
128862
128862
128862
128862
128862
128862
128862
128862
128862
128862
128862
128862
128862
128862
128862
128862
128862
128862
128862
128862
128862
128862
128862
128862
128862
128862
128862
128862
128862
128862
128862
128862
128862
128...

result:

ok 250000 numbers

Test #86:

score: 0
Accepted
time: 116ms
memory: 74524kb

input:

250000
1 2 201565 48487
1 1 169182 81789
1 1 0 0
1 1 0 0
1 2 133541 116989
1 1 189579 60701
1 1 235706 14146
1 1 0 0
1 1 84257 166678
1 1 0 0
1 1 69017 182115
1 1 0 0
1 1 134197 116680
1 1 0 0
1 1 0 0
1 1 0 0
1 1 80543 170669
1 2 125617 124732
1 1 0 0
1 1 0 0
1 1 197863 52376
1 1 0 0
1 1 0 0
1 1 0 0...

output:

-1
370747
201565
201565
133541
133541
133541
133541
133541
133541
133541
133541
133541
133541
133541
133541
133541
125617
125617
125617
125617
125617
125617
125617
125617
125617
125617
125617
125617
125617
125617
125617
125617
125617
125617
125617
125617
125617
125617
125617
125617
125617
125617
125...

result:

ok 250000 numbers

Test #87:

score: 0
Accepted
time: 114ms
memory: 74652kb

input:

250000
1 1 19904 230319
1 1 0 0
1 1 0 0
1 1 133443 117755
1 1 0 0
1 2 74491 175500
1 1 112101 139006
1 1 129611 121547
1 1 0 0
1 1 227992 22442
1 1 0 0
1 1 0 0
1 1 0 0
1 1 0 0
1 1 61125 189638
1 1 0 0
1 1 0 0
1 2 170371 79448
1 2 41035 209146
1 1 118916 132216
1 1 0 0
1 1 238621 11439
1 1 0 0
1 1 15...

output:

-1
-1
-1
-1
-1
175500
175500
175500
175500
175500
175500
175500
175500
175500
175500
175500
175500
170371
170371
170371
170371
170371
170371
170371
170371
170371
170371
170371
170371
170371
170371
170371
170371
145725
145725
145725
145725
145725
145725
125490
125490
125490
125490
125490
125490
12549...

result:

ok 250000 numbers

Test #88:

score: 0
Accepted
time: 108ms
memory: 74216kb

input:

250000
1 2 10218 239876
1 2 149770 100175
1 1 0 0
1 1 151233 98764
1 1 0 0
1 1 54855 195317
1 2 61147 188429
1 1 0 0
1 1 13230 236527
1 2 148451 101495
1 1 0 0
1 1 241747 7945
1 1 0 0
1 1 0 0
1 1 0 0
1 1 34013 216550
1 1 124958 124987
1 1 0 0
1 1 0 0
1 1 0 0
1 1 0 0
1 2 157641 92715
1 1 117054 13306...

output:

-1
-1
149770
149770
149770
149770
149770
149770
149770
148451
148451
148451
148451
148451
148451
148451
148451
148451
148451
148451
148451
148451
148451
148451
148451
148451
148451
148451
148451
134439
134439
134439
134439
134439
134439
134439
134439
134439
134439
134439
134439
134439
134439
134439
...

result:

ok 250000 numbers

Test #89:

score: 0
Accepted
time: 120ms
memory: 77016kb

input:

250000
1 2 153711 96344
1 2 88631 161404
1 2 139263 110640
1 2 178611 71390
1 1 105425 144595
1 1 106428 143568
1 2 27361 222674
1 1 130842 119071
1 1 144988 104928
1 2 189466 60525
1 1 79337 170577
1 1 18663 231401
1 1 202847 47133
1 1 225385 24587
1 2 139170 110727
1 2 63529 186446
1 2 78325 17158...

output:

-1
-1
-1
-1
255235
254208
254208
254208
254208
254208
254208
254208
254208
252746
252746
252746
252746
250242
250242
250242
250242
250242
250242
250242
250242
250242
250242
250178
250178
250178
250178
250178
250178
250178
250178
250178
250178
250178
250178
250178
250178
250178
250178
250178
250178
2...

result:

ok 250000 numbers

Test #90:

score: 0
Accepted
time: 113ms
memory: 77008kb

input:

250000
1 2 240014 10044
1 2 38341 211624
1 2 201314 48720
1 2 196971 53033
1 2 44802 205176
1 2 85365 164704
1 1 200123 49904
1 1 132703 117268
1 1 46683 203293
1 2 160441 89473
1 1 151642 98282
1 1 117221 132771
1 2 113116 136949
1 2 193588 56441
1 1 182632 67382
1 2 246665 3296
1 2 88353 161738
1 ...

output:

-1
-1
-1
-1
-1
-1
255080
255080
252013
252013
252013
252013
252013
252013
252013
252013
252013
252013
252013
252013
252013
252013
252013
252013
250980
250390
250390
250390
250390
250390
250390
250390
250390
250390
250390
250390
250390
250390
250390
250390
250390
250390
250390
250390
250390
250390
25...

result:

ok 250000 numbers

Test #91:

score: 0
Accepted
time: 108ms
memory: 76948kb

input:

250000
1 1 76120 173743
1 2 238375 11711
1 1 199261 50903
1 2 199190 50977
1 1 48510 201513
1 2 64227 185770
1 2 114579 135268
1 2 190664 59497
1 1 158762 91318
1 1 83400 166518
1 2 30075 219971
1 2 21809 228153
1 2 71051 178849
1 1 105395 144448
1 2 170157 79972
1 1 227878 22296
1 1 146227 103824
1...

output:

-1
314495
314495
275310
252490
252490
252490
252490
252490
252490
252490
252490
252490
252490
252490
250449
250449
250449
250449
250449
250449
250449
250449
250449
250449
250449
250449
250449
250449
250449
250449
250425
250425
250425
250425
250425
250425
250425
250425
250425
250425
250425
250425
250...

result:

ok 250000 numbers