QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#188379#2716. Interval Collectionlmeowdn4 1324ms216480kbC++144.1kb2023-09-25 19:35:372023-09-25 19:35:38

Judging History

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

  • [2023-09-25 19:35:38]
  • 评测
  • 测评结果:4
  • 用时:1324ms
  • 内存:216480kb
  • [2023-09-25 19:35:37]
  • 提交

answer

#include<bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define mp make_pair
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 i128; 
template<typename T,typename U>
T ceil(T x, U y) {return (x>0?(x+y-1)/y:x/y);}
template<typename T,typename U>
T floor(T x, U y) {return (x>0?x/y:(x-y+1)/y);}
template<class T,class S>
bool chmax(T &a,const S b) {return (a<b?a=b,1:0);}
template<class T,class S>
bool chmin(T &a,const S b) {return (a>b?a=b,1:0);}
int popcnt(int x) {return __builtin_popcount(x);}
int popcnt(ll x)  {return __builtin_popcountll(x);}
int topbit(int x) {return (x==0?-1:31-__builtin_clz(x));}
int topbit(ll x)  {return (x==0?-1:63-__builtin_clzll(x));}
int lowbit(int x) {return (x==0?-1:__builtin_ctz(x));}
int lowbit(ll x)  {return (x==0?-1:__builtin_ctzll(x));}

#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
typedef pair<int,int> pii; 
typedef vector<int> vi;
typedef vector<pii> vp;
typedef tuple<int,int,int> tiii;
int read() {
  int x=0,w=1; char c=getchar(); 
  while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
  while(isdigit(c)) {x=x*10+(c-'0'); c=getchar();}
  return x*w;
}

const int N=1e6+5,m=1e6,inf=1e8;
int ls[N<<1],rs[N<<1],tot=1,ml[N<<1],mr[N<<1],n;
multiset<int> sl[N],sr[N];
map<pii,int> cnt;
struct node {pii a,b; int val;};
bool operator < (const node &a,const node &b) {
  return a.val>b.val;
}
priority_queue<node> q;

void build(int p,int l,int r) {
  ml[p]=-inf, mr[p]=inf; if(l==r) return; int mid=l+r>>1;
  build(ls[p]=++tot,l,mid), build(rs[p]=++tot,mid+1,r);
}
void mdfl(int p,int l,int r,int x,int y) {
  if(l==r) {
    if(!sl[l].size()) ml[p]=-inf;
    else ml[p]=*(--sl[l].end());
    return;
  } int mid=l+r>>1;
  if(x<=mid) mdfl(ls[p],l,mid,x,y);
  else mdfl(rs[p],mid+1,r,x,y);
  ml[p]=max(ml[ls[p]],ml[rs[p]]);
}
void mdfr(int p,int l,int r,int x,int y) {
  if(l==r) {
    if(!sr[l].size()) mr[p]=inf;
    else mr[p]=*sr[l].begin();
    return;
  } int mid=l+r>>1;
  if(y<=mid) mdfr(ls[p],l,mid,x,y);
  else mdfr(rs[p],mid+1,r,x,y);
  mr[p]=min(mr[ls[p]],mr[rs[p]]);
}
int qryl(int p,int l,int r,int x,int y) {
  if(x>y) return -inf;
  if(l==x&&r==y) return ml[p]; int mid=l+r>>1;
  if(y<=mid) return qryl(ls[p],l,mid,x,y);
  else if(x>mid) return qryl(rs[p],mid+1,r,x,y);
  else return max(qryl(ls[p],l,mid,x,mid),qryl(rs[p],mid+1,r,mid+1,y));
}
int qryr(int p,int l,int r,int x,int y) {
  if(x>y) return inf;
  if(l==x&&r==y) return mr[p]; int mid=l+r>>1;
  if(y<=mid) return qryr(ls[p],l,mid,x,y);
  else if(x>mid) return qryr(rs[p],mid+1,r,x,y);
  else return min(qryr(ls[p],l,mid,x,mid),qryr(rs[p],mid+1,r,mid+1,y));
}
void addl(int l,int r) {
  if(l<=0||r>m) return;
  int pl=qryl(1,1,m,1,l);
  if(pl!=-inf) {
    int pr=*sr[pl].begin();
    q.push((node){pii(pl,pr),pii(l,r),r-pl});
  }
}
void addr(int l,int r) {
  if(l<=0||r>m) return;
  int qr=qryr(1,1,m,r,m);
  if(qr!=inf) {
    int ql=*(--sl[qr].end());
    q.push((node){pii(l,r),pii(ql,qr),qr-l});
  }
}

