QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#150513#4934. Forbidden Cardc20231020AC ✓9ms21072kbC++239.0kb2023-08-25 18:50:032023-08-25 18:50:04

Judging History

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

  • [2023-08-25 18:50:04]
  • 评测
  • 测评结果:AC
  • 用时:9ms
  • 内存:21072kb
  • [2023-08-25 18:50:03]
  • 提交

answer

/*
膜拜传奇特级宗师 Afterglow 大神儿
今天在 florr 首页称您为大夏尊贵的大名儿
一股敬佩之情油生然而
您在 florr 为国争光,扬我大夏威名
向您献上最真挚的膜拜!!!
膜拜传奇特级宗师 Afterglow 大神儿,今,一,您,扬。向!
膜拜传奇特级宗师 Afterglow 大神儿,今,一,您,扬。向!
膜拜传奇特级宗师 Afterglow 大神儿,今,一,您,扬。向!
*/
/*
          _____                    _____                     _____                    _____
         /\    \                  /\    \                   /\    \                  /\    \
        /  \    \                /  \    \                 /  \____\                /  \    \
        \   \    \              /    \    \               /   /    /                \   \    \
         \   \    \            /      \    \             /   /    /                  \   \    \
          \   \    \          /   /\   \    \           /   /____/                    \   \    \
           \   \    \        /   /  \   \    \         /    |    |                     \   \    \
            \   \    \      /   /    \   \    \       /     |    |                      \   \    \
             \   \    \    /   /    / \   \    \     /      |    |                       \   \    \
              \   \    \  /   /    /   \   \    \   /       |____|__ _____                \   \    \
_______________\   \____\/   /____/     \   \    \ /   /|            \    \ _______________\   \____\
\                  /    /\   \    \      \   \    \\  / |    _________\____\\                  /    /
 \    ____________/____/  \   \    \      \   \____\\/__|   |    |           \    ____________/____/
  \   \    \               \   \    \     |   |    |    |   |    |            \   \    \
   \   \    \               \   \    \    |   |    |    |   |    |             \   \    \
    \   \    \               \   \    \   |   |____|    |   |    |              \   \    \
     \   \    \               \   \    \  /   /    /    \   |    |               \   \    \
      \   \    \               \   \    \/   /    /      \  |    |                \   \    \
       \   \____\               \   \___/   /    /        \ |    |                 \   \____\
        \  /    /                \         /    /          \|    |                  \  /    /
         \/____/                  \_______/____/            \____|                   \/____/
*/
#define poj
#ifndef local
#define zcz
#endif
#ifdef poj
//C++
#include<iomanip>
#include<iostream>
//C
#include<cassert>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
//STL
#include<algorithm>
#include<bitset>
#include<functional>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
//C++11
#if __cplusplus>=201103L
#include<chrono>
#include<random>
#include<unordered_set>
#include<unordered_map>
#endif
#else
#include<bits/stdc++.h>
#endif
using namespace std;
#ifdef zcz
class fastin{
	private:
#ifdef poj
	static const int MAXBF=1<<20;
#else
	const int MAXBF=1<<27;
#endif
	FILE *inf;
	char *inbuf,*inst,*ined;
	inline char _getchar(){
		if(inst==ined)inst=inbuf,ined=inbuf+fread(inbuf,1,MAXBF,inf);
		return inst==ined?EOF:*inst++;
	}
	public:
	fastin(FILE*_inf=stdin){
		inbuf=new char[MAXBF],inf=_inf,inst=inbuf,ined=inbuf;
	}
	~fastin(){delete inbuf;}
	template<typename Int> fastin&operator>>(Int &n){
		static char c;
		Int t=1;
		while((c=_getchar())<'0'||c>'9')if(c=='-')t=-1;
		n=(c^48);
		while((c=_getchar())>='0'&&c<='9')n=n*10+(c^48);
		n*=t;
		return *this;
	}
	fastin&operator>>(char&c){
		while((c=_getchar())<'!'||c>'~');
		return *this;
	}
	fastin&operator>>(char*s){
		int t=0;
		static char c;
		while((c=_getchar())==' '||c=='\n');
		s[t++]=c;
		while((c=_getchar())>='!'&&c<='~')s[t++]=c;
		s[t]='\0';
		return *this;
	}
}fi;
class fastout{
	private:
#ifdef poj
	static const int MAXBF=1<<20;
#else
	const int MAXBF=1<<27;
#endif
	FILE *ouf;
	char *oubuf,*oust,*oued;
	inline void _flush(){fwrite(oubuf,1,oued-oust,ouf);oued=oust;}
	inline void _putchar(char c){
		if(oued==oust+MAXBF)_flush(),oued=oubuf;
		*oued++=c;
		#ifdef local
		_flush();
		#endif
	}
	public:
	fastout(FILE*_ouf=stdout){
		oubuf=new char[MAXBF],ouf=_ouf,oust=oubuf,oued=oubuf;
	}
	~fastout(){_flush();delete oubuf;}
	template<typename Int> fastout&operator<<(Int n){
		if(n<0)_putchar('-'),n=-n;
		static char S[20];
		int t=0;
		do{S[t++]='0'+n%10,n/=10;}while(n);
		for(int i=0;i<t;++i)_putchar(S[t-i-1]);
		return *this;
	}
	fastout&operator<<(char c){_putchar(c);return *this;}
	fastout&operator<<(char*s){
		for(int i=0;s[i];++i)_putchar(s[i]);
		return *this;
	}
	fastout&operator<<(const char*s){
		for(int i=0;s[i];++i)_putchar(s[i]);
		return *this;
	}
}fo;
#define cin fi
#define cout fo
#else
#define czc ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#endif
#define mod7 1000000007
#define mod9 998244353
#define ll long long
#define isinf 0x3f3f3f3f
#define ilinf 0x7fffffff
#define lsinf 0x3f3f3f3f3f3f3f3f
#define llinf 0x7fffffffffffffff
#define pii pair<int,int>
#define fr first
#define sc second
#define next ___
#define pb push_back
#define N 500010
#define M 5000010
#define For(i,a,b) for(ll i=(a);i<=(b);++i)
#define Rep(i,a,b,c) for(ll i=(a);i<=(b);i+=c)
#define Per(i,a,b,c) for(ll i=(a);i>=(b);i-=c)
#define Gra(i) for(ll i=h[x];i;i=next[i])
typedef int arr[N];
typedef int arm[M];
typedef ll arl[N];
typedef ll alm[M];
typedef double ard[N];
typedef double adm[M];
namespace modint{
	template<typename Int,Int mod,Int m1>
	struct modint{
		Int v;
		modint(){v=0;}
		modint(Int a){v=a;}
		bool operator==(modint a){return v==a.v;}
		bool operator!=(modint a){return v!=a.v;}
		bool operator<(modint a){return v<a.v;}
		bool operator>(modint a){return v>a.v;}
		bool operator<=(modint a){return v<=a.v;}
		bool operator>=(modint a){return v>=a.v;}
		bool operator==(Int a){return v==a;}
		bool operator!=(Int a){return v!=a;}
		bool operator<(Int a){return v<a;}
		bool operator>(Int a){return v>a;}
		bool operator<=(Int a){return v<=a;}
		bool operator>=(Int a){return v>=a;}
		modint operator+(modint a){return v>=mod-a.v?v-mod+a.v:v+a.v;}
		modint operator-(modint a){return v>=a.v?v-a.v:v+mod-a.v;}
		modint modnum(modint a){
			return a-((__int128(a.v)*m1)>>80)*mod;
		}
		modint operator*(modint a){return modnum(v*a.v);}
		modint operator+=(modint a){*this=*this+a;return *this;}
		modint operator-=(modint a){*this=*this-a;return *this;}
		modint operator*=(modint a){*this=*this*a;return *this;}
		modint qpow(modint a,Int b){
			modint r(1);
			for(;b;b>>=1,a*=a)if(b&1)r*=a;
			return r;
		}
		modint operator/(modint a){return qpow(a,mod-2)*v;}
		modint operator/=(modint a){*this=*this/a;return *this;}
		modint&operator++(){*this=*this+1;return *this;}
		modint&operator--(){*this=*this-1;return *this;}
		const modint operator++(int){modint r=*this;++*this;return r;}
		const modint operator--(int){modint r=*this;--*this;return r;}
		#ifdef cout
		friend fastin&operator>>(fastin&in,modint&n){in>>n.v;return in;}
		friend fastout&operator<<(fastout&out,modint n){out<<n.v;return out;}
		#else
		friend istream&operator>>(istream&in,modint&n){in>>n.v;return in;}
		friend ostream&operator<<(ostream&out,modint n){out<<n.v;return out;}
		#endif
	};
	typedef modint<long long,1000000007,1208925811152148> int7;
	typedef modint<long long,998244353,1211051999424262> int9;
}
using namespace modint;
int 🔴,🟠;
arr 🟡,🟢,🔵;
arm 🟣,🟤,🔴🔴;
void solve(){
	cin>>🔴>>🟠;
	For(🔴🟠,1,🔴){
		cin>>🟡[🔴🟠]>>🟢[🔴🟠];
	};
	int 🔴🟡=1,🔴🟢=0;
	For(🔴🟠,0,1){
		For(🔴🔵,1,🔴){
			if(🟣[🟡[🔴🔵]]&&🟣[🟢[🔴🔵]]){
				🔴🟡=🔴🔵;
				🔴🟠=2;
				break;
			}else if(🟣[🟡[🔴🔵]]){
				🟣[🟢[🔴🔵]]=🔴🔵;
				🟤[🟢[🔴🔵]]=++🔴🟢;
			}else{
				🟣[🟡[🔴🔵]]=🔴🔵;
				🟤[🟡[🔴🔵]]=++🔴🟢;
			}
		};
	};
	🔵[🔴🟡]+=🟠-🔴🟢;
	Per(🔴🟠,🔴,1,1){
		if(🟣[🟡[🔴🟠]]==🔴🟠&&🟣[🟢[🔴🟠]]==🔴🟠){
			🔵[🔴🟠]+=2;
		}else if(🟣[🟡[🔴🟠]]!=🔴🟠&&🟣[🟢[🔴🟠]]==🔴🟠){
			🔵[🔴🟠]++;
		}else if(🟣[🟡[🔴🟠]]==🔴🟠&&🟣[🟢[🔴🟠]]!=🔴🟠){
			for(int 🔴🔵=🔴🟠;;🔴🔵=🟣[🟢[🔴🔵]]){
				if(🔴🔴[🔴🔵]){
					🔵[🔴🔴[🔴🟠]=🔴🔴[🔴🔵]]++;
					break;
				}
				if(!🟣[🟢[🔴🔵]]){
					🔵[🔴🔴[🔴🟠]=🔴🟡]++;
					break;
				}
				if(🟣[🟢[🔴🔵]]==🔴🔵||🟤[🟡[🔴🟠]]>🟤[🟢[🔴🟠]]){
					🔵[🔴🔴[🔴🟠]=🔴🔵]++;
					break;
				}
			}
		}
	};
	For(🔴🟠,1,🔴)cout<<🔵[🔴🟠]<<'\n';
	return;
}
int main(){
	#ifndef zcz
	czc;
	#endif
	int t=1;
	while(t--)solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 11648kb

input:

3 6
1 2
2 4
4 2

output:

3
0
3

result:

ok 3 lines

Test #2:

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

input:

4 10
1 5
2 6
3 7
4 8

output:

4
2
2
2

result:

ok 4 lines

Test #3:

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

input:

1 2
1 2

output:

2

result:

ok single line: '2'

Test #4:

score: 0
Accepted
time: 6ms
memory: 13616kb

input:

69332 250102
51362 228823
206751 31351
181790 44202
186695 92215
172072 173179
86663 76959
42382 25827
204750 30001
42502 11959
201030 71886
227497 216114
164282 235028
178967 181951
125356 20611
169528 174071
50985 175562
63676 208400
189134 229462
49746 131529
180236 247427
29278 229589
30381 4412...

output:

197458
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 69332 lines

Test #5:

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

input:

80145 426253
421996 34366
346502 239646
343011 88629
67397 242186
299496 244930
21243 104718
387596 328535
219758 313693
75331 382300
313805 77098
42577 148653
337458 118115
214642 386869
250381 179903
371620 42703
175776 57872
382478 385425
67153 363632
137021 301439
54496 28984
416540 87624
180610...

output:

2
2
387645
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 80145 lines

Test #6:

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

input:

100000 1000000
123135 548518
73705 792839
425849 331898
823140 91484
612409 674530
215766 587078
145133 904035
435464 107690
291461 358251
156778 270843
378425 339959
353997 687100
373365 903063
948343 203641
349073 91866
329756 348161
731516 202789
767371 938875
3496 388919
998073 384450
73693 8551...

output:

2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
956616
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 100000 lines

Test #7:

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

input:

89069 799019
589538 728126
669934 721110
689804 767765
57113 349607
788143 621300
449778 648433
451910 356399
484000 586091
699836 387252
618498 221963
42563 549795
774972 697895
765784 478517
626296 213965
174994 617652
788312 418305
509601 717678
663049 769953
167726 375932
38772 144093
140904 564...

output:

2
783305
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 89069 lines

Test #8:

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

input:

69694 877503
863663 582574
192540 50718
545855 600725
106914 337076
95953 472303
337876 352481
617099 663754
658298 249330
575057 97722
522140 520920
811913 519974
533217 425142
590101 532180
684733 355462
783334 274412
25380 75797
853682 128592
457036 274558
184076 7863
688088 614343
733047 768004
...

output:

2
2
829210
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 69694 lines

Test #9:

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

input:

68561 994844
934673 839086
678230 902049
609695 838139
172142 165310
166125 382300
733287 681492
31687 156593
743676 484561
301345 936945
511237 258689
936301 315735
750745 500110
650444 288851
407665 485171
316258 272455
868401 430224
348328 582450
368182 44256
934873 895495
466439 780819
543373 68...

output:

2
2
2
2
985873
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 68561 lines

Test #10:

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

input:

100000 1000000
750844 577520
750988 551898
71182 495851
781670 620811
429538 655630
949020 91780
352634 583957
278999 299878
401107 296003
310998 796093
134490 713012
571847 466126
97048 513189
701512 397675
328784 597378
600866 775036
123964 779641
783762 95052
581923 521272
174622 578127
940629 92...

output:

958024
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 100000 lines

Test #11:

score: 0
Accepted
time: 9ms
memory: 17048kb

input:

97613 571574
473117 229386
423786 319808
400816 515877
51984 283789
129404 223355
36594 363548
378401 286262
173741 481783
33072 245586
443684 222118
84885 277987
521174 139691
557463 541830
447714 163559
414047 64274
366005 384713
149976 525494
497204 378402
548917 82952
184725 168981
445716 501317...

output:

542823
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 97613 lines

Test #12:

score: 0
Accepted
time: 9ms
memory: 18044kb

input:

69396 864127
464385 526906
787104 491768
38269 47670
86820 517464
353813 728363
679809 387823
517990 116740
848791 410216
587334 99062
778991 733391
832499 522941
19242 176014
751019 345373
268829 384678
55782 16440
127010 333800
535423 588225
109371 645414
145244 552479
597799 552396
600038 235109
...

output:

2
2
2
2
2
2
2
805120
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 69396 lines

Test #13:

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

input:

86470 288956
81959 261040
206019 205310
130325 15327
223490 45996
254263 134493
132914 146198
271808 230093
192789 239059
257256 18045
87950 183011
19344 266027
280038 28560
139522 285325
26554 267570
4553 143311
21451 61963
242467 238366
274767 216559
165157 8502
185945 180806
271515 104078
98160 2...

output:

239234
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 86470 lines

Test #14:

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

input:

2 2
2 1
1 2

output:

0
2

result:

ok 2 lines

Test #15:

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

input:

100000 1000000
642133 546926
123679 867209
617137 454611
472705 627306
94896 603782
523279 31451
263895 276501
142151 455942
525514 977824
263586 220101
93152 998514
117325 54406
75166 160431
174093 514041
409869 356920
751904 244516
844806 816952
904840 872203
896272 387803
522151 434957
154934 531...

output:

2
3
2
2
2
2
3
2
2
908975
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 100000 lines

Test #16:

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

input:

96191 790771
239246 406927
608723 39453
647021 455246
449613 325203
500412 246565
496412 527678
775691 306215
15686 145589
789951 122377
126343 302706
704644 254834
538536 278628
68976 439516
650659 690292
496323 588418
710462 6367
227229 387492
313599 215876
281669 237302
117764 311686
70133 388917...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 96191 lines

Test #17:

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

input:

86551 543901
231809 430371
538308 434317
542712 120195
323781 89341
535653 25803
423038 172132
280771 313400
527228 456621
112353 356938
487630 393471
191751 52096
151594 392894
230381 83155
362583 11099
43970 409303
356820 251516
199568 326380
74743 182624
406748 384282
534629 72327
358298 533328
3...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 86551 lines

Test #18:

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

input:

93037 985896
307616 610099
473548 781574
925052 974173
114523 953716
849734 22170
347888 872908
197173 704226
420801 910897
360824 815511
462972 653925
739302 705598
854395 334583
759168 478093
578734 402524
973337 24255
111116 351192
573368 228414
278418 449766
710599 891697
395650 352423
496881 71...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 93037 lines

Test #19:

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

input:

100000 1000000
666466 912306
493318 80646
764220 117237
731928 361774
156065 270803
448697 160671
338776 739311
407713 11860
655517 137923
141084 522764
433775 987696
574410 289307
30367 338803
678920 270682
831104 135916
283351 853322
285800 956122
384015 993537
978941 801509
642476 516063
717906 9...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 100000 lines

Test #20:

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

input:

50888 368468
66657 89844
335671 195763
203471 85924
260576 55499
192046 645
225756 57454
188029 271482
65743 101411
187362 40021
13929 349618
97806 7010
131423 98350
323610 190490
33467 195178
86639 235412
234923 307468
34275 201062
135495 129178
145507 105216
241093 21509
25120 360939
286913 113185...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 50888 lines

Test #21:

score: 0
Accepted
time: 6ms
memory: 16700kb

input:

58486 623096
431098 299819
144394 549261
191344 508221
326186 75720
303431 256171
611431 511726
421121 91179
32066 257052
454612 306754
291805 383819
447511 195742
344364 464616
78410 313406
493444 180249
67050 479211
319760 99699
188606 540399
396233 205182
158040 582371
105516 589421
348701 356436...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 58486 lines

Test #22:

score: 0
Accepted
time: 6ms
memory: 14176kb

input:

82525 359359
10998 157612
272920 63758
160775 148500
245107 2581
344831 305205
124010 169112
237361 239101
253353 206868
53186 244114
221854 65345
165008 273180
281279 75989
184012 248121
153849 232843
168597 96807
125191 111849
59946 48924
169637 355462
69503 270500
286627 142198
274891 273552
2157...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 82525 lines

Test #23:

score: 0
Accepted
time: 6ms
memory: 20820kb

input:

100000 1000000
425685 202147
438254 606329
252447 42709
155408 626774
606823 289054
351598 606736
982882 638626
179516 125412
961215 711382
701928 125327
248811 827723
807736 807012
386732 774880
868959 38390
78194 47065
579329 203823
42173 668892
835745 216393
163420 249700
742910 410953
248718 460...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 100000 lines

Test #24:

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

input:

70756 597360
480320 569526
224305 174976
438144 50990
109339 575143
451742 136690
277076 96009
399614 372626
64135 391826
583192 535270
144759 64870
288178 30083
12698 306256
422223 53650
97100 174189
538195 414289
310539 360500
442632 362505
210320 145501
576696 222823
204732 277556
215897 270374
4...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 70756 lines

Test #25:

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

input:

1 3
1 2

output:

3

result:

ok single line: '3'

Test #26:

score: 0
Accepted
time: 6ms
memory: 13436kb

input:

84785 184373
62716 147991
175818 104312
36730 96500
88702 69412
14804 67754
51663 127213
3750 43909
54463 131650
38305 134159
150145 125222
61107 159320
94170 106574
125041 64739
36902 25748
28735 150604
286 138187
155258 63937
163960 183981
81603 177290
81614 114780
1065 107146
167471 26539
85337 1...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 84785 lines

Test #27:

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

input:

67148 570300
122064 219482
400391 452496
163619 319642
484630 491545
188290 338510
145128 477327
418466 135983
310242 538510
492452 411168
334909 104859
141234 306471
564934 456853
180858 168044
497993 186591
392260 270902
431046 534198
233699 104885
343170 356445
516675 1139
337350 13077
127605 534...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 67148 lines

Test #28:

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

input:

100000 1000000
547883 10023
577775 14350
339373 660830
326712 856472
675036 677853
333553 127783
363592 423232
51660 956983
146143 913911
561777 923778
988556 237085
474621 280101
761902 95059
79776 171312
757643 980741
484987 175489
881092 657127
218013 366221
680122 545354
345116 424135
219373 122...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 100000 lines

Test #29:

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

input:

54391 33053
5920 2980
180 30295
19227 9914
25453 23433
11437 31321
24245 17622
19065 11949
2804 22112
20956 6998
27691 24109
20426 16523
3792 11370
10126 6760
20263 23196
14437 29653
28489 3083
21204 7404
662 8856
11505 19388
1861 3331
26990 2251
30793 8952
22025 6364
29038 15952
8052 15830
5741 240...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 54391 lines

Test #30:

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

input:

64013 88482
10314 58672
6959 8794
52063 56904
27764 62355
1632 22281
84033 25932
63863 2779
75549 28094
76343 27928
10395 41335
10608 60703
28054 44249
74825 20364
17254 41175
8795 78506
44131 7907
38096 79911
75799 59494
84992 87134
14328 76227
86118 3154
87940 7731
47471 75725
66582 40899
53747 65...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 64013 lines

Test #31:

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

input:

96315 804081
236612 190272
282362 530978
400127 644724
115659 517389
260414 596600
250265 297155
168162 632778
544161 165121
724744 313136
712975 385075
137552 407708
83539 675809
795105 320540
651286 223782
416215 793038
297168 566080
612978 20186
213237 674320
398895 404954
6511 330097
553806 5947...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 96315 lines

Test #32:

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

input:

100000 1000000
728033 226535
905877 895966
181924 701121
840076 802636
300805 650210
278718 447963
795948 967575
345255 53639
382326 335571
541029 472496
923813 92571
318956 701889
850852 784469
676666 46209
223883 672671
391326 282221
557349 937574
243193 426858
201949 697058
181045 97023
914030 67...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 100000 lines

Test #33:

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

input:

51881 110672
55007 32531
98872 38630
14496 79144
88737 99112
77739 13213
29081 98946
96336 80348
47526 7896
39830 14502
37443 107176
15672 45083
29553 27439
46357 74959
61374 93562
49416 11232
21839 92701
56231 52911
35265 63704
67003 88479
44136 79739
96232 82908
19097 61356
94971 44490
38238 40539...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 51881 lines

Test #34:

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

input:

51227 58333
35904 19397
32779 17906
50854 43038
36699 44174
31386 10863
40831 31616
7782 3753
7063 23563
4295 37241
45457 42931
9722 6683
26693 609
21158 20455
20397 22325
3126 8524
14749 56601
19082 9594
22176 32491
23278 29398
44715 20950
26330 1109
50579 2271
55226 38779
53676 20108
41443 15746
2...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 51227 lines

Test #35:

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

input:

86114 782518
632191 256996
63180 70657
483312 503452
191002 439245
717863 221928
661969 177679
636821 456029
1961 625872
758962 559768
510462 172490
6863 44061
525129 545154
306380 460293
375183 23696
688770 576665
359965 359511
537326 363211
405163 215614
613780 545865
583493 686344
781678 136863
7...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 86114 lines

Test #36:

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

input:

2 3
2 1
1 2

output:

1
2

result:

ok 2 lines

Test #37:

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

input:

100000 1000000
788144 4384
170771 62458
519004 298073
256883 533936
534461 898955
641139 672009
317748 553598
174942 56954
973532 723015
841113 570825
37255 896101
260133 464081
139778 145743
57942 938544
53248 330
645496 633217
158889 481739
272061 66974
826490 878954
809241 429174
722922 844642
21...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 100000 lines

Test #38:

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

input:

90687 139009
3956 123218
59281 127138
48972 58228
47401 20366
35390 2691
68970 77224
11988 23553
10022 68762
121059 31316
17258 105534
2427 98934
48957 68786
94441 115274
129072 78715
108163 119674
55810 64752
69932 1647
129048 135349
23153 85588
60023 5835
13624 2663
136294 80862
129858 89381
60210...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 90687 lines

Test #39:

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

input:

67647 96780
23111 47271
71542 50551
88735 9231
29426 93086
22467 77003
49456 57064
43617 25182
63311 76752
92569 36796
92079 63704
44756 42903
34123 83690
41211 92729
44010 71246
27160 37740
92282 42055
76685 1388
74332 54538
75555 44886
89656 28402
60278 79107
66361 13258
8725 45573
68617 66304
916...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 67647 lines

Test #40:

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

input:

82768 924871
858062 138672
23492 835766
320700 330796
534816 195221
165345 742793
566300 69982
304791 133820
301177 528260
711055 793440
773093 274063
622505 54539
461509 891595
194724 664040
621305 472316
451306 917457
542642 558713
460961 609238
904887 624175
904530 153181
923198 803473
828823 783...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 82768 lines

Test #41:

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

input:

100000 1000000
281950 737634
406671 682450
643435 297645
83691 45968
931429 543042
333974 625353
933780 537382
99957 115098
452506 761337
54208 103666
665013 437910
731910 71039
611956 695553
809022 818827
586364 111837
168727 462798
361759 611832
723840 247039
2958 494743
876119 791761
158598 12559...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 100000 lines

Test #42:

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

input:

1 1000000
1 2

output:

1000000

result:

ok single line: '1000000'

Test #43:

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

input:

2 1000000
2 1
1 2

output:

999998
2

result:

ok 2 lines

Test #44:

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

input:

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

output:

1000000
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 100000 lines

Test #45:

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

input:

100000 1000000
548938 592979
715351 844456
602900 858139
545006 847443
423652 623559
645890 384379
437584 297533
891767 56713
963656 272655
383439 477662
791720 812163
528891 479974
568041 392782
925590 836073
71036 337394
87129 648167
20219 368239
832614 957148
778151 140350
870006 870081
978611 47...

output:

800002
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

result:

ok 100000 lines

Test #46:

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

input:

55482 192266
122699 53874
149548 184487
55654 168088
191171 40283
69542 170313
49353 43761
608 102146
192263 5202
8369 110416
84122 12774
152695 31524
188709 11387
149472 122877
77527 135813
108455 24633
10803 182303
74474 174625
71427 121590
66356 134706
15865 19243
78833 101947
48492 159283
12892 ...

output:

2
3
141301
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 55482 lines