QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#36834#2447. Domino CoveringNaCly_FishAC ✓1767ms4388kbC++6.2kb2022-06-29 02:25:162024-10-07 15:52:11

Judging History

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

  • [2024-10-07 15:52:11]
  • 管理员手动重测该提交记录
  • 测评结果:AC
  • 用时:1767ms
  • 内存:4388kb
  • [2024-10-07 15:50:46]
  • 管理员手动重测该提交记录
  • 测评结果:100
  • 用时:1ms
  • 内存:3848kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-06-29 02:25:18]
  • 评测
  • 测评结果:100
  • 用时:3508ms
  • 内存:4156kb
  • [2022-06-29 02:25:16]
  • 提交

answer

#pragma GCC optimize (2)
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<ctime>
#define ll long long
#define N 10003
#define M 180
#define mid ((l+r)>>1)
using namespace std;

int siz,p;

inline int power(int a,int t){
    int res = 1;
    while(t){
        if(t&1) res = (ll)res*a%p;
        a = (ll)a*a%p;
    	t >>= 1;
    }
    return res;
}
/*
namespace Berlekamp_Massey{
    inline void add(int &x,int y){
        x += y;
        if(x>=p) x -= p;
    }

    inline void dec(int &x,int y){
        x -= y;
        if(x<0) x += p;
    }

    int cnt;
    int Fail[N],delta[N];
    vector<int> R[N];

    int solve(int n,const int *a,int *f){
		int k = 0;
        memset(Fail,0,sizeof(Fail));
        memset(delta,0,sizeof(delta));
        R[0].clear();
        cnt = 0;
        for(int i=1;i<=n;++i){
            if(cnt==0){
                if(a[i]){
                    Fail[cnt++] = i;
                    delta[i] = a[i];
                    R[cnt].resize(0);
                    R[cnt].resize(i,0);
                }
                continue;
            }
            int sum = 0,m = R[cnt].size();
            delta[i] = a[i];
            Fail[cnt] = i;
            for(int j=0;j<m;++j)
                sum = (sum+(ll)a[i-j-1]*R[cnt][j])%p;
            dec(delta[i],sum);    
            if (!delta[i]) continue;
            int id = cnt-1,v = i-Fail[id]+(int)R[id].size();
            for(int j=0;j<cnt;++j){
                if(i-Fail[j]+(int)R[j].size()<v){
                    id = j;
                    v = i-Fail[j]+(int)R[j].size();
                }
            }
            int tmp = (ll)delta[i]*power(delta[Fail[id]],p-2)%p;
            R[cnt+1] = R[cnt];
            while(R[cnt+1].size()<v) R[cnt+1].push_back(0);
            add(R[cnt+1][i-Fail[id]-1],tmp);
            for(int j=0;j<R[id].size();++j)
                dec(R[cnt+1][i-Fail[id]+j],(ll)tmp*R[id][j]%p);
            cnt++;
        }
        k = R[cnt].size();
        for(int i=1;i<=k;++i) f[i] = R[cnt][i-1];
		return k;
    }
}
*/
inline int add(const int& x,const int& y){ return x+y>=p?x+y-p:x+y; }
inline int dec(const int& x,const int& y){ return x<y?x-y+p:x-y; }

inline void mod(const int *f,const int *g,int n,int m,int *R){
	static int a[N],b[N],q[N];
	memcpy(a,f,(n+1)<<2),memcpy(b,g,(m+1)<<2);
	for(int i=n-m;~i;--i){
		q[i] = a[i+m];
		for(int j=0;j<=m;++j) 
			a[m+i-j] = (a[m+i-j]-(ll)q[i]*b[m-j])%p;
	}
	for(int i=0;i<m;++i) R[i] = a[i];
}

inline void multiply(const int *f,const int *g,int n,int m,int *r){
	static int h[N];
	memset(h,0,(n+m+1)<<2);
	for(int i=0;i<=n;++i)
	for(int j=0;j<=m;++j)
		h[i+j] = (h[i+j]+(ll)f[i]*g[j])%p;
	memcpy(r,h,(n+m+1)<<2);
}

struct complex{ 
    int a,b;
    complex(int a=0,int b=0):a(a),b(b){}

    complex operator + (const complex& x) const{
        return complex((a+x.a)%p,(b+x.b)%p);
    }
    complex operator - (const complex& x) const{
        return complex((a-x.a)%p,(b-x.b)%p);
    }
    complex operator * (const complex& x) const{
        complex res;
        return complex(((ll)a*x.a+5ll*b*x.b)%p,((ll)a*x.b+(ll)b*x.a)%p);
    }
};

inline complex power(complex a,ll t){
    complex res = complex(1,0); 
    while(t){
        if(t&1) res = res*a;
        a = a*a;
        t >>= 1;
    }
    return res;
}

inline int fib(ll n){
	if(p==2) return n%3!=0;
	int inv2 = (p+1)>>1;
	complex x = complex(inv2,inv2);
	complex y = complex(inv2,p-inv2);
	complex res = power(x,n)-power(y,n);
	return (res.b+p)%p;
}

int n,ans,lim;
ll m;
int B[36][36],D[36][36],F[M][36][36];
int g[M],cf[M];
int a[M],b[M],res[M];
int dc[36][36];