signed main() {
  n=read(); build(1,1,m);
  rep(i,1,n) {
    static char s[3]; int l,r;
    scanf("%s%d%d",s,&l,&r);
    if(s[0]=='A') {
      sl[r].insert(l), sr[l].insert(r);
      cnt[pii(l,r)]++;
      addl(l,r), addr(l,r);
      mdfl(1,1,m,r,l);
      mdfr(1,1,m,r,l);
    } else {
      sl[r].erase(sl[r].find(l));
      sr[l].erase(sr[l].find(r));
      cnt[pii(l,r)]--;
      mdfl(1,1,m,r,l);
      mdfr(1,1,m,r,l);
      int pl=qryl(1,1,m,1,r);
      if(pl!=-inf) {
        int pr=*sr[pl].begin();
        addr(pl,pr);
      }
      int qr=qryr(1,1,m,l,m);
      if(qr!=inf) {
        int ql=*(--sl[qr].end());
        addl(ql,qr);
      }
    }
    while(!q.empty()) {
      auto [a,b,v]=q.top();
      if(cnt[a]&&cnt[b]) {
        printf("%d\n",v);
        break;
      } q.pop();
    }
    if(q.empty()) {
      int l=qryl(1,1,m,1,m), r=qryr(1,1,m,1,m);
      int al=*(--sl[r].end()), ar=*sr[l].begin();
      printf("%d\n",ar-al);
    }
  }
  return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 3
Accepted
time: 8ms
memory: 128884kb

input:

500
A 85614 618681
A 96881 534557
A 371656 884110
A 55265 991070
A 135033 917439
A 467668 648254
A 810282 995373
A 578086 947503
A 63927 975158
A 142141 348881
A 372691 541176
A 409911 918917
A 594071 750141
A 26557 936338
A 194871 545990
A 584676 799137
A 153204 901288
A 22939 601013
A 102411 75491...

output:

533067
437676
787229
787229
787229
551373
527705
527705
527705
506113
399035
399035
377450
377450
377450
377450
377450
377450
377450
377450
377450
377450
377450
377450
377450
377450
377450
266548
266548
266548
266548
266548
266548
266548
266548
266548
266548
266548
266548
266548
266548
266548
266548...

result:

ok 500 lines

Test #2:

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

input:

500
A 51501 770046
A 413690 883908
A 523395 969644
A 30211 456370
A 866 555010
A 589894 942832
A 128560 337749
A 50396 485899
A 889863 891076
A 375430 607391
A 568094 832070
A 7602 682176
A 647210 910003
A 81345 578690
A 386161 851662
A 191746 397694
A 577109 942335
A 390374 905222
A 51091 943116
A ...

output:

718545
832407
918143
939433
939433
912621
755348
755348
477386
477386
322982
322982
322982
322982
322982
322982
322982
322982
322982
322982
322982
322982
322982
322982
322982
322982
322982
322982
322982
322982
322982
234916
234916
174741
174741
174741
174741
174741
174741
174741
39596
39596
39596
39...

result:

ok 500 lines

Test #3:

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

input:

500
A 301221 443323
A 424434 472378
A 718791 867097
A 101078 891843
A 73298 585915
A 85760 984998
A 310227 786962
R 73298 585915
A 537303 711968
R 301221 443323
A 246428 354895
R 101078 891843
A 348967 787936
R 718791 867097
A 158840 444913
R 85760 984998
A 210951 809780
R 424434 472378
A 585016 795...

output:

142102
171157
442663
442663
442663
442663
442663
442663
287534
287534
225950
225950
225950
225950
225950
225950
225950
465540
465540
465540
465540
465540
465540
465540
465540
465540
465540
465540
465540
549514
549514
613933
613933
469389
568445
568445
350432
350432
350432
350432
350432
350432
350432...

result:

ok 500 lines

Test #4:

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

input:

500
A 204876 998161
A 167407 791048
R 204876 998161
A 53892 881810
R 167407 791048
A 362592 434167
R 362592 434167
A 283061 956671
R 53892 881810
A 318340 634885
R 283061 956671
A 124251 174781
R 318340 634885
A 10197 775954
R 10197 775954
A 167294 386842
R 167294 386842
A 492190 783109
R 492190 783...

output:

793285
830754
623641
623641
827918
71575
827918
902779
673610
316545
316545
510634
50530
50530
50530
262591
50530
658858
50530
765859
682309
684495
682309
682309
945388
983918
609833
108565
609833
864513
609833
171294
171294
171294
922587
328865
328865
328865
620920
670041
620920
22638
620920
106927...

result:

ok 500 lines

Test #5:

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

input:

500
A 123116 774435
A 10262 999509
A 58818 999109
A 424964 764731
A 21849 995409
A 605987 894936
A 256901 952030
A 195515 466530
A 385455 558603
A 327112 652258
A 313709 690228
A 562387 692001
A 72143 832906
A 392854 451324
A 297535 997005
A 656156 804986
A 541148 818852
A 113736 843636
A 3943 97342...

output:

651319
651319
651319
339767
339767
469972
469972
699421
509481
509481
509481
306546
306546
299147
299147
299147
299147
299147
299147
226466
226466
226466
226466
226466
226466
226466
226466
226466
226466
226466
226466
226466
226466
226466
226466
226466
226466
226466
226466
226466
226466
226466
226466...

result:

ok 500 lines

Test #6:

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

input:

500
A 14498 941877
A 465728 992111
A 163990 382952
A 346993 755132
A 251432 637371
A 484019 912817
A 358610 696623
A 383832 982209
A 127111 612625
A 361420 577068
A 85779 715610
A 146073 991298
A 42838 514167
A 6122 825634
A 110242 967873
A 103675 822037
A 683367 927853
A 186285 855247
A 438265 8053...

output:

927379
977613
828121
828121
828121
748827
748827
748827
748827
748827
748827
748827
748827
748827
748827
748827
566433
566433
566433
566433
566433
566433
566433
566433
566433
566433
415735
415735
415735
415735
415735
415735
415735
415735
415735
415735
415735
415735
415735
415735
415735
390451
390451...

result:

ok 500 lines

Test #7:

score: 0
Accepted
time: 26ms
memory: 128772kb

input:

500
A 470361 948150
A 48638 994850
A 9995 931845
A 134805 710464
A 136626 888447
A 36409 947319
A 669991 972286
R 48638 994850
A 211860 323301
A 94620 990418
R 211860 323301
R 470361 948150
A 694316 980527
R 94620 990418
A 252387 903879
A 56119 600119
R 134805 710464
R 136626 888447
A 345935 694111
...

output:

477789
477789
938155
813345
813345
813345
837481
837481
736290
736290
837481
837481
845722
845722
845722
916167
916167
916167
634592
634592
634592
634592
634592
634592
634592
634592
634592
634592
634592
634592
634592
634592
634592
634592
634592
634592
634592
840391
840391
840391
840391
840391
675863...

result:

ok 500 lines

Test #8:

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

input:

500
A 780818 881382
A 245422 767332
A 141555 965048
R 245422 767332
A 615038 698285
R 780818 881382
R 615038 698285
A 108678 944698
R 141555 965048
A 595940 967053
R 108678 944698
A 146561 250686
A 303022 829278
A 72755 602619
A 374686 721067
A 8506 980130
A 3695 994460
A 156694 861875
R 156694 8618...

output:

100564
635960
635960
100564
266344
83247
823493
856370
836020
858375
371113
820492
682717
682717
574506
574506
574506
574506
574506
541524
327155
327155
541524
541524
541524
541524
433936
541524
541524
682717
682717
104125
823976
823976
823976
823976
823976
823976
823976
823976
897782
897782
897782
...

result:

ok 500 lines

Test #9:

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

input:

500
A 420438 541497
A 86798 990642
A 235310 729230
A 197788 625590
A 79284 860784
A 346912 450878
A 773621 889839
A 5712 984607
A 11350 639351
A 181429 945167
A 600438 974037
A 555450 871681
A 593584 939508
A 111801 887010
A 98478 501202
A 681985 834199
A 503983 625918
A 473820 924948
A 172241 84496...

output:

121059
121059
121059
121059
121059
194585
469401
469401
469401
469401
469401
451243
451243
451243
451243
413761
279006
279006
279006
279006
279006
279006
279006
279006
279006
279006
279006
279006
279006
279006
279006
279006
279006
279006
279006
279006
279006
279006
279006
279006
279006
279006
279006...

result:

ok 500 lines

Test #10:

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

input:

500
A 231294 865302
A 8 999932
A 12438 979246
A 238533 788301
A 489466 694962
A 449857 936742
A 508862 838859
A 9106 368028
A 328347 578297
A 44361 997182
A 131817 462103
A 221223 700923
A 555704 987943
A 114241 978978
A 403584 802697
A 38125 324399
A 21828 947351
A 258684 853933
A 367336 694342
A 3...

output:

634008
634008
634008
549768
205496
205496
349393
685856
685856
685856
563145
563145
563145
563145
563145
540172
540172
540172
540172
540172
540172
540172
540172
540172
540172
540172
540172
446351
270004
270004
270004
270004
270004
270004
270004
270004
270004
270004
270004
270004
270004
270004
270004...

result:

ok 500 lines

Test #11:

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

input:

500
A 343721 615037
A 50898 491918
A 48426 990133
A 449206 907311
A 532116 720634
A 466385 563131
A 22661 502083
A 345660 709874
A 130224 270658
A 545301 807676
A 5041 952806
A 444622 693531
A 289899 888889
A 47379 986754
A 231133 737204
A 2253 996081
A 450332 787060
A 404494 556776
A 660496 786591
...

output:

271316
564139
564139
856413
669736
669736
669736
669736
432907
432907
432907
432907
432907
432907
432907
432907
432907
426552
320206
320206
320206
320206
320206
320206
320206
320206
320206
320206
275330
275330
275330
275330
275330
275330
275330
275330
275330
275330
275330
275330
275330
275330
275330...

result:

ok 500 lines

Test #12:

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

input:

500
A 32207 954706
A 576067 592786
A 117728 458806
A 165460 529246
R 576067 592786
A 315884 799850
A 230281 974894
A 510689 824833
A 342520 902709
A 158641 808483
A 700956 847418
A 100978 425877
A 76360 575288
A 6220 995293
A 63604 586202
A 230873 993670
A 41522 213462
A 246536 727475
A 449004 92977...

output:

922499
16719
475058
427326
411518
682122
682122
707105
707105
707105
681958
681958
681958
681958
681958
681958
681958
681958
681958
681958
624642
624642
624642
624642
651025
651025
651025
651025
651025
651025
651025
367873
367873
367873
367873
235167
235167
235167
235167
235167
181297
181297
181297
...

result:

ok 500 lines

Test #13:

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

input:

500
A 306104 754196
A 214171 681395
A 105972 984762
A 94905 948643
A 292540 957380
A 754843 867779
A 745416 794633
A 34902 860261
A 20222 972411
A 110059 523930
A 397455 638101
A 64515 210449
A 22262 660198
A 11235 985854
A 244678 769170
A 457658 941789
A 2134 968210
A 423816 840352
A 2191 52569
A 2...

output:

448092
540025
540025
540025
540025
561675
561675
561675
561675
561675
397178
397178
397178
397178
397178
397178
397178
397178
208258
208258
208258
208258
208258
208258
208258
208258
208258
208258
208258
208258
208258
208258
208258
208258
208258
208258
113063
113063
113063
113063
113063
113063
113063...

result:

ok 500 lines

Test #14:

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

input:

500
A 17773 585069
A 10805 798041
A 9292 989157
A 132806 984174
A 120949 281437
A 94058 844382
A 222028 418948
A 287046 932966
A 344232 537538
A 268486 805522
A 327779 808754
A 766430 885562
A 8475 490707
A 156538 748364
A 28797 764725
A 123931 918493
A 725432 981971
A 296376 916640
A 86879 595729
A...

output:

567296
567296
567296
966401
863225
863225
297999
812017
416589
416589
416589
416589
416589
416589
416589
416589
416589
416589
416589
416589
416589
416589
416589
416589
416589
416589
416589
234238
234238
234238
234238
234238
234238
234238
234238
234238
234238
234238
234238
234238
234238
234238
234238...

result:

ok 500 lines

Test #15:

score: 0
Accepted
time: 34ms
memory: 129160kb

input:

500
A 446496 782465
A 250128 368406
A 589440 922990
A 9581 900002
A 796765 895690
A 100535 681192
A 480770 491534
A 204193 443280
A 80823 872633
A 280203 381216
A 332871 679970
A 429360 877678
A 756295 965817
A 135291 947218
A 30963 976507
A 301365 334438
A 248566 334240
A 590075 919800
A 662294 925...

output:

335969
532337
532337
532337
449194
449194
241406
241406
241406
211331
211331
211331
211331
211331
211331
190169
190169
190169
190169
190169
190169
190169
190169
190169
190169
190169
190169
190169
190169
190169
190169
190169
190169
190169
190169
190169
190169
181094
181094
181094
181094
181094
181094...

result:

ok 500 lines

Test #16:

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

input:

500
A 745 987896
A 257131 979515
A 255749 989332
A 449624 695408
A 113085 993645
A 396763 602015
A 354738 920971
A 106694 959998
A 341605 371385
A 663214 771813
A 122 990639
A 3760 993237
A 133709 962263
A 368367 686437
A 329118 922429
A 136220 881144
A 136168 926806
A 49390 692317
A 223407 609457
A...

output:

987151
722384
722384
245784
245784
298645
298645
298645
260410
260410
260410
260410
260410
260410
260410
260410
260410
260410
260410
207681
207681
207681
207681
207681
207681
207681
136143
136143
136143
136143
136143
136143
136143
136143
136143
136143
136143
136143
136143
136143
136143
136143
136143...

result:

ok 500 lines

Test #17:

score: 0
Accepted
time: 15ms
memory: 129168kb

input:

500
A 11953 695942
A 35551 731979
A 13233 934644
A 8174 954394
A 4475 959711
A 37705 77406
A 44087 45729
A 727372 740080
A 978 987857
A 1923 203498
A 126556 335611
A 57616 726164
A 108636 181849
A 327729 907228
A 34031 45718
A 68049 399000
A 9275 956024
A 37527 647862
A 252883 742199
A 9430 857336
A...

output:

683989
720026
720026
720026
720026
39701
1642
695993
695993
695993
291524
291524
137762
137762
137762
137762
137762
137762
137762
137762
137762
137762
137762
137762
137762
137762
137762
137762
137762
137762
137762
137762
137762
137762
137762
137762
137762
137762
137762
137762
137762
137762
137762
13...

result:

ok 500 lines

Test #18:

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

input:

500
A 298007 888579
A 483714 603189
A 219523 976671
A 1646 991493
A 23869 985885
A 660671 926526
A 1516 993019
A 337971 929682
A 589482 957416
A 422476 695992
A 167078 239061
A 763279 792829
A 97931 722151
A 120681 132093
A 190287 394093
A 328901 335618
A 879810 928556
A 390183 830830
A 99017 719367...

output:

590572
119475
119475
119475
119475
442812
442812
442812
442812
442812
436111
309115
309115
118380
118380
118380
118380
118380
118380
118380
118380
118380
118380
118380
118380
118380
118380
118380
118380
118380
118380
118380
118380
66850
66850
66850
66850
66850
66850
66850
66850
66850
66850
66850
668...

result:

ok 500 lines

Test #19:

score: 0
Accepted
time: 29ms
memory: 129080kb

input:

500
A 588811 753498
A 25744 954698
A 21827 606205
A 45919 960197
A 11071 907495
A 18776 990396
A 9017 942595
R 18776 990396
A 229036 314027
R 25744 954698
A 27964 272394
R 229036 314027
A 369610 990304
R 27964 272394
A 414713 642052
R 45919 960197
A 178858 900447
R 178858 900447
A 494650 630549
R 90...

output:

164687
164687
731671
731671
731671
731671
731671
731671
524462
524462
524462
725534
725534
731671
731671
731671
731671
731671
731671
731671
693965
571016
571016
571016
571016
571016
571016
571016
571016
571016
571016
571016
571016
571016
323371
214957
497837
760011
760011
760011
188669
188669
188669...

result:

ok 500 lines

Test #20:

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

input:

500
A 106057 921927
A 303014 807667
R 303014 807667
A 423054 692630
R 106057 921927
A 187145 756778
R 187145 756778
A 64120 986049
R 423054 692630
A 166967 655998
R 64120 986049
A 318687 497532
R 166967 655998
A 304167 958195
R 318687 497532
A 106187 686625
R 106187 686625
A 973469 991522
R 304167 9...

output:

815870
504653
815870
269576
269576
269576
269576
269576
921929
489031
489031
178845
178845
178845
654028
852008
654028
687355
18053
858841
18053
816179
18053
855668
18053
814268
699990
730551
699990
850070
699990
699990
902415
164646
164646
810066
189358
784977
189358
758565
189358
576279
209831
340...

result:

ok 500 lines

Test #21:

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

input:

500
A 137766 477177
A 7564 860035
A 129588 989018
A 323 937154
A 41925 795040
A 9207 260372
A 120296 557819
A 1657 880038
A 8815 168680
A 56356 998169
A 53816 776405
A 4207 888989
A 26811 75718
A 48976 56850
A 8424 913386
A 1435 966270
A 279532 596973
A 698007 884380
A 86391 540254
A 1750 41798
A 24...

output:

339411
339411
339411
339411
339411
467970
467970
467970
468362
468362
468362
468362
450366
428201
428201
428201
428201
428201
428201
55100
55100
55100
55100
55100
55100
55100
55100
55100
55100
55100
50859
50859
50859
50859
50859
50859
50859
50859
50859
50859
50859
50859
50859
50859
50859
50859
50859...

result:

ok 500 lines

Test #22:

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

input:

500
A 275582 317840
A 47056 832191
A 287663 711028
A 16255 276633
A 480611 685852
A 128995 190159
A 36668 954591
A 218862 926429
A 268916 889801
A 317450 388722
A 71382 403894
A 93695 520175
A 62 742471
A 138106 941494
A 151897 327644
A 376089 411916
A 208579 689653
A 8800 325054
A 110069 876308
A 1...

output:

42258
42258
435446
694773
410270
188845
188845
188845
188845
188845
188845
188845
188845
188845
188845
136334
136334
136334
136334
136334
136334
136334
136334
136334
136334
136334
136334
136334
136334
136334
136334
136334
136334
136334
136334
136334
136334
110239
110239
110239
110239
110239
110239
1...

result:

ok 500 lines

Test #23:

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

input:

500
A 344488 665895
A 148041 751144
A 35243 707400
A 24325 925025
A 20169 938061
A 4736 983787
A 24697 913069
A 7876 69057
A 41241 999109
A 1533 673869
R 7876 69057
A 120253 639649
R 4736 983787
R 24697 913069
R 24325 925025
A 34350 855359
A 280369 957789
A 775495 998121
R 280369 957789
A 23337 9991...

output:

321407
321407
321407
321407
321407
321407
321407
658019
658019
658019
321407
545642
545642
545642
545642
545642
545642
653633
653633
653633
653633
653633
653633
557629
450040
450040
450040
450040
450040
450040
450040
450040
433439
268053
268053
268053
268053
268053
268053
268053
268053
268053
268053...

result:

ok 500 lines

Test #24:

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

input:

500
A 1448 974037
A 495065 673867
A 337787 867021
R 337787 867021
A 229625 584134
R 229625 584134
R 495065 673867
A 126424 634218
A 2415 869749
A 90946 820247
R 126424 634218
R 90946 820247
A 633806 937354
R 2415 869749
R 1448 974037
A 459089 484543
R 459089 484543
A 344368 830604
A 926675 946450
R ...

output:

972589
178802
178802
178802
444242
178802
972589
507794
507794
507794
729301
867334
934939
303548
303548
478265
303548
592986
602082
312644
19775
19775
19775
769857
19775
19775
724126
724126
724126
724126
85698
85698
689862
689862
689862
372305
372305
814501
372305
240101
240101
240101
240101
275449...

result:

ok 500 lines

Test #25:

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

input:

500
A 193911 938608
A 85030 816054
A 329835 564575
A 114343 645838
A 304252 308629
A 472139 861625
A 450383 511626
A 514921 708694
A 427332 910230
A 845878 886647
A 705629 763425
A 237842 614707
A 456279 695717
A 399118 631058
A 84572 710775
A 599128 912563
A 378035 574380
A 263244 896316
A 827864 8...

output:

744697
853578
234740
234740
260323
260323
207374
207374
207374
207374
181018
181018
181018
181018
181018
181018
181018
181018
176785
176785
176785
176785
176785
176785
176785
176785
176785
176785
176785
176785
176785
176785
176785
176785
176785
176785
176785
176785
176785
176785
176785
176785
176785...

result:

ok 500 lines

Test #26:

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

input:

500
A 54738 868077
A 588547 875633
A 16225 80984
A 59087 522101
A 602 906079
A 13799 833381
A 165065 775393
A 38303 916902
A 22256 114177
A 12475 917423
A 127398 996588
A 777408 862424
A 21541 952174
A 386493 859793
A 8113 886191
A 550084 950433
A 2906 988632
A 12980 933884
A 301140 981816
A 50031 5...

output:

813339
820895
859408
816546
816546
816546
759168
759168
753137
753137
753137
697359
697359
697359
697359
697359
697359
697359
697359
697359
697359
697359
256263
123031
123031
123031
123031
123031
123031
123031
123031
123031
88537
88537
88537
88537
88537
88537
88537
88537
88537
88537
88537
88537
8853...

result:

ok 500 lines

Test #27:

score: 0
Accepted
time: 15ms
memory: 129168kb

input:

500
A 303428 446771
A 543675 669996
A 418270 540614
A 483641 505919
A 326605 976348
A 317975 493304
A 185995 801094
A 31748 926561
A 500905 578852
A 156433 886800
A 360038 594253
A 441527 457739
A 123491 719674
A 28229 555206
R 28229 555206
A 3473 964833
A 372239 538589
A 230944 500159
A 667860 8314...

output:

143343
366568
251726
186355
186355
186355
186355
186355
186355
186355
186355
64392
64392
64392
64392
64392
64392
64392
64392
64392
64392
64392
64392
64392
64392
64392
64392
64392
64392
64392
64392
64392
64392
64392
64392
64392
64392
64392
64392
64392
64392
64392
64392
64392
64392
64392
64392
64392
6...

result:

ok 500 lines

Test #28:

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

input:

500
A 141812 907928
A 182434 884453
A 40789 952678
A 12695 954244
R 182434 884453
A 11349 986676
A 10652 955472
R 141812 907928
A 247328 698726
A 25356 964628
A 551841 860392
A 315885 587235
A 6132 996500
A 636141 871187
A 157688 792095
A 280677 380869
A 925571 942795
A 762682 969953
A 215267 720643...

output:

766116
702019
702019
702019
766116
766116
766116
911889
451398
451398
613064
544507
544507
555302
555302
555302
306654
306654
306654
306654
306654
306654
306654
306654
306654
306654
306654
306654
306654
306654
306654
306654
306654
306654
306654
306654
306654
306654
306654
272122
272122
272122
101539...

result:

ok 500 lines

Test #29:

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

input:

500
A 6832 307527
A 341466 970802
A 149322 998864
A 177594 997810
A 357851 379382
A 68200 427730
A 21297 998990
A 340810 784235
A 41766 999403
A 108762 998749
A 16092 999326
A 170999 998204
A 11916 999712
A 108899 889310
A 51516 999692
A 1903 966825
A 96814 105662
A 164034 371725
A 87615 105130
A 17...

output:

300695
963970
963970
963970
372550
372550
372550
372550
372550
372550
372550
372550
372550
372550
372550
372550
282568
274911
274911
274911
274911
274911
274911
274911
274911
274911
274911
274911
274911
274911
274911
274911
274911
274911
274911
274911
274911
274911
274911
274911
274911
274911
192305...

result:

ok 500 lines

Test #30:

score: 0
Accepted
time: 15ms
memory: 128844kb

input:

500
A 679677 906656
A 383398 997815
A 31005 911610
A 507320 948895
A 115394 999230
A 335238 603601
A 915439 953993
A 611605 808174
A 675359 821597
A 763056 937349
A 916 947783
A 204314 953734
A 259327 696595
A 12726 999834
A 36892 825783
A 203912 962211
A 30800 720510
A 855020 940327
A 66540 999342
...

output:

226979
226979
226979
226979
226979
571418
274316
274316
274316
274316
274316
274316
274316
274316
274316
274316
274316
264968
264968
264968
264968
264968
264968
244544
244544
244544
244544
244544
244544
244544
244544
244544
243744
243744
243744
243744
243744
243744
243744
243744
132748
132748
132748...

result:

ok 500 lines

Test #31:

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

input:

500
A 350410 829666
A 211207 616646
A 502648 682639
A 282364 437940
A 126420 729288
A 66617 770209
A 115386 992988
A 371171 782557
A 664742 852771
A 133450 586677
A 128134 549444
A 858659 977535
A 6166 775106
A 446721 859623
A 1522 943671
A 92567 932848
A 305551 545600
A 16070 791346
A 348392 786505...

output:

479256
618459
471432
400275
400275
400275
400275
400275
400275
400275
400275
312793
312793
312793
312793
312793
312793
312793
312793
312793
312793
312793
312793
312793
312793
312793
312793
312793
257693
257693
257693
257693
257693
257693
257693
257693
257693
257693
257693
257693
257693
257693
257693...

result:

ok 500 lines

Test #32:

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

input:

500
A 675292 805732
A 14438 995574
A 25026 170473
A 587672 801999
A 337 996331
A 17495 137363
A 335 996697
A 4927 152665
A 101687 492834
A 1981 962554
A 16337 553396
A 200730 861951
A 364391 877081
A 431303 971034
A 507934 697729
A 524542 940120
A 79615 792406
A 536396 790749
A 16803 843367
A 437129...

output:

130440
130440
780706
776973
776973
776973
776973
776973
700312
700312
700312
700312
700312
700312
596042
596042
596042
596042
596042
596042
596042
370776
370776
334554
334554
334554
334554
334554
334554
294418
294418
294418
294418
294418
294418
294418
294418
294418
294418
294418
294418
294418
294418...

result:

ok 500 lines

Test #33:

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

input:

500
A 73484 936804
A 16710 971890
R 73484 936804
A 480498 957585
R 16710 971890
A 49942 906409
R 480498 957585
A 146475 985092
R 49942 906409
A 832504 858487
R 832504 858487
A 117500 933778
R 117500 933778
A 81653 707240
R 81653 707240
A 356971 982487
R 146475 985092
A 144518 666786
R 356971 982487
...

output:

863320
863320
955180
477087
477087
907643
856467
935150
838617
25983
838617
867592
838617
903439
838617
625516
625516
837969
522268
661763
38512
711781
679567
111966
111966
111966
111966
650920
111966
513725
231614
231614
875058
884915
875058
919263
875058
940647
553686
473293
553686
742838
553686
1...

result:

ok 500 lines

Test #34:

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

input:

500
A 42398 476588
A 92359 868724
R 42398 476588
A 604991 988947
R 92359 868724
A 60564 219738
R 60564 219738
A 369 991707
R 604991 988947
A 301167 823990
R 301167 823990
A 228034 985407
R 228034 985407
A 21268 814379
R 369 991707
A 133028 822389
R 21268 814379
A 204073 783583
R 204073 783583
A 1220...

output:

434190
826326
776365
896588
383956
928383
383956
383956
991338
522823
991338
757373
991338
793111
793111
801121
689361
579510
689361
700301
689361
750337
350242
477635
472605
575853
472605
478454
285836
670497
651065
982264
651065
886597
809696
95275
95275
658499
95275
544574
95275
95275
551494
6568...

result:

ok 500 lines

Test #35:

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

input:

500
A 100638 295546
A 192743 974300
R 100638 295546
A 63576 680836
R 192743 974300
A 55088 922034
R 55088 922034
A 252912 799106
R 252912 799106
A 13863 414676
R 63576 680836
A 306573 468779
R 306573 468779
A 454391 907459
R 13863 414676
A 9801 967647
R 9801 967647
A 792121 879100
R 454391 907459
A ...

output:

194908
873662
781557
910724
617260
617260
617260
735530
617260
666973
400813
454916
400813
893596
453068
453068
453068
86979
86979
559632
86979
559866
86979
801499
86979
532614
86979
697092
86979
86979
876769
323077
876769
486991
876769
876769
995802
106097
995802
638646
995802
154672
995802
728166
...

result:

ok 500 lines

Test #36:

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

input:

500
A 114285 960375
A 471863 829118
R 471863 829118
A 7825 690648
R 114285 960375
A 192371 231654
R 7825 690648
A 648837 819085
R 192371 231654
A 4658 666174
R 648837 819085
A 251114 615091
R 251114 615091
A 402359 880204
R 4658 666174
A 92232 997516
R 402359 880204
A 243703 996523
R 92232 997516
A ...

output:

846090
357255
846090
952550
682823
39283
39283
626714
170248
814427
661516
363977
661516
875546
477845
477845
905284
752820
752820
287579
752820
310179
310179
310179
822736
857017
822736
881376
668903
22460
22460
842825
633538
764484
633538
633538
993031
62141
62141
654855
29268
544005
397025
454439...

result:

ok 500 lines

Test #37:

score: 0
Accepted
time: 15ms
memory: 128828kb

input:

500
A 21043 984093
A 248079 963775
R 248079 963775
A 93376 957210
A 10301 474603
A 331626 810525
A 70492 974701
A 281342 956814
A 56532 833223
A 736458 987063
A 64139 975386
R 736458 987063
A 420966 565261
R 93376 957210
R 420966 565261
A 443753 749663
R 281342 956814
R 70492 974701
R 21043 984093
A...

output:

963050
715696
963050
863834
946909
800224
800224
800224
800224
976762
976762
800224
554960
554960
800224
739362
739362
739362
739362
739362
512854
512854
512854
512854
512854
512854
512854
512854
512854
512854
512854
275300
275300
275300
275300
275300
275300
275300
275300
275300
275300
275300
275300...

result:

ok 500 lines

Test #38:

score: 0
Accepted
time: 22ms
memory: 128832kb

input:

500
A 609751 859750
A 760379 804266
R 609751 859750
A 12135 997598
A 132483 369255
R 760379 804266
R 132483 369255
A 103893 621687
R 103893 621687
A 66091 791226
R 66091 791226
A 226914 569109
R 226914 569109
A 91121 981647
R 91121 981647
A 264420 485641
R 264420 485641
A 9353 967990
R 12135 997598
...

output:

249999
43887
43887
43887
671783
236772
985463
517794
985463
725135
985463
342195
985463
890526
985463
221221
985463
988245
958637
172389
644121
172389
172389
107502
488294
488294
162808
162808
405305
405305
405305
405305
383354
383354
383354
383354
383354
383354
735534
735534
735534
735534
735534
69...

result:

ok 500 lines

Test #39:

score: 0
Accepted
time: 17ms
memory: 128884kb

input:

500
A 29475 158455
A 547408 799768
R 547408 799768
A 429410 962867
R 429410 962867
A 72773 753875
A 331070 959683
R 72773 753875
R 331070 959683
A 94102 340227
A 63543 126748
A 141419 917470
A 119012 690867
R 63543 126748
R 94102 340227
A 113849 908834
R 119012 690867
A 161950 722752
R 29475 158455
...

output:

128980
770293
128980
933392
128980
724400
930208
930208
128980
310752
276684
853927
853927
887995
887995
887995
887995
693277
560802
39502
39502
39502
253314
253314
253314
253314
490922
490922
490922
490922
933067
933067
933067
933067
895377
895377
895377
97217
97217
97217
97217
97217
97217
873948
5...

result:

ok 500 lines

Test #40:

score: 0
Accepted
time: 15ms
memory: 128884kb

input:

500
A 180236 960399
A 132851 960909
A 261211 438849
R 180236 960399
R 132851 960909
A 365268 810394
A 254754 694963
R 254754 694963
R 365268 810394
A 46244 309595
R 261211 438849
A 30669 922670
A 191831 900322
R 191831 900322
R 30669 922670
A 300931 969614
R 300931 969614
A 335810 920310
A 568538 72...

output:

780163
780163
177638
177638
177638
549183
549183
549183
177638
392605
263351
263351
854078
263351
263351
923370
263351
874066
674692
674692
152398
152398
390928
425539
210859
210859
210859
210859
210859
644619
644619
210859
909698
458119
484574
189750
189750
189750
189750
275280
275280
63392
63392
6...

result:

ok 500 lines

Test #41:

score: 0
Accepted
time: 26ms
memory: 128900kb

input:

500
A 529079 933460
A 165284 787941
A 309257 800948
R 309257 800948
A 777560 840933
R 165284 787941
A 13278 797671
A 860948 946604
A 840160 966456
A 13698 821053
A 103613 966144
A 214445 629645
A 67367 977522
R 13278 797671
A 350133 830034
A 59794 908567
A 95057 518987
A 728799 886367
A 361380 88589...

output:

404381
768176
768176
768176
675649
63373
827655
169044
169044
169044
169044
169044
169044
169044
169044
169044
169044
169044
169044
169044
169044
169044
169044
169044
169044
169044
556896
556896
556896
556896
556896
531103
531103
531103
531103
437819
189719
189719
189719
189719
189719
132250
132250
...

result:

ok 500 lines

Test #42:

score: -3
Wrong Answer
time: 12ms
memory: 128824kb

input:

500
A 65176 993394
A 234698 752126
A 57673 993986
A 182470 788432
A 58838 951037
A 141893 998425
A 86207 938500
A 342026 783445
A 9648 814379
R 234698 752126
A 396294 807183
A 546832 835454
A 403272 914307
R 86207 938500
R 546832 835454
A 398157 502428
R 141893 998425
A 517744 902045
A 47073 925064
...

output:

928218
517428
517428
517428
517428
517428
517428
548747
548747
441419
465157
493428
493428
493428
572281
516150
516150
503888
503888
503888
503888
503888
503888
718491
718491
718491
482230
482230
482230
482230
482230
331946
331946
331946
331946
357672
357672
357672
357672
357672
357672
357672
357672...

result:

wrong answer 253rd lines differ - expected: '766198', found: '814595'

Subtask #2:

score: 0
Wrong Answer

Test #61:

score: 8
Accepted
time: 11ms
memory: 129092kb

input:

6
A 1 4
A 3 6
A 7 9
A 8 13
A 10 11
A 12 20

output:

3
5
6
6
4
4

result:

ok 6 lines

Test #62:

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

input:

3
A 1 9
A 6 15
A 5 10

output:

8
14
14

result:

ok 3 lines

Test #63:

score: 0
Accepted
time: 15ms
memory: 128748kb

input:

1
A 1 1000000

output:

999999

result:

ok single line: '999999'

Test #64:

score: 0
Accepted
time: 51ms
memory: 130220kb

input:

12000
A 174045 346671
A 58746 969907
A 52277 860980
A 51687 822337
A 320881 593470
A 22653 724673
A 347122 956041
A 514874 780251
A 155146 643918
A 116754 682718
A 374599 823274
A 373533 892185
A 63743 897550
A 224312 990829
A 423470 808028
A 212113 622665
A 263437 824930
A 416679 820773
A 515191 97...

output:

172626
172626
172626
172626
419425
419425
781996
606206
606206
606206
606206
606206
606206
606206
606206
606206
606206
606206
606206
606206
606206
606206
606206
606206
606206
606206
606206
606206
606206
606206
606206
606206
606206
606206
606206
606206
606206
606206
606206
606206
606206
606206
606206...

result:

ok 12000 lines

Test #65:

score: 0
Accepted
time: 44ms
memory: 129404kb

input:

12000
A 375053 948875
A 28782 831017
A 52211 937756
A 80144 303540
A 57568 955525
A 117481 966016
A 92106 774943
A 456401 788566
A 48304 887683
A 120272 532671
A 335039 490427
A 131773 461751
A 175340 859808
A 742792 956002
A 195683 690807
A 444964 948448
A 196618 213884
A 352567 814097
A 85197 7149...

output:

573822
920093
920093
868731
868731
868731
868731
708422
708422
708422
410283
410283
410283
410283
410283
410283
293809
293809
293809
293809
293809
293809
293809
293809
293809
293809
293809
293809
293809
293809
293809
293809
187217
187217
187217
187217
187217
187217
157635
157635
157635
157635
157635...

result:

ok 12000 lines

Test #66:

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

input:

12000
A 172707 791589
A 18321 972881
A 44693 902976
A 415826 678816
A 83141 342581
A 583854 704629
A 530249 872055
A 610833 923695
A 150732 828203
A 102712 316004
A 163501 823356
A 592883 741010
A 27109 968613
A 183246 463865
A 288597 951953
A 14861 822901
A 422932 959751
A 542217 751694
A 18241 875...

output:

618882
618882
618882
262990
595675
595675
595675
595675
595675
576104
576104
576104
576104
521383
521383
521383
521383
521383
521383
521383
377169
377169
377169
377169
377169
377169
377169
377169
377169
358016
358016
358016
358016
358016
358016
358016
358016
358016
358016
358016
358016
358016
358016...

result:

ok 12000 lines

Test #67:

score: 0
Accepted
time: 31ms
memory: 129464kb

input:

12000
A 35884 649685
A 764439 995061
R 35884 649685
A 473510 720163
R 473510 720163
A 1694 991467
R 1694 991467
A 2078 922894
R 764439 995061
A 67822 985273
R 67822 985273
A 188824 999642
R 2078 922894
A 176985 294251
R 188824 999642
A 31584 938679
R 31584 938679
A 206899 757444
R 206899 757444
A 38...

output:

613801
959177
230622
521551
230622
993367
230622
992983
920816
983195
920816
997564
810818
822657
117266
117266
117266
580459
117266
361632
117266
117266
117266
600615
117266
734456
721244
770936
569964
827436
337535
526807
217897
217897
648936
58239
648936
304115
648936
786882
740288
252119
252119
...

result:

ok 12000 lines

Test #68:

score: 0
Accepted
time: 46ms
memory: 129884kb

input:

12000
A 295818 322488
A 194486 958341
A 28813 921331
A 39689 732155
A 59934 947250
A 102263 994304
A 769281 889828
A 168891 836268
A 88251 777482
A 486833 853793
A 400373 650259
A 57459 937031
A 640586 847234
A 231543 640202
A 273952 769078
A 237156 734274
A 258521 775116
A 94729 522604
A 140392 321...

output:

26670
26670
26670
26670
26670
26670
594010
594010
594010
557975
354441
354441
354441
354441
354441
354441
354441
354441
354441
321340
321340
321340
258019
258019
258019
258019
258019
198469
198469
198469
195334
195334
195334
195334
195334
195334
195334
195334
195334
195334
195334
195334
195334
19533...

result:

ok 12000 lines

Test #69:

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

input:

12000
A 287096 678918
A 66955 750293
A 11278 980638
A 47754 128513
A 328262 804903
A 46563 992257
A 260778 483652
A 13155 811773
A 709373 756846
A 282832 503862
A 14936 999943
A 13245 668099
A 685672 706938
A 132960 959902
A 350293 984394
A 399165 989216
A 17675 990043
A 449275 934586
A 107269 48506...

output:

391822
391822
391822
631164
631164
631164
435898
435898
435898
435898
435898
435898
71174
71174
71174
71174
71174
71174
71174
71174
71174
71174
71174
71174
71174
71174
71174
71174
71174
71174
71174
71174
71174
71174
71174
71174
71174
71174
71174
71174
71174
71174
71174
71174
71174
71174
71174
71174
...

result:

ok 12000 lines

Test #70:

score: 0
Accepted
time: 49ms
memory: 129228kb

input:

12000
A 511406 972117
A 54145 806456
A 557224 559501
A 354989 370456
A 360970 715349
A 131872 889549
A 165249 663678
A 117428 942597
A 658215 978498
A 45390 955058
A 319579 364695
A 507525 566328
A 109962 994362
A 26377 867674
A 35924 666899
A 261992 820039
A 600630 836275
A 348494 413336
A 483194 5...

output:

460711
917972
2277
204512
204512
204512
204512
204512
204512
204512
204512
204512
204512
204512
204512
204512
204512
204512
76307
76307
76307
76307
76307
76307
76307
76307
76307
76307
76307
76307
76307
76307
76307
76307
76307
76307
76307
76307
76307
76307
76307
76307
76307
76307
76307
76307
76307
76...

result:

ok 12000 lines

Test #71:

score: -8
Wrong Answer
time: 32ms
memory: 129168kb

input:

12000
A 84821 966505
A 213856 800166
R 213856 800166
A 118271 264111
A 308831 338570
A 67502 740567
R 308831 338570
A 697562 795385
A 463548 539984
A 4098 999875
A 79386 276484
R 84821 966505
R 4098 999875
A 24058 794140
A 559517 754841
R 79386 276484
A 168780 896043
R 463548 539984
A 18528 998627
A...

output:

881684
586310
881684
145840
220299
220299
145840
677114
331837
331837
331837
331837
331837
331837
291293
291293
291293
636570
636570
636570
636570
636570
254720
429378
429378
429378
429378
429378
429378
429378
429378
429378
410588
410588
410588
413105
413105
413105
413105
413105
413105
413105
413105...

result:

wrong answer 60th lines differ - expected: '372181', found: '495316'

Subtask #3:

score: 0
Wrong Answer

Test #133:

score: 7
Accepted
time: 97ms
memory: 136020kb

input:

50000
A 407618 981209
A 14832 978274
A 21496 974294
A 159141 441444
A 103094 770273
A 133173 804558
A 243940 901651
A 590784 872146
A 158069 795070
A 114024 817376
A 7306 972394
A 156995 964178
A 126045 964369
A 23896 862655
A 405378 416054
A 634234 672082
A 369490 983098
A 83772 519426
A 699410 854...

output:

573591
966377
959713
822068
822068
822068
822068
713005
713005
713005
713005
713005
713005
713005
466768
266704
266704
266704
220208
220208
220208
220208
220208
220208
220208
122952
122952
122952
122952
122952
122952
122952
122952
122952
122952
122952
122952
122952
122952
122952
122952
122952
122952...

result:

ok 50000 lines

Test #134:

score: 0
Accepted
time: 102ms
memory: 132780kb

input:

50000
A 127499 615320
A 101672 778406
A 16006 893213
A 190368 804628
A 88084 738969
A 131974 922476
A 31690 490333
A 63501 942205
A 528227 885055
A 112111 970309
A 250 329606
A 363269 801758
A 491948 606453
A 74251 986538
A 118275 441615
A 612858 931868
A 540713 953891
A 65472 643350
A 128407 985888...

output:

487821
487821
487821
677129
677129
677129
772938
772938
853365
853365
853365
801508
574763
574763
488178
439920
439920
439920
439920
439920
439920
439920
439920
361954
361954
361954
361954
361954
361954
361954
361954
301912
301912
301912
301912
301912
229183
229183
229183
229183
229183
229183
229183...

result:

ok 50000 lines

Test #135:

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

input:

50000
A 659539 805418
A 189141 385538
A 499628 737264
A 832193 989432
A 144182 900738
A 21221 42706
A 83275 954567
A 182730 952585
A 3119 974509
A 468925 480899
A 240301 552748
A 333643 953011
A 143592 151167
A 78711 862038
A 470342 847406
A 29297 772523
A 1247 997697
A 89354 730349
A 385838 759964
...

output:

145879
616277
548123
329893
329893
329893
329893
329893
329893
268339
268339
268339
129946
129946
129946
129946
129946
129946
129946
129946
129946
129946
125961
125961
125961
125961
125961
125961
125961
125961
125961
125961
125961
125961
125961
125961
125961
125961
125961
125961
125961
125961
125961...

result:

ok 50000 lines

Test #136:

score: -7
Wrong Answer
time: 91ms
memory: 130672kb

input:

50000
A 430647 696600
A 122877 222787
A 147789 805461
A 71428 759579
A 6810 964816
R 71428 759579
A 40898 997196
R 122877 222787
A 472139 778234
R 6810 964816
A 709093 766865
R 147789 805461
A 503681 762430
R 709093 766865
A 35159 598264
R 35159 598264
A 595393 750298
R 40898 997196
A 366019 993106
...

output:

265953
573723
573723
573723
573723
573723
573723
265953
347587
347587
336218
336218
336218
331783
727271
331783
319651
319651
319651
331783
331783
331783
331783
331783
516898
331783
331783
331783
745829
745829
732755
732755
732755
745829
394034
745829
745829
745829
745829
629460
629460
660561
660561...

result:

wrong answer 1380th lines differ - expected: '671555', found: '681871'

Subtask #4:

score: 4
Accepted

Test #193:

score: 4
Accepted
time: 203ms
memory: 163544kb

input:

200000
A 1 7
A 8 14
A 15 21
A 22 28
A 29 35
A 36 42
A 43 49
A 50 56
A 57 63
A 64 70
A 71 77
A 78 84
A 85 91
A 92 98
A 99 105
A 106 112
A 113 119
A 120 126
A 127 133
A 134 140
A 141 147
A 148 154
A 155 161
A 162 168
A 169 175
A 176 182
A 183 189
A 190 196
A 197 203
A 204 210
A 211 217
A 218 224
A 225...

output:

6
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
1...

result:

ok 200000 lines

Test #194:

score: 0
Accepted
time: 182ms
memory: 164480kb

input:

200000
A 900009 900010
A 900007 900008
A 900005 900006
A 900003 900004
A 900001 900002
A 899999 900000
A 899997 899998
A 899995 899996
A 899993 899994
A 899991 899992
A 899989 899990
A 899987 899988
A 899985 899986
A 899983 899984
A 899981 899982
A 899979 899980
A 899977 899978
A 899975 899976
A 899...

output:

1
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
...

result:

ok 200000 lines

Test #195:

score: 0
Accepted
time: 388ms
memory: 199032kb

input:

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

output:

1
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
...

result:

ok 400000 lines

Test #196:

score: 0
Accepted
time: 362ms
memory: 200244kb

input:

400000
A 799999 800000
A 799997 799998
A 799995 799996
A 799993 799994
A 799991 799992
A 799989 799990
A 799987 799988
A 799985 799986
A 799983 799984
A 799981 799982
A 799979 799980
A 799977 799978
A 799975 799976
A 799973 799974
A 799971 799972
A 799969 799970
A 799967 799968
A 799965 799966
A 799...

output:

1
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
...

result:

ok 400000 lines

Test #197:

score: 0
Accepted
time: 478ms
memory: 216356kb

input:

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

output:

1
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
...

result:

ok 499999 lines

Test #198:

score: 0
Accepted
time: 472ms
memory: 216480kb

input:

499999
A 999997 999998
A 999995 999996
A 999993 999994
A 999991 999992
A 999989 999990
A 999987 999988
A 999985 999986
A 999983 999984
A 999981 999982
A 999979 999980
A 999977 999978
A 999975 999976
A 999973 999974
A 999971 999972
A 999969 999970
A 999967 999968
A 999965 999966
A 999963 999964
A 999...

output:

1
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
...

result:

ok 499999 lines

Test #199:

score: 0
Accepted
time: 815ms
memory: 160384kb

input:

500000
A 50 911
A 990 1785
A 1860 2691
A 7 29
A 34 44
A 45 46
A 2865 3234
A 1803 1842
A 47 48
A 1846 1856
A 1787 1802
A 1857 1859
A 931 982
A 1844 1845
A 2719 2824
A 30 33
A 2 4
A 2849 2855
A 2862 2864
A 5 6
A 920 925
A 983 988
A 2693 2718
A 927 930
A 915 916
A 918 919
A 912 914
A 2856 2859
A 2828 2...

output:

861
1735
1701
904
37
12
12
12
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
...

result:

ok 500000 lines

Test #200:

score: 0
Accepted
time: 596ms
memory: 151956kb

input:

500000
A 4 16
A 2 3
A 23 29
A 34 41
A 18 22
A 31 33
A 42 56
R 42 56
R 2 3
A 47 54
A 45 46
A 2 3
R 23 29
A 24 29
A 42 44
A 57 66
A 67 81
R 67 81
R 31 33
A 55 56
R 24 29
A 73 75
A 77 89
A 97 104
A 90 94
A 114 118
A 121 128
A 67 70
A 71 72
A 107 108
A 30 33
A 130 133
A 119 120
A 95 96
A 144 146
A 138 1...

output:

12
14
14
14
11
10
10
10
10
10
9
9
9
9
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
...

result:

ok 500000 lines

Test #201:

score: 0
Accepted
time: 560ms
memory: 151808kb

input:

500000
A 8 9
A 14 16
A 2 7
A 19 23
A 10 12
A 25 29
A 30 37
A 17 18
R 8 9
A 8 9
A 38 39
A 40 42
A 46 50
A 51 53
A 44 45
A 55 59
A 60 67
R 51 53
A 52 53
R 25 29
A 68 73
R 8 9
R 55 59
A 8 9
A 76 80
A 74 75
A 24 29
A 54 59
A 82 83
A 87 90
R 60 67
A 60 67
A 85 86
R 30 37
A 91 95
A 102 103
R 8 9
A 104 109...

output:

1
8
7
7
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
3
3
3
3
4
4
4
4
4
4
4
4
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
...

result:

ok 500000 lines

Test #202:

score: 0
Accepted
time: 845ms
memory: 159916kb

input:

500000
A 34 953
A 8 33
A 1098 1791
A 3 5
A 2355 2766
A 954 1093
A 3352 3687
A 1094 1097
A 2073 2233
A 2261 2321
A 6 7
A 2890 3049
A 3054 3331
A 2836 2876
A 2886 2888
A 3340 3345
A 3782 4574
A 4741 5342
A 2339 2349
A 1845 2023
A 4617 4707
A 4580 4597
A 2235 2246
A 4602 4604
A 3346 3348
A 2350 2352
A ...

output:

919
945
945
30
30
30
30
30
30
30
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3...

result:

ok 500000 lines

Test #203:

score: 0
Accepted
time: 592ms
memory: 152320kb

input:

500000
A 2 12
A 13 18
A 20 33
A 35 36
A 47 48
A 55 60
A 49 54
A 42 46
A 70 73
A 76 88
A 40 41
A 65 66
A 67 69
A 74 75
A 38 39
A 94 98
A 99 100
A 89 91
R 65 66
A 104 105
A 92 93
A 62 64
R 13 18
A 13 19
A 101 103
A 65 66
R 49 54
A 49 50
R 74 75
A 53 54
A 107 109
A 110 112
A 51 52
A 74 75
A 117 127
A 1...

output:

10
16
16
16
13
13
7
6
6
6
6
6
4
4
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
...

result:

ok 500000 lines

Test #204:

score: 0
Accepted
time: 561ms
memory: 152560kb

input:

500000
A 2 9
A 11 14
A 17 19
A 15 16
A 21 27
A 29 30
A 31 36
A 38 39
A 40 43
A 45 47
A 51 55
A 56 58
A 59 65
A 49 50
R 59 65
R 11 14
A 10 14
A 59 66
A 68 74
A 77 81
A 86 87
A 75 76
R 68 74
A 67 68
A 82 85
R 21 27
A 20 25
A 88 95
A 26 28
A 102 103
A 106 108
A 111 116
A 118 124
A 104 105
A 96 100
A 10...

output:

7
12
8
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3...

result:

ok 500000 lines

Test #205:

score: 0
Accepted
time: 786ms
memory: 160740kb

input:

500000
A 15 316
A 756 986
A 3 8
A 10 14
A 339 668
A 318 323
A 1300 1724
A 1928 2004
A 2208 2663
A 2743 3604
A 1119 1238
A 3625 4526
A 3609 3624
A 1868 1897
A 4997 5311
A 713 725
A 676 693
A 1056 1108
A 1905 1922
A 737 752
A 1736 1867
A 2060 2203
A 2022 2026
A 754 755
A 324 333
A 727 735
A 1731 1734
...

output:

301
971
313
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
8
8
8
8
4
4
4
4
4
4
4
4
4
4
4
4
4
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
...

result:

ok 500000 lines

Test #206:

score: 0
Accepted
time: 576ms
memory: 151984kb

input:

500000
A 2 16
A 22 26
A 18 21
A 35 37
A 39 48
A 50 58
A 63 72
A 76 82
A 86 87
A 90 102
A 27 32
A 104 115
A 120 124
A 84 85
A 125 130
A 73 75
A 88 89
A 33 34
R 125 130
A 59 62
R 18 21
A 129 138
A 117 119
A 127 128
R 120 124
A 17 18
A 121 124
A 142 149
A 125 126
A 155 157
R 76 82
A 19 21
A 150 152
A 1...

output:

14
24
8
8
8
8
8
8
8
8
8
8
8
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
...

result:

ok 500000 lines

Test #207:

score: 0
Accepted
time: 552ms
memory: 152516kb

input:

500000
A 2 8
A 11 14
A 16 18
A 19 25
A 9 10
A 26 31
R 16 18
A 15 17
A 33 37
A 42 43
A 44 47
A 49 53
A 38 40
R 38 40
A 38 39
A 40 41
R 9 10
R 40 41
A 54 56
A 40 41
A 9 10
A 57 64
R 11 14
A 65 70
A 12 13
R 57 64
R 38 39
A 72 77
A 80 82
R 80 82
A 78 82
A 38 39
A 57 64
A 84 89
R 72 77
A 71 75
A 90 97
R ...

output:

6
12
7
7
5
5
5
5
5
5
5
5
5
5
5
3
3
5
5
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3...

result:

ok 500000 lines

Test #208:

score: 0
Accepted
time: 653ms
memory: 140004kb

input:

499999
A 1 2
A 101 102
A 201 202
A 301 302
A 401 402
A 501 502
A 601 602
A 701 702
A 801 802
A 901 902
A 1001 1002
A 1101 1102
A 1201 1202
A 1301 1302
A 1401 1402
A 1501 1502
A 1601 1602
A 1701 1702
A 1801 1802
A 1901 1902
A 2001 2002
A 2101 2102
A 2201 2202
A 2301 2302
A 2401 2402
A 2501 2502
A 260...

output:

1
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
10...

result:

ok 499999 lines

Test #209:

score: 0
Accepted
time: 663ms
memory: 140000kb

input:

499994
A 1 2
A 101 102
A 201 202
A 301 302
A 401 402
A 501 502
A 601 602
A 701 702
A 801 802
A 901 902
A 1001 1002
A 1101 1102
A 1201 1202
A 1301 1302
A 1401 1402
A 1501 1502
A 1601 1602
A 1701 1702
A 1801 1802
A 1901 1902
A 2001 2002
A 2101 2102
A 2201 2202
A 2301 2302
A 2401 2402
A 2501 2502
A 260...

output:

1
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
10...

result:

ok 499994 lines

Test #210:

score: 0
Accepted
time: 675ms
memory: 140004kb

input:

500000
A 1 2
A 101 102
A 201 202
A 301 302
A 401 402
A 501 502
A 601 602
A 701 702
A 801 802
A 901 902
A 1001 1002
A 1101 1102
A 1201 1202
A 1301 1302
A 1401 1402
A 1501 1502
A 1601 1602
A 1701 1702
A 1801 1802
A 1901 1902
A 2001 2002
A 2101 2102
A 2201 2202
A 2301 2302
A 2401 2402
A 2501 2502
A 260...

output:

1
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
10...

result:

ok 500000 lines

Test #211:

score: 0
Accepted
time: 667ms
memory: 140208kb

input:

499995
A 1 2
A 101 102
A 201 202
A 301 302
A 401 402
A 501 502
A 601 602
A 701 702
A 801 802
A 901 902
A 1001 1002
A 1101 1102
A 1201 1202
A 1301 1302
A 1401 1402
A 1501 1502
A 1601 1602
A 1701 1702
A 1801 1802
A 1901 1902
A 2001 2002
A 2101 2102
A 2201 2202
A 2301 2302
A 2401 2402
A 2501 2502
A 260...

output:

1
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
10...

result:

ok 499995 lines

Test #212:

score: 0
Accepted
time: 671ms
memory: 140224kb

input:

499991
A 1 2
A 101 102
A 201 202
A 301 302
A 401 402
A 501 502
A 601 602
A 701 702
A 801 802
A 901 902
A 1001 1002
A 1101 1102
A 1201 1202
A 1301 1302
A 1401 1402
A 1501 1502
A 1601 1602
A 1701 1702
A 1801 1802
A 1901 1902
A 2001 2002
A 2101 2102
A 2201 2202
A 2301 2302
A 2401 2402
A 2501 2502
A 260...

output:

1
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
10...

result:

ok 499991 lines

Subtask #5:

score: 0
Wrong Answer

Test #213:

score: 3
Accepted
time: 1324ms
memory: 194444kb

input:

500000
A 177873 500336
A 457824 814681
A 841342 988692
A 419772 679383
A 932 397613
A 112565 840517
A 21558 993484
A 388360 943423
A 51953 706434
A 444776 874634
A 672973 719874
A 324528 972601
A 711851 858636
A 219651 966235
A 89897 472254
A 40578 919362
A 340868 944392
A 163582 585658
A 637082 954...

output:

322463
636808
530868
530868
530868
530868
530868
530868
530868
530868
315719
315719
315719
315719
315719
315719
315719
315719
315719
315719
315719
315719
315719
131305
131305
131305
131305
131305
131305
131305
131305
131305
131305
131305
131305
131305
131305
131305
131305
131305
131305
131305
131305...

result:

ok 500000 lines

Test #214:

score: 0
Accepted
time: 1265ms
memory: 170084kb

input:

500000
A 19984 450284
A 96761 997086
A 316867 923102
A 593966 846630
A 324820 370426
A 737058 767339
A 609035 732288
A 27614 753125
A 47817 778799
A 511932 911251
A 325127 545889
A 194006 849501
A 397366 989935
A 384642 644398
A 151785 160335
A 435217 791912
A 75861 637008
A 109997 799477
A 7242 712...

output:

430300
977102
903118
826646
521810
442519
158304
158304
158304
158304
158304
158304
158304
158304
158304
158304
158304
158304
158304
158304
158304
158304
158304
158304
158304
158304
158304
158304
158304
158304
158304
158304
158304
158304
158304
158304
158304
158304
158304
158304
158304
158304
158304...

result:

ok 500000 lines

Test #215:

score: 0
Accepted
time: 1127ms
memory: 163872kb

input:

500000
A 111685 968715
A 186277 709985
A 565791 833397
A 357566 476482
A 504529 910778
A 262851 710970
A 666814 962461
A 112848 930053
A 5291 687264
A 298473 648758
A 163948 762721
A 455591 904212
A 418733 558691
A 581238 893994
A 144080 870515
A 364468 730718
A 192074 596046
A 555574 646266
A 16634...

output:

857030
523708
647120
475831
475831
475831
475831
475831
475831
475831
475831
475831
414664
414664
414664
414664
414664
288700
288700
288700
288700
288700
288700
288700
288700
288700
288700
288700
288700
288700
288700
208576
208576
208576
208576
208576
208576
197774
197774
197774
197774
197774
197774...

result:

ok 500000 lines

Test #216:

score: -3
Wrong Answer
time: 1019ms
memory: 146096kb

input:

500000
A 558637 801931
A 294450 833269
A 153742 489961
A 127456 979454
A 55544 888378
A 440730 950479
A 12565 984056
A 528996 783709
A 213138 746144
A 91639 628875
A 553285 988400
A 576669 855051
A 192059 333695
A 141236 394580
A 382106 947539
A 64124 924508
A 778749 794755
A 755863 801496
A 55077 9...

output:

243294
243294
648189
648189
648189
648189
648189
629967
629967
629967
629967
629967
591650
591650
591650
591650
581617
581617
581617
533230
519972
519972
161687
161687
154641
154641
154641
154641
154641
154641
154641
154641
56045
56045
56045
56045
56045
56045
56045
56045
56045
56045
56045
56045
5604...

result:

wrong answer 6103rd lines differ - expected: '238552', found: '285665'