int main(){
	int T,k;
	scanf("%d",&T);
	while(T--){
		scanf("%d%lld%d",&n,&m,&p);
		if((n&1)&(m&1)){
			puts("0");
			continue;
		}
		if(n==1){
			puts("1");
			continue;
		}
		if(n==2){
			printf("%d\n",fib(m+1));
			continue;
		}
		//printf("n = %d,m = %lld\n",n,m);
		for(int i=0;i<=n;++i) dc[0][i] = 1;
		for(int i=1;i<=n;++i){
			dc[i][0] = 1;
			for(int j=1;j<=n;++j)
				dc[i][j] = ((dc[i-1][j]+dc[i][j-1])%p+dc[i-1][j-1])%p;
		}
		siz = n,lim = (n<<1)+2;		
		memset(F[0],0,sizeof(F[0]));
		memset(F[1],0,sizeof(F[1]));
		for(int i=0;i<n;++i) F[0][i][i] = 1;
		for(int i=0;i<(n-1);++i){
			F[1][i][i+1] = 1;
			F[1][i+1][i] = p-1;
		}
		for(int i=2;i<=lim;++i){
			for(int j=0;j<n;++j)
			for(int k=0;k<n;++k){
				F[i][j][k] = p-F[i-2][j][k];
				if(k-1>=0) F[i][j][k] = add(F[i][j][k],F[i-1][j][k-1]);
				if(k+1<n) F[i][j][k] = dec(F[i][j][k],F[i-1][j][k+1]);
			}
		}
		for(int i=0;i<n;++i) cf[i+1] = -dc[i][n-i];
		reverse(cf+1,cf+n+1);
		memset(a,0,sizeof(a)),memset(b,0,sizeof(b));
		memset(res,0,sizeof(res));
		//memset(a,0,(n+1)<<3),memset(b,0,(n+1)<<3);
		//memset(res,0,(n+1)<<3);
		for(int i=1;i<=n;++i) a[n-i] = p-cf[i];
		a[n] = b[1] = res[0] = 1;
		int bt = 1,rt = 0,tn = n;
		ll tm = m;
		m >>= 1;
		while(1){
			if(m&1){
				multiply(res,b,rt,bt,res);
				rt += bt;
				if(rt>=n) mod(res,a,rt,n,res);
				rt = min(rt,n-1);
			}
			m >>= 1;
			if(m==0) break;
			multiply(b,b,bt,bt,b);
			bt <<= 1;
			if(bt>=n) mod(b,a,bt<<1,n,b);
			bt = min(bt,n-1);
		}
		//for(int i=0;i<n;++i) printf("%d ",res[i]);
		//putchar('\n');
		memset(D,0,sizeof(D));
		memset(B,0,sizeof(B));
		
		for(int i=0;i<(n<<1);++i){
			if((tm&1)!=(i&1)) continue;
			for(int t=0;t<n;++t)
			for(int j=0;j<n;++j)
				D[t][j] = (D[t][j]+(ll)res[i>>1]*F[i][t][j])%p;
		}
		for(int i=0;i<n;++i){
			if((i&1)==0) continue;
			for(int j=0;j<n;++j){
				if(D[i][j]==0) continue;
				B[i>>1][j>>1] = D[i][j];
			}
		}
		n >>= 1;
		int d,flag = 1;
		for(int i=0;i<n;++i){
			int j = i;
			while(j<n&&B[j][i]==0) ++j;
			if(j==n) continue;
			if(j!=i){
				for(int k=i;k<n;++k) swap(B[i][k],B[j][k]);
				flag ^= 1;
			}
			for(j=i+1;j<n;++j){
				if(B[j][i]==0) continue;
				d = (ll)B[j][i]*power(B[i][i],p-2)%p;
				for(int k=i;k<n;++k) B[j][k] = (B[j][k]-(ll)d*B[i][k])%p;
			}
		}
		ans = 1;
		for(int i=0;i<n;++i) ans = (ll)ans*B[i][i]%p;
		if(tn%4==2||tn%4==3) ans = ((tm-1)>>1)&1?ans:-ans;
		if(flag==0) ans = p-ans;
		ans = (ans%p+p)%p;
		printf("%d\n",ans);
	}
	return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3996kb

input:

6
2 2 23
2 3 233
3 3 2333
3 4 23333
4 4 2332333
5 251346744251346744 998244353

output:

2
3
0
11
36
295381485

result:

ok 6 lines

Test #2:

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

input:

8
16 16 16661
34 27 358541
34 27 281
12 24 145601
30 31 232129
32 32 391249
2 666 514229
5 666 514229

output:

0
0
0
0
0
0
0
0

result:

ok 8 lines

Test #3:

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

input:

20000
4 747131000 1028899213
33 944626471805076524 282167341
3 958208828 291374227
5 997109836 623754041
3 605617978 868835159
3 295174586 1063408937
5 928614498 559800229
4 775389906 627795521
4 952402791 876193807
4 986743773 366013061
5 914794840 528739903
3 94794176 571500967
2 912318075 2936382...

output:

519939148
181125628
107614896
110771098
756697234
557889014
12971448
287282314
85784841
211000800
343076751
306106623
180400804
307430913
434090415
258636034
104674414
20780665
209002753
352765042
711105673
880377332
41902222
734100858
139790068
473250669
92128708
224530126
352131721
754111629
62918...

result:

ok 20000 lines

Test #4:

score: 0
Accepted
time: 923ms
memory: 4192kb

input:

20000
2 735774348 627068881
5 50880382 377843773
3 524342560 1068953923
4 543946457 874715687
5 770658174 689377049
5 594584360 357364523
30 857873313445829062 818870699
4 624666155 410174909
2 568717677 179214869
2 880538823 195014147
5 704698766 562643449
35 991914543969869538 1020526601
4 5851065...

output:

20479549
300370671
486047396
284022147
372335076
118841771
27564426
78064735
172104795
181319869
548201970
517098632
369922858
162699373
25709610
208810003
152621979
404768709
139952390
949481607
114263052
224977308
52935118
11141470
7688306
828557177
305355917
157578163
107126106
208391697
13451558...

result:

ok 20000 lines

Test #5:

score: 0
Accepted
time: 905ms
memory: 4376kb

input:

20000
5 558088752 843865859
2 676714336 147090859
2 678416093 627364121
3 693487506 154226869
3 404892078 650839729
3 697188002 409072403
5 606154662 1067477767
34 267774477316486093 752057113
5 751808228 694658611
4 900519320 828781847
5 956048754 519311029
3 779654168 498900553
4 163041364 3807275...

output:

133470674
74627186
112461132
83432116
539278562
232800717
392394437
182700082
528181010
739552857
131032721
47384782
270369049
691132036
321429608
533385135
4380823
385853277
429803530
686041965
392819240
280722879
166132894
335278572
54093534
23683845
225303654
752324046
682098345
723675904
8329856...

result:

ok 20000 lines

Test #6:

score: 0
Accepted
time: 879ms
memory: 4324kb

input:

20000
3 691344966 832767827
31 408945273246574266 1019856449
5 51173098 397648457
3 618010320 342115757
2 374639311 69026339
2 374883877 1028126809
2 642981827 660707237
3 731253278 707468149
4 203753988 67539533
5 907605630 434353823
2 546532951 290978287
3 830513482 164027971
3 927087342 874416407...

output:

156589890
472460488
150158880
283422378
66373066
528995718
201035433
350202429
11506552
83314530
264931330
126468755
829334029
638218314
111739927
308746817
216645994
192156392
201290662
72973820
499972590
285631614
949123257
358528165
520596006
5234380
802657948
297570983
43438284
895443363
5655707...

result:

ok 20000 lines

Test #7:

score: 0
Accepted
time: 887ms
memory: 4244kb

input:

20000
5 973728370 201797483
2 654732639 900626647
3 804040326 613580603
4 541085678 917123981
2 940645834 591082927
34 638468824679555856 93553897
30 803354635801821270 383268079
4 872315639 993505889
3 522931098 744391093
2 111376979 940493419
34 659115439185660376 251939579
5 725581076 665011757
2...

output:

167749093
746674586
319096291
436789465
245658819
27572544
316224156
895286172
81382531
736760797
59299931
227616493
37418516
679520065
888052275
10186249
202225875
204612121
523981520
489896269
38771645
424893440
108442928
452390919
4496359
15772783
619728136
101914189
570264350
114992759
38111416
...

result:

ok 20000 lines

Test #8:

score: 0
Accepted
time: 918ms
memory: 4340kb

input:

20000
2 752764146 634055299
5 614798588 462003827
4 690881670 652471681
5 801694902 836876107
4 45377293 944616041
3 569841788 890958713
3 783145974 387991943
3 904606224 322758739
5 557554012 724746059
4 98111112 760107913
5 839867130 140709739
3 881847794 180698989
3 937809674 302271461
34 8082314...

output:

394656096
250958398
12022548
448357218
588958987
584615860
306940858
126214663
431994826
239096128
126146009
87737620
91520565
884659743
10759104
873539121
204229653
197164070
33241717
677291488
133816118
201029549
158594828
267462097
258173379
93995607
255559556
642141307
380349564
32118561
1896804...

result:

ok 20000 lines

Test #9:

score: 0
Accepted
time: 895ms
memory: 4376kb

input:

20000
3 383812082 125018297
5 954515611628373776 21804817
3 718662286314757780 75454703
4 164188368 491077057
5 526352522 256733327
4 826345621 219089089
4 552049790 799976663
4 892514336 343168541
4 786641895 1051382317
5 512981340 795892873
5 314470486 940893997
2 685900656 655847509
2 964720837 6...

output:

65920915
20987933
53218351
133729793
81724098
198548398
357416916
232510257
325382943
393120027
405891565
629539546
117644486
274014833
41532184
211883755
686780978
609741056
9246691
6682457
335603876
726710645
670729999
448455204
454629408
79864986
352682780
218100895
28811680
708240880
589938263
7...

result:

ok 20000 lines

Test #10:

score: 0
Accepted
time: 912ms
memory: 4372kb

input:

20000
3 749921356 894004621
3 597315598 314592829
3 919253458 359727679
3 207060782 818552341
3 49636524 607688789
2 737616096 630590509
2 712721686 676405201
2 610645912 636704743
4 640343470 281801561
2 643601910 205941511
5 555341938 163366289
2 5241876 742696223
3 898452540 580595671
4 864624093...

output:

227709339
279803279
285500063
576746998
23146550
20390510
590936481
461660420
139300208
104361813
117524603
410241141
330408772
168931554
156284667
443313605
925636872
35049234
482812582
362369025
30059370
401717
754209774
352100117
712580610
637754008
642437460
270729228
80994931
306418564
21726218...

result:

ok 20000 lines

Test #11:

score: 0
Accepted
time: 901ms
memory: 4316kb

input:

20000
3 22174180 432204973
2 842960339 534222053
6 721809449339148058 618898597
2 905194586 735449521
5 519181164 921278867
4 896788878 982163603
3 649829500 96408997
4 737857450 422452507
4 500123176 913429901
4 982664702 989009773
5 582222720 463288307
3 852530422 445038289
3 736711134 558971557
3...

output:

431778396
128393359
243374111
573278147
642339023
469560795
41145635
170374109
648920168
124687344
274308034
18502299
262588175
216651666
190160762
40843499
615862566
836868214
105921076
129578820
248062756
16607602
630572960
623786092
166437225
457380493
318569383
94758306
352800348
285921863
38961...

result:

ok 20000 lines

Test #12:

score: 0
Accepted
time: 919ms
memory: 4324kb

input:

20000
4 173334352 698310187
2 544308544 949462387
4 202594506 569878741
2 812598120 611127161
3 106251594 399922477
2 528736069 958442249
2 497069956 148642993
5 582116070 207566627
2 993490502 845580191
5 950838888 939525283
3 368623666 294781301
4 527235234 966172637
5 551580226 70567213
4 2086862...

output:

134970345
393514645
454789691
138266061
197003357
340423157
139671847
68535971
2759902
401925198
7667140
240157068
42011738
1020987
829520375
460861800
610151398
72517207
339585780
431228089
198693678
162738811
388415197
64878479
38631565
334291123
88482235
429020869
272302870
147640942
37998460
851...

result:

ok 20000 lines

Test #13:

score: 0
Accepted
time: 1419ms
memory: 4240kb

input:

20000
2 699212044 1037456831
5 806688566 1069873787
2 716090804 1011430949
4 633289947 749672029
3 858726744 1048863649
5 608865850 1037085779
3 621368304 1017888307
3 962245764 1031787083
3 573335692 1038083707
4 962518368 1062089057
5 740579688 1035984727
5 679276940 1004953321
4 620616422 1064309...

output:

925831468
450734614
15687916
516983317
307544531
735920071
790845317
417919160
700682336
585508768
342307337
598466041
481878993
294952361
748519216
942183110
405321380
382594898
281581764
662115873
293742570
542415902
925867195
170670482
188814654
627344467
207131
375230335
321275304
953693222
3290...

result:

ok 20000 lines

Test #14:

score: 0
Accepted
time: 1424ms
memory: 4244kb

input:

20000
2 654977232 1016104783
3 603044174 1007597659
2 515954008 1027364491
34 864691128455135231 1073740691
2 662502924 1016804573
30 704315415534389946 1073668049
3 785810498 1039502669
3 784009428 1069868353
2 564908098 1001729713
3 884942258 60918887
4 549290685 1023165973
5 801897320 708927347
2...

output:

49311759
128339573
615764548
1056879457
41190995
384093329
556945478
974005787
898003530
166273
49137622
482837903
6636457
381867230
915980174
269951600
513767058
547229500
860761429
598731147
906280805
662317294
568171207
907680472
650420017
41584435
936412291
319435636
862854857
533775482
45867932...

result:

ok 20000 lines

Test #15:

score: 0
Accepted
time: 1421ms
memory: 4340kb

input:

20000
5 702069956 1006969289
3 670083652 1062872563
14 751461782437409319 1753
4 767035077 275097887
2 652696076 1012751921
2 925532592 1067721943
3 696059242 1030255739
3 843527798 1049027429
3 982320504 1062838477
5 809664014 1009914791
2 694346882 1038743611
32 32 1021159939
3 577351012 105704880...

output:

595596198
788283488
939
238520363
336981422
703584088
939726159
253257805
202803105
1000187740
943051659
203449973
739352504
197575285
378198467
295464763
346108426
440558978
167104801
778141613
422203177
3232003
865860422
584811116
688302293
699553123
419887746
330708986
41538104
616684290
26815655...

result:

ok 20000 lines

Test #16:

score: 0
Accepted
time: 1423ms
memory: 4376kb

input:

20000
5 602407844 1008225991
34 864691128455135231 1073740163
3 164690384 1037197981
4 793580965 841052819
2 602115395 1025110517
2 729982004 1003904581
4 794382420 1063653103
5 985432028 1068204941
4 681010384 1004673559
2 888090933 1058912783
4 797484356 1047600817
4 804672533 1041919559
3 7585981...

output:

867906783
141548553
778943426
772693747
259634945
329219233
981599707
86656357
935381191
937946860
664212320
17636122
14160650
186589465
335808834
459612384
55395774
228610469
81089182
611140935
294486897
629716387
966653670
535156574
385324233
392744806
913221695
349205346
427400019
584122709
71981...

result:

ok 20000 lines

Test #17:

score: 0
Accepted
time: 1423ms
memory: 4336kb

input:

20000
3 957229406 373168141
4 965295789 1011865663
4 906848622 1070765627
5 901228490 915041833
2 836490171 1017081203
2 955803318 1049174611
2 752212634 1060122433
5 827852874 1011200251
4 869318566 1037356849
3 655874014 1036650337
5 983618056 1061495569
4 789385917 1037135179
4 994773682 10474224...

output:

61110622
945205474
130224869
253636234
994394643
357053479
459265742
817717130
351770524
845591318
252384439
765954776
1036535914
621592411
827640914
191874532
484282229
827632847
227877826
692630746
807298634
296260080
63804953
833338099
730948994
416084490
483208263
349855854
547951277
859902663
4...

result:

ok 20000 lines

Test #18:

score: 0
Accepted
time: 1419ms
memory: 4196kb

input:

20000
34 864691128455135231 1073739949
2 972376546 1045926103
5 893476294 1061695703
35 864691128455135230 1040124259
3 844614214 1061059183
3 903584558 1051976689
2 689224165 1056543113
35 982168192004968018 1021084109
3 601981422 1046499929
5 887223946 1019756461
3 941548496 1015373929
4 764925834...

output:

261875126
505795510
1032487176
84480696
385959935
889226642
648063444
576463430
65838493
218165790
212719233
985863904
485696362
89523795
943067572
661196886
161128524
200921744
492663106
232090388
426951697
126969976
110307596
903452966
675457165
333797961
886960020
934831401
209556068
748491349
75...

result:

ok 20000 lines

Test #19:

score: 0
Accepted
time: 1422ms
memory: 4316kb

input:

20000
5 974826610 1024963963
2 653857686 883549963
4 806181882 1023824833
3 907858054 1043268833
2 617399164 1001807747
3 556508458 1054365017
1 1 1000000007
5 656111378 1036580401
34 864691128455135231 1073738563
3 866708658 1065800867
4 770922308 1029817543
3 823439010 1040730637
2 784238146 44362...

output:

894938526
429082550
813312837
373388453
970128124
281641165
0
424368400
372304945
1037917294
270542542
823699856
400882309
1029049595
18623598
295660092
203496789
756300571
289583661
531274052
537678996
942857311
558764657
680756864
543260018
51204325
382943608
136825387
929370204
175213781
86377906...

result:

ok 20000 lines

Test #20:

score: 0
Accepted
time: 1419ms
memory: 4316kb

input:

20000
4 804519820 1045376681
4 937847302 587412491
2 695600776 1006703051
5 959609376 1043483741
3 995398402 1052445841
5 589747844 1051520219
5 218154686 1054660039
31 673668285398335092 694617767
5 936244870 1024617851
5 735157336 1046688257
4 891202924 1065154943
4 825675499 1040302141
2 65027868...

output:

711841616
350311812
635046207
20063429
331214662
452177680
205143158
13658542
345985767
378835322
467298666
531170571
405697691
431889505
13574362
191171363
275780585
146965412
589695072
367610955
472651671
61719440
9453679
571242932
639107738
406709991
877436998
206865515
685759329
330276470
269787...

result:

ok 20000 lines

Test #21:

score: 0
Accepted
time: 1423ms
memory: 4276kb

input:

20000
4 953208569 1002794911
3 650588464 1054578103
4 801527429 1072078669
4 593395105 1029804481
2 828521773 1039218263
4 795220145 1061392933
2 992874304 1049421899
4 556508895 1069047479
2 980715853 1066885577
4 667519058 1065593407
5 988433496 1001722681
5 896149900 1021500721
3 932993532 100442...

output:

482060614
903783229
732169343
120679334
323062843
258661840
386590865
376894499
908225603
832470496
770594292
712584658
331869149
86296533
439835228
349602733
311412380
898317887
496774450
54814153
940305419
775554341
919689964
808316394
839840829
115965387
109933884
33212343
245590834
360793185
501...

result:

ok 20000 lines

Test #22:

score: 0
Accepted
time: 1428ms
memory: 4336kb

input:

20000
3 695860418 1064851577
5 909984642 1024590071
2 702478034 1015656679
3 832070346 1020170803
3 931276816 1069777147
5 624464668 1019025517
4 563777828 1039054439
3 70355912 1062629389
2 538334151 1043751551
4 644616259 1051984399
2 565963832 1050482821
3 489913670 1030290631
5 625001688 6518147...

output:

175636008
670951730
483405543
127343329
519459233
524024279
815773299
734679810
266201944
156563661
556277524
841321357
607188444
243626454
108744246
7651374
636855097
509810366
66494941
482058350
232780855
220305284
157636415
735388230
99671148
863972210
540368496
824555091
20145756
337198629
85541...

result:

ok 20000 lines

Test #23:

score: 0
Accepted
time: 1390ms
memory: 4320kb

input:

20000
4 712767225 1061699003
4 701419501 1039343507
4 547742550 1008187163
4 572603260 1035544199
5 736261556 1059841687
5 785006792 1008763103
5 955315382 1032205981
5 722498050 1009551373
5 891289396 1053018929
4 684434273 1034054173
5 877937392 1052219239
4 939765366 1021525669
4 709291964 103446...

output:

619662353
641213901
219257595
572397127
73772733
192356178
577724038
5333379
790872394
449050628
287962853
896743524
348384943
726052455
16170020
822589559
1000636867
510998169
316711216
574443535
412303042
47037370
111573956
830543981
304273138
815890544
942021481
469331363
746308230
398894692
5354...

result:

ok 20000 lines

Test #24:

score: 0
Accepted
time: 1389ms
memory: 4340kb

input:

20000
5 811571258 1011622727
4 953151145 1002971939
4 693751427 1008349711
4 627592827 1051285009
5 763577660 1033715087
4 649296845 1020714133
4 817189044 1034391461
5 792251878 1064653787
5 986238254 1055156647
4 748916844 1070027213
33 813307050728084294 1044674347
5 800442320 1073480123
5 868031...

output:

724995501
853731638
243312197
861256225
318072903
110864399
1012008329
633266069
792532614
910798309
677650569
1050063310
442793514
290642366
250386964
621215682
842432741
45385177
981039253
847441412
674994723
1006261088
957111191
138550
661460353
767249594
283086378
241791563
885730736
942553323
3...

result:

ok 20000 lines

Test #25:

score: 0
Accepted
time: 1387ms
memory: 4172kb

input:

20000
4 651731574 1011482621
4 823877422 1034472191
5 549416198 1013824739
4 580679767 1002083347
5 966466576 1051748923
4 804839254 1051837289
5 619885534 1004955199
5 920980850 1005076069
5 761276164 1018688611
4 761282065 1048024837
4 747781899 1019238217
5 843793778 1007972731
5 986554132 105806...

output:

982280270
861367691
794192681
221007978
98077003
472402829
588562489
123914105
972935587
282846316
626195426
40143570
191200886
421019326
934124875
236695062
620742805
144423536
650604100
70711318
283599718
408863199
895884805
139186333
616633455
121747093
388838383
913732463
409333216
904148707
573...

result:

ok 20000 lines

Test #26:

score: 0
Accepted
time: 1391ms
memory: 4324kb

input:

20000
4 859667578 1002747113
4 799303140 1005228331
5 647427008 1000076839
4 594436629 1054323847
5 833583718 1029304531
4 798233318 1000056587
4 867740971 1025230847
5 600394414 1011720937
4 898996610 1054308179
4 966826313 1073102047
4 973989409 1008560437
5 962768584 1059271117
5 700327580 101402...

output:

275212697
730143598
518962810
769121653
25800678
385255043
352927154
730217210
769779243
777259647
716722907
537037053
659964292
105555981
112791347
819429079
1006450350
459009050
832733618
319859193
850834154
203137350
190229799
845320539
528052675
910696787
827545365
384574016
790513062
569099086
...

result:

ok 20000 lines

Test #27:

score: 0
Accepted
time: 1387ms
memory: 4320kb

input:

20000
5 719475966 1040053471
5 839039950 1026812209
5 607194156 1072722857
4 632361271 1044835537
5 631605696 1068834629
4 558562466 1011539999
5 632488644 1001839777
5 660590658 1018038269
5 822563394 1020756937
4 944365225 1044497929
5 763367826 1042031047
5 937207708 1047444371
4 804888969 102309...

output:

826726270
183329898
30926951
875827122
542830237
163033134
126131886
655955015
810889544
60848807
737770006
435860392
709111178
567020997
871271517
878558276
767130864
999903814
698425638
898302458
912059901
966026895
218322523
629735676
390269954
928824508
130784177
796832577
115965635
297645670
76...

result:

ok 20000 lines

Test #28:

score: 0
Accepted
time: 1390ms
memory: 4384kb

input:

20000
4 979436939 1014107093
4 895395733 1030709789
5 748727860 1055755391
4 869383871 1052460823
5 666005000 1064635123
5 868891798 1046349431
4 841409219 1022435807
4 974497458 1003677391
5 828241080 1009120781
5 800574620 1046424173
5 696062930 1034633969
35 985796595277823596 1056701941
5 674142...

output:

864738537
914283732
609457706
125137703
998738030
471420485
897685691
119663179
219947784
567680027
134561954
104774102
885478076
486935960
719346000
130183355
106230972
883022761
91346689
378822796
188830039
181422476
905978875
518687083
175316367
894388941
408410983
951845949
779784893
400830858
9...

result:

ok 20000 lines

Test #29:

score: 0
Accepted
time: 1396ms
memory: 4380kb

input:

20000
5 767475856 1001483947
5 969996826 1027203839
5 568735408 1008736583
4 919550558 1067366087
33 827678802486481630 1007910793
5 921710824 1052797651
5 565228312 1016383309
4 971836052 1024237121
34 783932377107869933 1036512859
4 929217071 1010295863
4 590934364 1052908607
4 717459966 106436912...

output:

303467430
822542681
428533297
821856022
423747301
1004274146
937543036
89527446
774947688
797615774
569966008
269401236
417196206
338593177
820575107
882158143
374422124
210007744
900633924
529633191
982751942
900829877
770869991
230523792
373353571
549865982
866188439
679628318
866372286
178889738
...

result:

ok 20000 lines

Test #30:

score: 0
Accepted
time: 1392ms
memory: 4200kb

input:

20000
4 991168475 1024172767
5 591753644 1046925337
5 759362636 1062185827
4 687054729 1020668681
4 984659123 1032000967
4 999984339 1018063027
5 609014272 1043938963
4 684053132 1011540109
4 847619992 1034155937
5 953497476 1011295189
5 647469810 1039049113
4 847817651 1034491643
5 649376532 106453...

output:

898550094
99578606
785316391
723926126
786621225
961918185
852213564
126336248
1006812975
735971797
390985648
817311079
47970057
195930150
297990071
383303475
436642871
316767795
894390894
348028494
556104395
941905185
690754750
521416963
225143418
92182622
649740222
502664166
269045167
758937078
89...

result:

ok 20000 lines

Test #31:

score: 0
Accepted
time: 1387ms
memory: 4268kb

input:

20000
4 694549713 1073444873
34 680053246661639646 1069028581
4 951339853 1015050893
34 872177819547330626 1005592169
4 657797329 1043946331
4 940112845 1067009381
5 658795282 1042206223
5 900905616 1017127667
5 812000924 1049143493
5 654023070 1069039421
4 681974235 1045656643
5 773341542 106567946...

output:

1046590991
1067782642
857048575
271508203
104951819
815603522
938264324
11718738
564952853
500719463
763836864
181756560
369751386
27550559
8434025
4444905
542934934
718756422
124400298
501029279
884249114
630085961
186196240
527462104
607442268
940279707
32790443
908689734
449061767
476559394
10852...

result:

ok 20000 lines

Test #32:

score: 0
Accepted
time: 1396ms
memory: 4276kb

input:

20000
5 596795418 1023642511
5 540607396 1073010013
5 739192490 1032236033
4 861309696 1004833303
4 816760555 1024968569
5 883628634 1067041211
4 807848597 1014810571
4 580406238 1037303609
4 624720754 1032097057
4 791419208 1062387169
5 972177734 1047196859
4 765938941 1051510267
5 956149576 106100...

output:

737670700
149798822
575182234
198533457
520600878
80477377
502058260
980140294
135524190
990942561
384121329
963912022
838002732
900927624
389063103
989513782
712039975
855989931
644257139
158152531
336319368
982589950
879767197
304738149
927494962
1032769150
535726312
904090599
607042317
562454922
...

result:

ok 20000 lines

Test #33:

score: 0
Accepted
time: 1761ms
memory: 4372kb

input:

20000
5 805306366 1044572471
5 939524094 1014990959
5 805306366 1037874661
5 805306366 1050835813
5 939524094 1021127897
5 805306366 1045869691
5 805306366 1025228179
5 805306366 1009915363
5 805306366 1040995597
5 939524094 1054638119
5 939524094 1019975897
5 805306366 1030502773
5 805306366 101974...

output:

705651429
648123333
649509235
304997120
12490406
500531584
864850137
156340206
674726255
342351290
46137256
56837947
816024008
320986640
603805734
421457263
847592205
775377968
658892596
780652931
872887691
125535474
843414679
190389567
157111088
643087649
172389199
345132554
674545579
502576345
617...

result:

ok 20000 lines

Test #34:

score: 0
Accepted
time: 1762ms
memory: 4340kb

input:

20000
5 939524094 1065871843
5 805306366 1047289769
5 805306366 1005839489
5 805306366 1002376709
5 805306366 1021633813
5 805306366 1018611487
5 939524094 1006101023
5 805306366 1016413507
5 939524094 1001468269
5 939524094 1012281887
5 805306366 1031845361
5 939524094 1071259313
5 805306366 104723...

output:

767984497
103272873
195271692
848968277
768078720
750380
961453823
752229086
26116868
435893358
991901729
642097566
371069822
117246585
624314188
14865292
880818287
392256953
300233220
309748743
423281336
790007248
220668119
486567837
216818970
739081406
78113291
392583287
982296337
975093321
912833...

result:

ok 20000 lines

Test #35:

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

input:

20000
5 805306366 1069538941
5 805306366 1046959499
5 805306366 1029558461
5 939524094 1030105187
5 939524094 1030256833
5 939524094 1003192103
5 939524094 1015810427
5 939524094 1020396607
5 805306366 1038871549
5 805306366 1069189073
5 805306366 1052054203
5 805306366 1045007773
5 939524094 103165...

output:

25630150
156473120
918272936
165141973
114807171
78669751
369870072
618197912
516391497
353677217
216308202
685266614
222423259
463662681
174113458
877663132
915470485
133071911
351080443
639757076
364152571
14542519
909999654
547848853
720796076
546655162
739622449
1007206248
539041852
689150237
83...

result:

ok 20000 lines

Test #36:

score: 0
Accepted
time: 1763ms
memory: 4276kb

input:

20000
5 939524094 1057245919
5 805306366 1023942347
5 939524094 1037362877
35 864691128455135230 1006479181
5 939524094 1019740987
5 939524094 1050184879
5 805306366 1024007143
5 939524094 1035241447
5 805306366 1006518427
5 939524094 1019658259
5 805306366 1054204523
5 939524094 1065766813
5 939524...

output:

100184945
128437073
827185962
419843662
568026670
821921029
787753674
953004927
766059454
867921860
365809856
426860590
314849256
314680395
843934225
173289855
351891951
570192831
463571016
807302827
447279512
586381921
37114081
294005074
468428310
709388589
614613720
690897081
815614717
565476831
2...

result:

ok 20000 lines

Test #37:

score: 0
Accepted
time: 1762ms
memory: 4388kb

input:

20000
5 805306366 1029585343
5 939524094 1015006591
5 805306366 1049687239
5 939524094 1050573907
5 805306366 1002791963
5 939524094 1022996393
5 939524094 1012550269
5 939524094 1051088977
5 939524094 1011958253
5 939524094 1071613021
5 939524094 1051825937
5 939524094 1058689691
5 939524094 105707...

output:

508492990
930581443
1048750424
457282677
313674825
193954132
563539623
450598007
744151161
654874144
797489303
379858782
408645057
43547440
146326558
420398826
13542292
644770062
877806323
573410767
675778428
920638046
229157303
755177911
971942274
1033647825
318931330
83098361
129063311
71181260
52...

result:

ok 20000 lines

Test #38:

score: 0
Accepted
time: 1762ms
memory: 4380kb

input:

20000
5 805306366 1063080281
5 805306366 1017975527
5 939524094 1021541167
5 939524094 1067813449
5 805306366 1060246153
5 805306366 1051270907
35 864691128455135230 1055091409
5 805306366 1026124667
5 939524094 1005395933
5 805306366 1015134007
5 939524094 1014721723
5 805306366 1059996317
5 939524...

output:

505001801
330888916
145516811
1020886713
60360669
502349491
150583886
498471355
18037475
640999839
509231834
116889642
715350703
277531994
401252974
904338046
955561006
136611100
687674871
886920762
468029796
734060644
693217322
441102081
402219843
706307372
951085158
245880384
104326835
904907071
2...

result:

ok 20000 lines

Test #39:

score: 0
Accepted
time: 1762ms
memory: 4336kb

input:

20000
5 939524094 1050990767
5 805306366 1020135203
5 939524094 1003296269
5 805306366 1054908383
5 805306366 1002530147
35 864691128455135230 1008160513
5 939524094 1067643821
5 805306366 1023367099
5 805306366 1017957709
5 939524094 1070490353
5 939524094 1020572209
5 805306366 1053323567
5 939524...

output:

903145331
896695770
850663528
981365455
474157925
635012511
890144971
29033211
113933663
340944671
134431668
980063569
275135436
625783489
216737839
667313616
281425467
137042326
640291687
33782983
747412072
733085021
896452255
306947636
264556615
297973182
342464474
309373243
505382854
1049692101
1...

result:

ok 20000 lines

Test #40:

score: 0
Accepted
time: 1767ms
memory: 4324kb

input:

20000
35 864691128455135230 1050244253
5 939524094 1054860949
5 805306366 1009210607
5 939524094 1053332639
5 939524094 1072178011
5 805306366 1065765563
5 939524094 1071305971
5 805306366 1014589097
5 939524094 1025356729
5 805306366 1015762883
5 805306366 1030348589
5 805306366 1044629477
5 805306...

output:

109016552
351842905
638398740
286870840
544583051
319150530
124039406
374912431
392965362
353982865
391662455
849173855
220734457
79159813
623694385
578414190
776814547
467328576
701589410
426332926
272313272
301565287
205230992
120031411
866654239
106242137
326136445
658158185
603198812
493716307
1...

result:

ok 20000 lines

Test #41:

score: 0
Accepted
time: 1758ms
memory: 4316kb

input:

20000
5 939524094 1030346719
5 805306366 1044377933
5 805306366 1016609287
5 939524094 1006745413
5 805306366 1005292987
5 805306366 1048911761
5 805306366 1061759011
5 939524094 1003354171
5 805306366 1032662311
5 939524094 1016835541
5 939524094 1034336201
35 864691128455135230 1023811531
5 805306...

output:

986014894
911666415
802086235
391817854
278366803
671878103
348042649
797285174
137178483
122399819
205302241
64121194
108653491
81133790
483998461
106542389
592658763
434273671
989144356
935428452
825180142
1005894588
740027223
695514917
600580471
183310562
365721998
628024051
1021439646
461911624
...

result:

ok 20000 lines

Test #42:

score: 0
Accepted
time: 1763ms
memory: 4372kb

input:

20000
5 939524094 1034220023
5 939524094 1020678821
5 805306366 1062043933
35 864691128455135230 1023794141
5 805306366 1038065419
35 864691128455135230 1026998653
5 805306366 1019175359
35 864691128455135230 1041539269
5 805306366 1059631487
35 864691128455135230 1005185009
5 805306366 1024667851
5...

output:

1019805797
925818585
689045887
362004191
258124620
553234559
296340329
631689402
669005840
925732087
480284470
19433438
1033679413
747200186
50267255
793477508
513793246
807050910
161530653
1027900221
310415174
102499349
743278190
561709129
854056912
595840952
249626522
925246261
634720581
538957936...

result:

ok 20000 lines

Test #43:

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

input:

20000
4 805306367 1048443787
4 805306367 1061426953
4 939524095 1027548679
4 939524095 1014022327
4 939524095 1032784757
4 939524095 1039302227
4 805306367 1047652747
4 805306367 1019591273
4 939524095 1073248723
4 805306367 1071416029
4 805306367 1017186743
4 939524095 1052601973
4 939524095 104614...

output:

269267819
957801733
282233659
245263748
945324093
417187953
875162502
653194628
435175946
883153255
148276380
23666172
920150460
209649764
545263308
84339780
314788863
406876308
5844882
290597247
667163745
619162080
444202060
581703615
967356969
248942751
644246029
304450334
719197625
635539075
3654...

result:

ok 20000 lines

Test #44:

score: 0
Accepted
time: 1595ms
memory: 4372kb

input:

20000
4 805306367 1029272861
4 805306367 1030741337
4 805306367 1003284013
4 939524095 1027537739
4 805306367 1013648287
4 805306367 1011911137
4 939524095 1064426641
4 939524095 1048623041
4 939524095 1020706789
4 805306367 1040079647
4 805306367 1055835437
4 939524095 1039834897
4 805306367 103080...

output:

589573337
305501742
911352083
951641567
638800714
914198631
876484927
210344400
627335839
1002385696
442119198
378754875
512147869
253933597
433540692
718138458
127530884
526355913
109299971
408965865
448128370
221387375
764173503
89420421
726777678
214827280
11883487
38614520
106785668
633627831
91...

result:

ok 20000 lines

Test #45:

score: 0
Accepted
time: 1591ms
memory: 4228kb

input:

20000
4 805306367 1003790129
4 805306367 1019943439
4 939524095 1069750951
4 805306367 1050718103
4 939524095 1021139489
4 805306367 1067678497
4 805306367 1072595369
34 864691128455135231 1058725693
4 805306367 1037368847
4 939524095 1020257467
4 805306367 1055127131
4 939524095 1013225567
4 805306...

output:

421315039
983831765
120164585
707365052
90343375
400715139
654780417
752779605
694244806
412175340
900738570
852408910
1027295809
23519641
164832184
564802966
450473045
827736936
726361980
142662027
124563838
254383775
835963923
567883380
428727579
1029365235
489001278
970231196
795449093
82754603
2...

result:

ok 20000 lines

Test #46:

score: 0
Accepted
time: 1599ms
memory: 4264kb

input:

20000
4 939524095 1022989829
4 805306367 1014627767
4 805306367 1036542323
4 939524095 1005710291
4 805306367 1047271931
4 805306367 1006448701
4 805306367 1058131313
4 939524095 1028804209
4 939524095 1061523119
4 805306367 1017822931
4 939524095 1057717663
4 805306367 1011429311
4 805306367 103719...

output:

189190063
588728456
239540319
601524059
771594720
730093845
947060965
801996563
780411954
134761859
49099272
123183509
178775068
196323310
397152360
442046507
940561718
933618750
42587207
222336036
174161069
331240116
124953800
891214308
391266342
230338476
247638446
1021053936
292369261
167663758
2...

result:

ok 20000 lines

Test #47:

score: 0
Accepted
time: 1596ms
memory: 4324kb

input:

20000
4 805306367 1005551843
4 805306367 1038278027
4 805306367 1072696763
4 805306367 1045891037
4 805306367 1006425659
4 805306367 1003993897
4 805306367 1031080793
34 864691128455135231 1032639793
4 939524095 1014023629
4 805306367 1009565707
4 939524095 1048444223
4 939524095 1029279079
4 805306...

output:

494960057
487258997
1635989
414880579
530881348
957295850
79435090
726828364
733982807
209156269
231808715
865672884
236984357
254571775
352863791
615227994
546078804
994326933
643377529
635282447
289567631
83202825
853115768
70941548
561808042
717879332
775303657
576364560
786147887
447274221
25477...

result:

ok 20000 lines

Test #48:

score: 0
Accepted
time: 1596ms
memory: 4324kb

input:

20000
4 805306367 1000697861
4 939524095 1065430243
34 864691128455135231 1038491807
4 939524095 1062316799
4 939524095 1042284457
4 939524095 1034549903
4 939524095 1011796699
4 939524095 1015168859
4 805306367 1023558157
4 939524095 1009392031
4 805306367 1039697177
4 805306367 1039080617
4 939524...

output:

482273915
829406099
744852623
706059990
1010851685
820542295
939514798
42251990
752267760
898874564
772573250
715121162
45847503
615128146
627000057
412160415
663360094
918682256
842349261
162733734
539991101
336731871
466279414
603153542
646065473
488006078
336515999
952750597
199007211
272438159
7...

result:

ok 20000 lines

Test #49:

score: 0
Accepted
time: 1596ms
memory: 4328kb

input:

20000
4 939524095 1014401833
4 939524095 1024217407
4 939524095 1045141261
4 805306367 1019530951
4 805306367 1012857239
4 939524095 1035207539
4 939524095 1015120313
4 805306367 1013558543
4 805306367 1062156301
4 805306367 1000648211
4 805306367 1024968031
4 939524095 1027837843
4 939524095 101959...

output:

251902236
401540832
472151658
565369539
699933229
677671625
180639496
499488883
305679352
131112298
926793288
538038161
116039607
472663639
333285591
833664168
374187449
99695158
200497875
464298644
523047060
146813615
381236812
362940273
588043386
896197679
667790479
963975295
277834849
363292439
9...

result:

ok 20000 lines

Test #50:

score: 0
Accepted
time: 1596ms
memory: 4376kb

input:

20000
4 805306367 1029879491
34 864691128455135231 1020199643
4 939524095 1001652569
4 805306367 1007983043
4 939524095 1058450201
4 805306367 1012571893
4 805306367 1056975743
4 939524095 1033232327
4 805306367 1039608407
4 939524095 1019438549
4 805306367 1061227103
4 939524095 1052432291
4 939524...

output:

849192014
85591446
988390258
399874197
737005152
913823587
276860463
407310323
689857473
620449448
226612801
133568520
323667678
429801507
21616127
40192311
462012021
556741397
95816136
546667598
211207400
903014527
453358564
708271530
247092370
773123130
121399115
115993998
58363500
828331214
75763...

result:

ok 20000 lines

Test #51:

score: 0
Accepted
time: 1592ms
memory: 4332kb

input:

20000
4 939524095 1064359213
4 939524095 1071809041
4 805306367 1024634173
4 939524095 1032467003
4 939524095 1007356541
4 805306367 1055044061
4 805306367 1059359827
4 939524095 1050349457
4 805306367 1054943629
4 805306367 1001671277
4 805306367 1026855847
4 805306367 1051002143
4 939524095 100259...

output:

222835706
578883485
365623592
114160079
749520232
319862880
1042405232
114675315
550833805
193629342
1010705432
364247951
722774007
16031717
588078271
916252495
925163111
268739840
829584205
535996643
105555001
139660928
553155730
367832893
364056913
266414964
672100171
14000957
425999685
624641888
...

result:

ok 20000 lines

Test #52:

score: 0
Accepted
time: 1596ms
memory: 4236kb

input:

20000
4 805306367 1017492029
4 805306367 1019112433
4 939524095 1003763567
4 805306367 1026001219
4 939524095 1051906223
4 939524095 1030177457
4 805306367 1048034401
4 939524095 1002105803
4 939524095 1043996389
4 805306367 1026517777
4 805306367 1027030913
4 939524095 1031243821
4 805306367 105431...

output:

739132582
147253161
245850379
365547243
746618286
542712752
682301110
388543744
634645645
296818519
295460558
583618459
427540296
709148475
298032130
428664688
185967171
350562659
484164135
576537543
670063847
660445314
474426162
499254938
903571402
219507641
575909409
499994127
712098204
910536288
...

result:

ok 20000 lines

Test #53:

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

input:

20000
3 319075986 789933323
5 574363192 316464859
3 820837638 1044634841
4 665053381 830691067
1 669047608 791355353
5 59959602 106723517
1 631889068 814270621
3 956168800 184807393
2 389452349 299943277
1 666024808 153631453
5 735965700 1026102043
2 922950164 751156019
2 680276372 458325323
2 73871...

output:

101112043
197619328
895658740
756369927
1
17999910
1
78393690
74332305
1
152902549
198354429
374355782
145340065
58199024
736014428
596165203
1
1
360259336
51853663
40605592
209237075
684266733
52226260
680092954
171153929
73058018
41445630
859483166
84799227
236816887
54562594
4222959
586071904
532...

result:

ok 20000 lines

Test #54:

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

input:

20000
1 359935610 386021203
3 860399910 616529899
4 985702397 1041677911
1 408457074 31874957
2 221088886 479314793
4 590486624 597293381
1 229184652 7671163
2 850160624 701376419
1 236447458 540889189
5 877121694 936299363
5 337352526 598282837
2 972096224 648277519
2 442091733 792125161
4 63314967...

output:

1
7060178
491636162
1
37934692
52567493
1
347798175
1
415765124
293202395
171491137
681043805
173842699
1
167359540
230804882
469225750
114622121
1
108468471
159244959
113345252
1
296273962
400285206
388410020
715434798
1
236542182
1
1
164812309
44750108
151200370
1000910
43603309
207199288
306966
1...

result:

ok 20000 lines

Test #55:

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

input:

20000
3 921845764 477487063
1 820552244 122992697
3 140742766 921350303
2 609608209720787594 682206947
1 806060552 408779711
3 764353104 566731241
3 725351556 237853619
4 225439709 586048681
4 998762190 555839117
5 193096910 350219299
1 933883814 289277731
1 316929320 355225361
1 405203184 286191127...

output:

13934937
1
157522986
263364239
1
364981870
165865258
266286041
528960270
310976451
1
1
1
1
178424025
785334698
2898375
187232416
416756618
236079012
610870
291522441
149206520
29366326
320162336
212811302
69364322
50396274
7911579
230843977
1
1
797458031
225065661
13274973
1
234517052
1
836004090
1
...

result:

ok 20000 lines

Test #56:

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

input:

20000
4 209727315 260809589
2 381948106 611349997
2 547297356 96271589
2 37542416 243656299
3 925467302 83574713
1 169052596 417919813
4 576101558 1059697577
3 928981780 306106651
4 335599939 520180747
3 269591184 656910193
4 535276176 622638377
5 675064152 328314709
4 880099027 479551447
3 73497995...

output:

186611799
609296835
85517631
166408784
69961753
1
123418448
149469480
42853906
569007343
101979113
327329304
322440765
253914095
1
304365583
1
6830942
1
83553331
90913437
56866049
634022884
98697359
136088612
1
131828609
275911916
349792277
498489090
217857306
135343098
392825675
17176464
293326777
...

result:

ok 20000 lines

Test #57:

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

input:

20000
4 667409143 43537853
4 749432709 1041648007
4 999863318 757603807
5 572368634 735426959
3 58426328 510217049
4 71623953 722138653
2 283722762 498691093
1 476575342 423849241
2 942905566 1041658913
1 174874126 982104367
2 590264307 300802973
4 820411226 548593579
2 123233309 244326713
2 9843291...

output:

14451378
555811669
675392083
16164558
22839515
404238035
118738608
1
260304538
1
250008986
501505710
69636200
242956842
1
351506346
410658226
1
682578921
1
1
1
642549961
609151757
617463848
1
790686096
171723650
1
171441511
287933476
82581642
389014102
607355065
510916766
1
877791350
244547678
37000...

result:

ok 20000 lines

Test #58:

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

input:

20000
2 905142199 332958797
2 443328695 368230133
4 167003713 406329289
2 39168117 130890763
2 442968035 639179747
4 646802278 858336377
4 902461847 435553409
1 667897220 276077777
3 73767946 252020029
4 811956080 345182659
4 701555069 1009343723
5 585142214 943224637
1 448492286 26979607
3 13006957...

output:

263275448
217833049
258550695
45297797
235662838
43464736
24800593
1
55275780
9634566
787287964
527742037
1
159011043
430208539
365545302
619854042
164143076
438864055
274039664
2157581
1381465
46915419
449789605
8297892
1714403
2917590
56812128
302652413
238030456
287172678
4140953
274605497
134177...

result:

ok 20000 lines

Test #59:

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

input:

20000
2 594361400 315541231
4 490375297 1003260289
2 163326337 128936693
4 959973800 694278479
7 17467596095703284 694239881
1 709147816 64648357
5 527626854 602408857
4 611824350 752087201
3 499507772 732751847
7 933615168293596630 776310419
3 761214748 400631447
3 437358754 158425793
5 849191634 6...

output:

44757812
141207674
75357459
109944876
678033596
1
180113368
675401321
558939543
217881240
4458994
104040964
191572254
772372070
1
204844412
147422191
460949602
395381137
264291455
70581197
1
1
428354
82649904
716502199
124031594
531453708
17691067
374059501
405524786
1
240052847
155250232
334015865
...

result:

ok 20000 lines

Test #60:

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

input:

20000
1 694280438 960507773
6 940870741754469865 22918297
1 906046244 397971671
3 433436762 215595763
3 827261934 361918841
1 876177752 609686659
2 448156160 26555657
5 499059734 1005887041
1 980283782 784201021
1 585666648 6259301
4 473953203 805078271
2 966780509 343167529
5 583401770 839886967
5 ...

output:

1
4859339
1
103788773
267041116
1
19069122
849990963
1
1
335011756
211231295
427562148
346565635
85883533
483377199
109933202
1
57571576
132573462
268599488
105214561
1
427670872
10365057
406552784
313026685
50717332
340337750
11847666
28998653
55516315
262687533
93363055
512157989
289436684
3794972...

result:

ok 20000 lines

Test #61:

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

input:

20000
3 821677256 466039039
5 689965474 896056907
5 34582190 849497587
5 635353824 916722901
2 458721375 920509001
4 185135793 203314259
2 429065650 18980629
3 768953506 771975583
5 600326950 914082511
3 797488972 634989877
5 459678470 883924651
3 515163088 876781517
5 724256108 1000166837
4 8842342...

output:

334105383
762303960
315180197
102328168
759369874
115161262
5648131
258276138
620895205
125910334
77121784
678042419
722299697
19592888
117312771
53598802
585180711
37361523
97049593
108351595
415732798
30815044
1
107249272
476826615
77207424
14443952
45619598
1
150173503
288675731
199320539
6168552...

result:

ok 20000 lines

Test #62:

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

input:

20000
2 993533615 260822647
1 124826406 523738931
1 702131302 446451743
3 474110796 444177233
8 233621050424278411 149244197
5 876915630 444699259
5 9112120 141711683
3 621526894 270449423
3 419144162 182430397
1 155675424 336960847
1 178553640 412152733
5 448522316 246224527
4 454328693 286899337
5...

output:

103777851
1
1
256694654
72975334
126794430
55459370
228008951
75140106
1
1
89487560
184948470
26046697
167264998
110215628
58856681
1
111666891
98252649
114874938
381619647
182521042
1
613095536
263374275
1
248352077
114982889
1
61677793
138329071
526569441
36028053
371213168
573407663
634946581
308...

result:

ok 20000 lines

Test #63:

score: 0
Accepted
time: 301ms
memory: 4232kb

input:

20000
1 13352 5
1 35598 5
1 31830 7
1 24144 5
1 31086 2
1 23954 2
1 31038 3
1 8840 5
1 8112 5
1 1366 5
1 126 7
1 30826 7
31 1994 2
1 20950 7
1 1194 2
1 25720 3
1 1628 5
1 6216 5
1 31094 3
1 12500 7
1 5228 3
1 22586 2
1 24888 3
1 18260 7
1 35722 2
1 9450 3
1 21706 2
1 10308 7
1 4920 3
1 12770 3
31 50...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
4
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 20000 lines

Test #64:

score: 0
Accepted
time: 305ms
memory: 4300kb

input:

20000
1 8298 71
1 13810 11
1 24350 53
1 37366 59
1 36234 5
1 13642 3
1 10900 23
1 336 89
1 17776 97
1 28186 23
1 11568 53
1 15244 13
1 9270 67
1 11882 13
1 31990 2
1 30010 17
1 30432 5
1 33088 3
31 1386 67
1 21454 89
1 21264 23
1 13218 73
1 23584 41
1 36798 83
1 35748 41
1 28730 61
1 26162 79
1 6262...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
61
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
12
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
3
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
11
1
1
1
1
1
1
1
1
1
1
1
1
1
9
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
3
1
1
1
1
1
1
1
1
1
1
1
1
1...

result:

ok 20000 lines

Test #65:

score: 0
Accepted
time: 308ms
memory: 4288kb

input:

20000
1 18800 71
31 434 421
1 15262 919
1 2038 661
1 3242 907
1 26456 661
1 16318 359
1 15434 491
1 8262 461
1 36898 317
1 28596 997
1 5204 5
1 37740 977
1 33238 883
1 278 907
1 24978 101
1 32590 211
1 16432 431
31 606 757
1 37914 719
1 17744 563
1 4824 293
1 10074 2
1 37902 73
31 46 3
1 15370 467
1...

output:

1
339
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
470
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
431
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
334
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 20000 lines

Test #66:

score: 0
Accepted
time: 312ms
memory: 4164kb

input:

20000
1 10280 4273
1 35812 743
1 2324 8969
1 17036 1109
1 35508 7673
1 21292 5641
1 30156 947
1 15552 7477
1 6898 6197
1 4500 1609
1 15934 9859
1 7264 4423
1 35076 2053
31 1164 3343
1 18052 7643
1 810 5281
1 36982 8663
1 21604 8363
1 35676 5689
1 36708 4327
1 19194 3061
1 30292 9221
1 36300 8563
31 ...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
228
1
1
1
1
1
1
1
1
1
108
1
1
1
4342
1
1997
1
1
1
1
1
1
1
1
1
241
1
1
1
1
1
2423
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
123
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

result:

ok 20000 lines

Test #67:

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

input:

20000
32 487 5
2 4298 2
2 13967 7
2 17793 2
2 13487 5
2 12595 3
2 6185 5
32 700 3
2 10217 3
2 1654 7
2 1684 3
2 12908 7
2 4189 7
2 15100 3
2 6580 2
2 18394 2
2 8994 2
2 9870 7
2 8598 3
2 18508 2
2 14603 3
2 3247 7
2 9738 5
32 908 5
2 9547 7
2 6149 3
2 9269 3
2 548 5
2 18114 2
2 10557 2
2 1624 2
2 12...

output:

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

result:

ok 20000 lines

Test #68:

score: 0
Accepted
time: 324ms
memory: 4304kb

input:

20000
2 17807 41
2 3084 83
2 3195 7
2 9645 29
2 11495 53
2 18809 73
2 245 23
2 883 89
2 8285 11
2 5478 89
32 855 83
2 14452 73
2 13448 41
2 9109 7
2 3427 37
2 1278 97
2 17700 71
2 15426 97
2 17817 89
2 3695 17
32 910 17
2 8720 3
2 1761 29
2 9962 41
2 7121 41
2 18426 5
2 229 23
2 4516 53
2 14895 73
2...

output:

21
61
4
0
8
12
8
3
8
88
56
32
34
1
21
92
34
23
88
9
15
1
28
2
1
3
14
47
28
6
55
4
1
35
8
76
5
56
1
10
79
12
3
10
5
15
52
21
81
62
39
54
38
30
2
4
44
16
39
6
13
14
5
44
1
8
12
0
4
15
5
39
12
46
18
1
5
8
11
87
1
0
1
10
22
2
30
55
66
40
4
60
5
84
1
10
5
1
28
0
2
13
13
18
2
17
13
5
45
6
34
3
2
30
86
68
...

result:

ok 20000 lines

Test #69:

score: 0
Accepted
time: 328ms
memory: 4292kb

input:

20000
2 9245 337
2 16575 17
2 12716 863
2 3837 547
2 8042 229
2 15321 281
2 13068 353
2 3580 113
2 17103 433
2 17722 59
2 2514 239
2 1979 947
2 10434 43
2 598 991
2 16294 241
2 13178 587
2 9674 971
2 9413 269
2 12771 419
2 14072 877
2 5004 827
2 11310 919
2 18979 811
2 13283 593
2 5647 347
32 76 263...

output:

265
1
841
546
83
273
92
34
316
36
156
622
30
5
74
10
258
87
357
480
320
89
2
535
330
206
8
55
347
321
323
21
77
34
129
7
149
272
104
595
50
35
113
7
476
29
21
544
124
157
22
3
564
224
602
601
35
2
214
269
31
120
179
328
390
882
25
164
1
120
142
205
5
1
142
284
197
11
847
669
676
546
599
282
97
423
2...

result:

ok 20000 lines

Test #70:

score: 0
Accepted
time: 332ms
memory: 4296kb

input:

20000
2 7406 127
2 1425 6311
2 11054 5237
2 5998 9803
2 2776 3923
2 16521 7321
2 16378 1997
2 5024 521
2 13479 8081
2 5508 6361
2 16368 7589
2 17380 449
32 288 2411
2 24 6029
2 5789 5639
2 7349 1493
2 2584 6269
2 4019 4799
2 5563 3313
2 14422 2503
2 9078 6553
2 13184 6899
2 17919 8663
32 657 3301
2 ...

output:

73
3777
4360
8216
522
853
975
13
7713
1073
5943
14
1058
2677
912
412
1377
3766
2595
189
613
1817
2367
3055
11
3756
1941
1397
1148
2280
6816
5222
9204
32
2210
6000
313
3950
5517
466
1872
1230
3280
5572
376
1422
1118
6788
3503
151
12
412
7736
1611
7015
280
2236
58
1562
4757
4123
4393
3162
395
1336
338...

result:

ok 20000 lines

Test #71:

score: 0
Accepted
time: 395ms
memory: 4316kb

input:

20000
3 16212 3
3 21590 2
3 35936 7
3 30304 2
3 2918 5
3 29038 5
3 28706 2
3 7886 2
3 12098 5
3 5250 5
3 19638 5
3 4260 2
3 16762 2
3 1154 7
3 34924 2
33 16 5
3 1100 2
3 33266 2
3 23440 7
3 22878 3
3 26338 2
3 26860 7
3 7994 7
3 5734 3
3 32226 7
3 27474 2
3 5042 5
3 18490 5
3 32422 2
3 22418 5
3 913...

output:

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

result:

ok 20000 lines

Test #72:

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

input:

20000
3 37522 73
3 2636 5
3 6654 31
3 24402 3
3 29690 3
3 772 29
3 25086 73
3 3196 67
3 15364 83
3 33708 7
3 6516 3
3 4106 41
3 16188 31
3 24554 7
3 20130 11
3 33182 67
3 28336 97
3 28664 19
3 19592 19
3 31980 61
3 21046 2
3 396 2
3 26558 3
3 3050 41
3 27694 5
3 34088 11
3 25030 2
3 2852 61
3 16552 ...

output:

60
3
1
2
0
12
62
1
28
3
1
30
3
4
10
1
96
11
3
60
1
1
0
1
1
10
1
45
15
12
34
8
54
23
0
50
12
3
3
6
28
11
64
11
32
3
8
1
1
36
1
11
11
0
41
6
1
1
26
1
10
11
14
32
3
15
59
1
3
8
3
3
2
1
2
64
24
54
4
15
3
33
13
20
41
66
1
22
4
35
41
1
24
1
1
43
11
1
60
1
41
0
35
21
68
3
1
10
36
3
65
1
3
1
1
33
16
16
13
4...

result:

ok 20000 lines

Test #73:

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

input:

20000
3 19038 37
3 654 479
33 830 983
3 13606 373
3 13676 601
33 154 617
3 23550 331
3 18094 641
3 29798 607
3 9070 599
3 29818 821
3 5118 857
3 28304 857
3 9000 619
3 28122 449
3 11478 53
3 35606 2
3 7710 587
3 6120 877
3 4136 439
33 1158 373
3 30702 383
3 3972 199
3 37640 661
3 1040 19
3 1874 233
...

output:

26
141
622
232
476
212
315
110
566
277
548
848
704
48
235
11
1
478
306
94
2
177
187
383
1
3
106
556
121
464
431
313
30
132
51
24
397
705
1
98
67
256
146
66
159
287
22
220
11
169
51
541
115
799
397
84
27
142
434
598
252
475
74
6
427
89
103
521
647
11
1
329
252
596
103
290
490
446
59
408
3
352
259
204...

result:

ok 20000 lines

Test #74:

score: 0
Accepted
time: 403ms
memory: 4232kb

input:

20000
3 25994 5449
3 14328 97
3 8338 4909
3 23658 5749
3 10700 8293
3 766 1723
3 19674 7019
3 9420 409
3 9788 461
3 5970 6089
3 32650 41
3 5066 2027
3 6584 8641
3 6312 2207
3 31376 8933
3 33374 4931
3 806 9721
3 28462 3929
3 18350 1693
3 32144 3511
3 33536 6779
3 32356 5381
3 14064 6841
3 36672 3259...

output:

2981
41
3553
2650
3991
314
5518
231
289
4914
3
45
3558
1453
7286
1075
6156
3332
418
810
2054
1802
3035
33
3018
9023
1292
3380
429
892
1339
8274
658
2532
1
88
2741
3219
2451
7
2107
555
2568
185
382
7938
735
5504
564
368
1213
581
2479
4326
3604
6383
1424
2548
1833
882
1393
856
505
3262
153
3917
1389
5...

result:

ok 20000 lines

Test #75:

score: 0
Accepted
time: 434ms
memory: 4360kb

input:

20000
4 916 3
4 18911 7
4 16020 5
4 9278 3
34 403 7
4 2109 3
4 1193 5
34 222 7
4 6241 5
4 2696 2
4 2108 7
34 626 5
4 12573 2
4 6042 5
34 341 3
4 7700 3
4 8730 3
4 1189 3
4 8519 5
4 3716 3
4 5178 5
4 1884 2
4 8928 5
4 5232 2
4 17735 3
4 15162 3
4 13771 5
4 17942 2
4 3225 2
34 446 7
4 2535 5
4 11741 5...

output:

2
0
1
1
4
0
0
1
1
1
5
0
1
1
2
1
1
0
0
2
1
0
1
1
2
2
1
1
1
2
1
0
1
1
1
1
1
0
0
0
1
1
1
1
1
0
1
0
1
2
1
1
1
1
2
0
1
1
0
4
2
1
0
5
1
1
1
1
1
1
0
1
1
1
1
0
5
0
1
0
4
1
1
1
4
1
1
2
5
1
1
1
1
1
0
0
1
0
1
1
1
1
2
2
0
1
1
1
0
1
1
1
2
0
1
0
0
0
1
1
1
1
1
1
1
1
0
1
1
1
1
1
4
0
0
1
1
1
2
4
4
1
0
1
2
1
1
1
0
1
...

result:

ok 20000 lines

Test #76:

score: 0
Accepted
time: 433ms
memory: 4364kb

input:

20000
34 715 29
34 552 83
4 296 89
4 11523 79
4 18194 17
34 346 47
4 7338 3
4 2286 3
4 11440 73
34 7 73
4 17319 97
34 1 97
4 2740 97
4 15445 31
4 16702 53
4 2865 73
4 7276 29
4 15460 7
4 11687 43
4 8958 17
34 800 17
4 559 59
4 3248 3
4 16856 11
4 3094 97
4 18384 31
34 664 73
4 18310 73
4 1437 2
4 13...

output:

13
9
26
47
12
22
1
2
16
56
31
1
14
18
17
16
1
1
6
8
12
49
1
6
46
17
51
27
1
73
22
38
6
18
65
21
5
7
9
6
61
63
29
16
85
23
44
37
18
23
1
17
16
1
17
12
18
27
38
1
24
0
6
1
0
3
4
9
8
5
8
14
56
11
87
15
39
4
1
54
19
2
10
5
3
37
1
10
5
15
25
54
0
4
11
13
1
29
33
42
46
36
61
33
0
5
5
12
72
5
49
11
31
1
10...

result:

ok 20000 lines

Test #77:

score: 0
Accepted
time: 445ms
memory: 4304kb

input:

20000
4 9149 887
4 8787 829
4 17875 431
4 1248 613
4 12906 443
4 6484 307
4 15007 131
4 1190 59
34 223 593
4 15078 101
4 2251 677
4 152 43
4 16614 691
4 6464 367
4 7266 547
4 1211 67
4 15819 2
4 14961 83
4 1463 733
4 408 31
4 18549 881
4 3852 461
4 9494 541
4 12277 257
34 947 37
4 15015 461
4 5372 4...

output:

208
698
25
382
397
229
103
3
582
79
525
29
281
196
396
28
0
1
146
27
763
229
335
101
30
19
442
43
13
6
388
159
353
26
93
114
138
225
586
258
138
3
300
38
302
439
245
1
5
93
1
5
39
424
365
72
265
939
1
154
112
400
224
48
305
615
534
65
0
331
455
170
166
128
339
4
548
236
578
429
207
120
324
0
144
535...

result:

ok 20000 lines

Test #78:

score: 0
Accepted
time: 451ms
memory: 4372kb

input:

20000
4 12248 4603
4 14117 8681
4 14429 3677
4 93 617
4 5999 5431
4 2296 4327
4 17181 5431
4 15525 6247
4 6769 1423
4 11751 3697
4 8936 7949
4 7326 9091
4 17641 6277
34 861 7459
4 16611 1549
4 13406 8431
4 6710 8681
4 7731 4219
4 6115 6029
4 4960 3347
4 18614 3907
4 17372 557
4 6864 3329
4 7471 1049...

output:

3084
4321
954
551
156
885
977
415
119
2008
3114
2943
1416
4960
1370
7320
4210
2242
3089
3054
118
511
2205
478
483
3362
2859
1656
3929
575
396
326
4027
2450
2042
1254
2966
7839
933
1103
3661
1855
317
7783
8200
155
2029
59
796
3356
1163
1252
1429
5172
6941
1072
103
808
14
653
16
5284
95
4393
978
955
2...

result:

ok 20000 lines

Test #79:

score: 0
Accepted
time: 514ms
memory: 4340kb

input:

20000
5 19070 7
5 10818 3
5 46 7
5 13276 3
5 34688 5
5 5454 7
5 16054 7
5 6930 5
5 12866 2
5 7334 3
5 20486 5
5 36008 3
5 33530 7
5 23012 7
5 10650 3
5 8360 7
5 21788 7
5 15904 7
5 10636 5
5 31946 2
5 7488 7
5 27634 3
5 12442 2
5 16382 5
5 8648 5
5 106 7
5 24374 5
5 28 3
5 20420 5
35 1164 3
5 8664 5...

output:

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

result:

ok 20000 lines

Test #80:

score: 0
Accepted
time: 520ms
memory: 4384kb

input:

20000
5 26746 71
5 31460 5
5 34524 71
5 28158 61
5 30168 59
5 25280 41
5 36604 83
5 6002 19
5 21674 17
5 35626 73
5 22780 61
5 32944 59
5 22020 79
35 932 2
5 14944 17
5 18248 5
5 19520 17
5 30932 37
5 19660 67
5 2542 17
5 33940 23
5 1840 59
5 20324 43
5 32430 59
5 4760 19
35 1498 13
5 23900 23
5 383...

output:

10
4
66
7
15
1
32
3
13
50
59
1
68
0
5
4
0
29
55
5
3
16
8
15
15
9
8
8
2
37
1
32
11
38
1
1
10
7
1
4
24
2
1
38
6
4
4
2
19
16
0
10
3
9
1
1
7
20
7
4
19
6
3
4
4
12
13
27
60
10
50
11
0
6
8
56
0
25
41
20
4
10
3
4
5
17
8
19
3
11
45
51
23
1
0
8
0
28
10
12
0
14
2
94
17
7
4
27
32
4
8
13
6
36
8
0
66
64
4
0
4
18
...

result:

ok 20000 lines

Test #81:

score: 0
Accepted
time: 524ms
memory: 4340kb

input:

20000
5 10780 283
5 5608 337
5 4172 83
5 16862 809
5 10956 907
5 20366 41
5 13736 751
5 20690 467
5 29960 499
5 17530 673
5 30340 7
5 29528 173
5 23230 887
5 34002 659
35 1648 211
5 12498 349
5 7940 937
5 37620 37
5 13666 97
5 29442 571
5 11416 491
5 24088 79
5 22402 613
5 5274 661
5 25202 523
5 630...

output:

273
41
10
194
561
6
608
226
55
134
1
74
52
545
98
260
606
1
53
177
90
62
577
381
99
4
172
52
321
42
403
1
241
614
129
551
101
11
166
390
816
0
75
602
48
397
365
332
22
550
93
75
449
110
773
329
30
416
454
14
201
395
273
318
126
31
1
356
36
61
259
525
28
678
7
442
4
679
96
14
19
384
276
335
172
320
3...

result:

ok 20000 lines

Test #82:

score: 0
Accepted
time: 529ms
memory: 4336kb

input:

20000
5 13972 3671
5 32714 3463
35 1082 8231
5 800 6863
5 27038 8963
5 16804 97
5 30830 53
5 20790 5009
5 35832 5717
5 24618 7481
5 3354 8719
35 1212 8707
5 772 1483
35 1370 7109
5 30810 6481
5 15772 2909
5 7202 827
5 17690 6047
5 10630 5653
5 10520 107
5 834 547
5 24554 7237
5 11476 1873
5 644 5393...

output:

2843
2933
4466
2036
6484
10
45
433
1222
7417
7832
5524
380
4368
1705
61
745
228
220
72
212
2794
976
2639
8435
97
4970
5223
2525
31
6086
479
1073
482
1148
1016
1307
2739
4725
6803
2680
3279
1978
1687
465
1749
1300
196
309
5660
12
828
391
7630
377
8656
109
30
5877
4740
6769
5760
389
1768
1438
1251
919...

result:

ok 20000 lines