QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#354437#5142. Grid PointsCrysflyAC ✓314ms19084kbC++175.3kb2024-03-15 12:57:152024-03-15 12:57:17

Judging History

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

  • [2024-03-15 12:57:17]
  • 评测
  • 测评结果:AC
  • 用时:314ms
  • 内存:19084kb
  • [2024-03-15 12:57:15]
  • 提交

answer

// what is matter? never mind. 
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2") 
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
#define int long long
#define ull unsigned long long
#define i128 __int128
#define SZ(x) ((int)((x).size()))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
inline int read()
{
    char c=getchar();int x=0;bool f=0;
    for(;!isdigit(c);c=getchar())f^=!(c^45);
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
    if(f)x=-x;return x;
}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;
 
#define maxn 500005
#define inf 0x3f3f3f3f

// i=[0..n] (a*i+b)/c
i128 floor_sum(i128 n,i128 a,i128 b,i128 c){
	i128 res=0;
//	For(i,0,n)res+=(a*i+b)/c;return res;
	res=(n+1)*(b/c)+n*(n+1)/2*(a/c);
	a%=c,b%=c;
	if(a<0)a+=c,res-=n*(n+1)/2;
	if(b<0)b+=c,res-=n+1;
	if(!a)return res+(n+1)*(b/c);
//	i128 m=(a*n+b)/c;
//	i128 t=floor_sum(m-1,c,c-b-1,a);
//	res=n*m-t;
	i128 t=a*(n+1)+b;
	if(t>=c) res+=floor_sum(t/c-1,c,t%c,a);
	return res;
}

i128 floor_sum(i128 a,i128 b,i128 c,i128 l,i128 r){
	return floor_sum(r,a,b,c)-floor_sum(l-1,a,b,c);
}

#define double long double
typedef double db;
const db eps=1e-10,pi=3.14159265358979323846;

struct P{
	int x,y;
	P(int x=0,int y=0):x(x),y(y){}
	P&operator +=(P o){return x+=o.x,y+=o.y,*this;}
	P&operator -=(P o){return x-=o.x,y-=o.y,*this;}
	P&operator *=(int o){return x*=o,y*=o,*this;}
	P&operator /=(int o){return x/=o,y/=o,*this;}
	friend P operator +(P a,P b){return a+=b;}
	friend P operator -(P a,P b){return a-=b;}
	friend P operator *(P a,int b){return a*=b;}
	friend P operator /(P a,int b){return a/=b;}
	friend bool operator <(P a,P b){return a.x==b.x?a.y<b.y:a.x<b.x;}
	friend int operator %(P a,P b){return a.x*b.x+a.y*b.y;} // dot
	friend int operator *(P a,P b){return a.x*b.y-a.y*b.x;} // cross
	
	inline double ang(){return atan2(y,x);}
	inline double l(){return sqrt((*this)*(*this));}
	
	void read(){cin>>x>>y;}
	void out(){cout<<"("<<x<<","<<y<<")"<<endl;}
};


const int W=1000000000,V=W*W+W+1;
pii getid(int x){
	if(x<=V)return mkp(x,V);
	return mkp(V,V*2-x);
}

int gcd(int x,int y){
	x=abs(x),y=abs(y);
	return __gcd(x,y);
}

int n,k;
P a[maxn];
db ang[maxn],ang2[maxn];

int tmp[maxn];

bool isin(P a,int k1,int k2,int xl){
	return a.x<=xl && (i128)a.y*k2<=(i128)a.x*k1;
}

i128 Div(i128 a,i128 b){
	if(a>=0) return a/b;
	return (a-b+1)/b;
}
int gclamp(i128 x){
	return (int)max(min(x,(i128)V),-(i128)V);
}
void clamp(int&l,int&r,i128 k,i128 b){
	if(k==0){
		if(b<0)l=1,r=0;
		return;
	}
	if(k>0){
		i128 t=Div(b,k);
		r=min(r,gclamp(t));
	}else{
		i128 t=Div((-b)+(-k)-1,-k);
		l=max(l,gclamp(t));
	}
}

int seg(P u,P v,int k1,int k2,int xl){
	if(u.x>v.x)swap(u,v);
	int d=gcd(v.x-u.x,v.y-u.y);
	int l=1,r=d-1;
	i128 dx=(v.x-u.x)/d,dy=(v.y-u.y)/d;
	clamp(l,r,dx,xl-u.x);
	clamp(l,r,dy*k2-dx*k1,(i128)u.x*k1-(i128)u.y*k2);
	return max(0ll,r-l+1);
}

pair<int,db>calc(P u,P v,int id,int k1,int k2,int xl){
	int res1=0; db res2=0;
	if(u.x==v.x)return mkp(res1,res2);
	if(u.x>v.x)swap(u,v);
	
	int l=u.x+1,r=min(v.x-1,xl);
	int a=v.y-u.y,c=v.x-u.x,b=u.y*c-u.x*a-1;
	clamp(l,r,(i128)k2*a-(i128)k1*c,-(i128)b*k2);
//	cout<<"l,r "<<l<<" "<<r<<"\n";
	if(l<=r) res1+=2*(floor_sum(a,b,c,l,r));//cout<<"a,b,c "<<a<<" "<<b<<" "<<c<<"\n";
//	cout<<"res1 "<<res1<<"\n";
	
	l=u.x+1,r=min(v.x-1,xl);
	clamp(l,r,(i128)k1*c-(i128)k2*a,(i128)b*k2-1);
	a=k1,b=0,c=k2;
//	cout<<"l,r "<<l<<" "<<r<<"\n";
	if(l<=r) res1+=2*(floor_sum(a,b,c,l,r));//cout<<"a,b,c "<<a<<" "<<b<<" "<<c<<"\n";
//	cout<<"res1 "<<res1<<"\n";
	
//	cout<<"res1 "<<res1<<"\n";
	res1+=seg(P(u.x,0),u,k1,k2,xl);
	res1+=seg(P(v.x,0),v,k1,k2,xl);
	res1+=seg(u,v,k1,k2,xl);
//	cout<<"res1 "<<res1<<"\n";
	
	if(isin(u,k1,k2,xl)) res2+=ang[id];
	if(isin(v,k1,k2,xl)) res2+=1-ang[id];
	return mkp(res1,res2);
}

int counts(int k1,int k2,int xl){
//	cout<<"count "<<k1<<" "<<k2<<" "<<xl<<"\n";
	int res1=0; db res2=0;
	For(i,0,n-1){
		tmp[i]=0;
		P u=a[i],v=a[(i+1)%n];
		if(u.x==v.x)continue;
		auto [c1,c2]=calc(u,v,i,k1,k2,xl);
		if(u.x<v.x) res1-=c1,res2-=c2;
		else res1+=c1,res2+=c2;
	}
	For(i,0,n-1){
		if(isin(a[i],k1,k2,xl)) res2+=ang2[i];
		res1+=seg(a[i],a[(i+1)%n],k1,k2,xl);
	}
	int res=res1+round(res2);
//	cout<<"Res "<<res<<"\n";
	res/=2;
	return res;
}

void work()
{
	n=read(),k=read();
	For(i,0,n-1)a[i].read();
	For(i,0,n-1){
		P u=a[i]-a[(i+n-1)%n],v=a[i]-a[(i+1)%n];
		ang2[i]=atan2(u*v,u%v);
		if(ang2[i]<0) ang2[i]+=2*pi;
		ang2[i]/=pi;
		u=a[i],v=a[(i+1)%n];
		if(u.x>v.x)swap(u,v);
		if(u.x==v.x)ang[i]=0;
		else ang[i]=((v-u).ang()+pi/2)/pi;
	}
	int l=0,r=2*V;
	while(l+1!=r){
		int mid=l+r>>1;
		pii kk=getid(mid);
		if(counts(kk.fi,kk.se,W)>=k)r=mid;
		else l=mid;
	}
	pii k1=getid(l),k2=getid(r);
	int rk=k-counts(k1.fi,k1.se,W);
	l=0,r=W;
	while(l+1!=r){
		int mid=l+r>>1;
		if(counts(k2.fi,k2.se,mid)-counts(k1.fi,k1.se,mid)>=rk)r=mid;
		else l=mid;
	}
	int ry=(((i128)r*k2.fi)/k2.se);
	cout<<r<<" "<<ry<<"\n";
}

signed main()
{
	int T=read();
	while(T--)work();
	return 0;
}
/*

*/

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 16344kb

input:

4
3 3
1 1
3 1
3 3
4 500000000000000000
1 1
1000000000 1
1000000000 1000000000
1 1000000000
9 22
9 6
6 7
9 7
10 10
6 9
3 9
1 6
1 5
7 3
5 22447972861454999
270353376 593874603
230208698 598303091
237630296 255016434
782669452 568066304
654623868 958264153

output:

3 2
500000000 500000000
7 8
730715389 644702744

result:

ok 4 lines

Test #2:

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

input:

500
3 1
9 5
3 6
5 5
3 3
7 7
2 8
8 6
3 3
2 7
1 1
3 1
3 1
6 9
4 6
5 2
3 9
8 10
7 6
10 3
3 3
8 10
5 2
7 7
3 4
6 3
6 2
8 10
3 5
8 4
10 8
4 4
3 16
10 1
5 6
3 2
3 7
4 2
6 2
3 7
3 11
1 7
3 3
8 7
3 2
1 10
1 6
2 6
3 5
8 1
10 5
1 9
3 10
7 4
6 8
2 4
3 3
6 10
1 3
4 7
3 9
7 5
1 5
4 2
3 15
4 1
5 9
2 10
3 5
1 9
7 ...

output:

9 5
6 7
1 1
5 2
8 8
8 10
8 10
9 6
5 4
4 5
5 7
1 6
7 3
4 5
1 3
4 4
2 10
4 6
5 7
3 9
7 10
9 5
4 4
6 5
4 2
6 7
6 8
1 4
1 4
4 8
3 2
4 1
4 4
5 9
1 6
4 7
4 5
8 4
7 1
8 8
3 8
6 6
1 3
6 5
5 4
1 8
4 6
2 4
2 9
4 5
6 6
6 4
7 9
3 1
6 3
3 2
1 2
5 2
8 3
4 8
7 7
1 4
3 3
4 4
3 4
9 6
7 5
2 4
4 9
5 4
7 9
3 1
1 3
5 5
...

result:

ok 500 lines

Test #3:

score: 0
Accepted
time: 247ms
memory: 16632kb

input:

500
3 12084405018385710
331460715 119904076
443992474 212176195
368959752 599178417
3 937652047917574
387890965 806690359
891389107 876297576
748723443 908286602
3 267910256628065
119712014 822811526
833361776 400608712
489063137 637454364
3 4102577495633102
533141838 823294265
842790945 803579971
8...

output:

369728953 276931697
808838386 866937398
757911281 447754520
765428784 827219064
737447482 855771288
597469869 358367482
408096141 714265302
580224987 155586131
273338160 543280361
519074060 469124540
263317572 545088776
470386462 441783156
466093854 608579356
540499761 718677631
534581495 546549779
...

result:

ok 500 lines

Test #4:

score: 0
Accepted
time: 48ms
memory: 15932kb

input:

500
4 13
10 8
9 9
5 9
2 8
4 5
8 5
6 10
5 10
7 1
4 23
8 1
9 5
10 9
3 4
4 18
3 1
10 2
10 3
6 5
4 9
4 4
3 2
10 5
9 9
4 6
8 9
7 9
4 5
7 2
4 2
10 5
6 7
1 10
10 3
4 9
7 1
10 2
5 5
7 2
4 20
5 4
4 10
1 4
1 2
4 2
9 8
3 9
1 1
4 3
4 10
2 5
9 6
9 8
8 9
4 12
10 8
3 6
8 7
10 3
4 7
7 7
2 1
4 1
7 2
4 11
10 10
2 6
5...

output:

3 8
8 5
4 4
6 5
7 5
7 5
10 4
5 5
2 6
5 4
8 9
3 6
2 1
8 9
3 7
6 5
6 3
3 4
7 6
1 2
2 4
1 5
6 5
2 6
8 2
3 5
10 6
4 6
6 8
4 1
9 6
6 7
10 10
6 4
3 3
6 5
4 1
2 6
6 3
2 8
7 5
2 6
8 8
6 2
5 10
6 7
8 7
6 6
2 6
9 9
5 10
6 5
3 4
4 7
4 6
6 10
6 5
5 5
3 5
4 6
6 10
7 5
9 2
3 5
6 7
3 7
6 6
7 3
6 1
7 7
4 4
5 2
8 3
...

result:

ok 500 lines

Test #5:

score: 0
Accepted
time: 314ms
memory: 16144kb

input:

500
4 33987609407043373
875939492 849676059
284683599 946361575
726296656 591469339
712143740 525145277
4 31936267258098893
729598728 196208690
790703190 626609620
442959304 299137943
387712098 266775762
4 31131923528747089
270918921 573583695
305809394 82289425
768050313 829505323
504721047 7406640...

output:

701518230 775473280
566797057 314487539
581738338 541098664
411889202 415577468
806219508 467506456
339040957 343744579
520081303 580156065
695446950 594297907
752374606 698805860
433544009 389392262
412088424 557786862
491290169 879295059
324516896 343712505
516978349 298999319
248652432 628560992
...

result:

ok 500 lines

Test #6:

score: 0
Accepted
time: 39ms
memory: 17396kb

input:

200
10 34
6 8
9 9
8 9
2 8
4 5
1 3
6 1
6 4
9 4
10 7
10 35
6 7
5 10
4 10
3 9
2 6
6 1
7 2
9 5
8 6
8 7
10 35
5 4
10 1
10 2
8 8
8 10
6 10
6 9
7 7
1 8
1 1
10 22
5 4
1 1
4 2
5 2
7 2
9 9
7 8
5 9
5 5
2 7
10 5
5 8
1 7
2 6
1 4
3 2
4 1
10 3
8 5
8 6
9 10
10 9
5 4
2 4
2 3
10 2
8 4
10 9
7 8
6 7
3 6
4 5
10 48
6 8
3...

output:

6 8
3 7
5 7
8 8
9 3
8 5
2 6
9 8
6 5
4 8
7 7
10 1
4 6
5 9
9 5
4 3
9 9
7 8
1 6
6 9
4 6
1 4
2 7
1 5
4 10
4 2
1 8
2 2
6 7
2 4
3 2
3 2
9 9
8 4
5 7
3 5
5 5
5 5
8 9
7 4
7 4
5 6
3 9
6 4
3 6
1 8
6 3
4 3
4 4
8 5
9 10
9 1
5 5
7 3
5 6
5 4
7 3
2 4
7 5
4 3
9 9
5 4
5 7
3 5
5 2
8 7
8 6
9 8
7 7
4 5
9 5
10 8
7 5
6 7
...

result:

ok 200 lines

Test #7:

score: 0
Accepted
time: 39ms
memory: 16416kb

input:

200
10 5
4 3
5 1
10 1
6 4
8 10
6 9
4 8
3 6
3 10
1 6
10 7
5 7
2 3
4 4
4 2
5 5
5 3
8 1
6 7
2 8
1 7
10 3
8 5
9 9
3 10
4 7
4 6
4 4
1 7
3 4
2 1
7 5
10 22
4 3
1 1
7 2
6 4
9 6
9 7
10 7
6 9
5 9
2 10
10 20
4 4
7 4
7 3
9 2
10 7
9 8
5 5
6 8
4 8
4 6
10 45
8 9
5 9
1 7
5 1
5 2
7 2
7 3
9 2
10 1
9 5
10 28
2 2
8 1
9...

output:

6 1
5 3
3 2
6 6
9 8
3 6
2 2
7 1
4 6
8 1
6 2
2 8
6 7
8 8
8 3
3 9
1 9
3 9
5 5
7 7
4 7
5 2
6 7
5 2
3 9
9 3
6 3
5 7
6 4
8 4
5 7
4 6
3 4
7 9
5 1
7 9
6 6
4 5
9 7
8 5
8 6
3 8
6 9
3 8
7 4
3 5
1 5
4 6
8 6
6 2
3 3
2 7
8 3
5 5
5 6
5 6
6 7
7 9
8 4
8 7
6 3
7 6
3 4
7 8
4 5
4 5
2 4
4 7
5 7
7 6
6 8
4 4
5 1
4 3
5 4
...

result:

ok 200 lines

Test #8:

score: 0
Accepted
time: 42ms
memory: 17584kb

input:

200
10 30
4 3
5 1
6 2
7 3
9 7
8 8
5 5
4 8
3 9
2 2
10 2
5 7
7 5
7 9
6 10
5 10
2 9
1 9
2 4
3 5
4 2
10 35
3 7
7 1
10 2
9 5
10 8
10 10
8 8
6 7
7 8
4 6
10 37
9 8
7 10
8 8
4 6
1 5
6 5
7 5
5 1
9 1
9 4
10 4
8 7
10 9
6 9
5 7
5 5
7 1
7 7
8 2
8 5
10 3
10 40
8 2
7 8
5 10
4 9
5 5
2 7
1 6
2 6
1 2
7 1
10 31
1 1
2 ...

output:

3 6
7 5
5 6
3 5
10 3
4 9
3 4
3 4
6 6
8 3
8 8
5 1
8 6
5 4
1 10
8 7
6 4
2 2
7 7
4 9
7 6
7 7
6 4
6 3
7 2
5 6
6 3
3 2
5 7
5 2
6 6
2 6
7 6
9 3
5 5
2 2
4 8
8 6
7 6
9 10
5 7
2 7
2 3
6 5
3 6
5 7
2 4
8 4
3 5
9 5
8 4
4 10
9 7
3 8
9 5
3 7
1 2
6 7
6 7
1 4
9 5
7 4
5 9
5 5
9 9
2 2
8 6
5 5
5 4
2 5
2 4
3 4
7 6
3 4
...

result:

ok 200 lines

Test #9:

score: 0
Accepted
time: 40ms
memory: 17896kb

input:

200
10 9
2 7
3 5
2 5
2 1
6 3
7 3
9 3
9 6
3 10
4 7
10 35
3 2
9 1
7 4
9 3
7 5
9 6
7 6
4 7
3 8
1 4
10 48
6 3
9 1
10 9
9 10
8 10
5 7
5 9
4 9
3 4
5 2
10 38
10 5
10 9
6 8
1 5
1 3
2 5
4 5
5 5
4 4
6 1
10 37
10 5
9 8
3 10
3 4
2 3
1 1
7 7
8 6
9 3
10 1
10 44
6 5
10 4
9 10
6 6
2 10
1 9
1 6
1 2
5 2
4 4
10 42
5 3...

output:

9 5
3 7
4 8
5 7
4 8
1 4
4 7
4 6
2 6
5 8
8 2
2 8
5 5
6 9
5 4
2 10
5 2
8 2
9 3
4 9
2 6
7 4
4 3
6 9
9 7
6 4
7 9
7 3
10 3
8 4
7 9
3 3
5 5
7 4
5 5
2 8
6 7
5 3
9 2
6 4
3 7
6 8
4 9
6 5
8 7
7 10
8 3
5 3
6 4
3 3
6 2
8 7
2 4
1 8
4 9
2 3
2 6
5 5
7 10
1 9
8 4
7 3
6 6
5 1
7 5
6 8
2 4
6 7
4 3
3 7
8 6
2 6
9 2
7 9
...

result:

ok 200 lines

Test #10:

score: 0
Accepted
time: 39ms
memory: 17740kb

input:

200
10 2
10 2
8 4
7 4
6 4
3 9
2 5
2 4
2 3
4 1
9 1
10 19
8 8
1 9
2 8
1 4
2 2
4 5
3 3
10 1
8 4
10 3
10 7
5 2
5 1
10 6
8 6
6 4
4 7
3 4
3 3
4 3
5 3
10 20
4 6
8 6
8 7
2 10
3 7
2 5
3 2
4 5
6 3
6 4
10 17
2 3
3 1
9 4
10 6
4 7
3 10
1 10
1 6
1 3
2 5
10 42
8 8
5 8
5 10
1 7
1 6
2 4
4 4
7 3
9 1
10 3
10 4
7 7
6 9...

output:

8 1
5 4
9 5
3 5
4 3
3 7
6 2
4 5
4 9
5 4
4 9
1 4
5 3
8 4
7 8
3 8
2 5
5 8
4 8
2 7
7 2
3 9
8 2
5 8
7 3
6 8
3 5
3 6
7 6
7 8
3 3
4 2
3 8
10 2
2 1
7 7
9 6
9 9
4 3
3 4
7 5
9 5
4 6
6 5
5 4
3 6
8 8
9 4
9 7
5 4
8 5
5 5
8 6
6 7
3 2
6 6
6 5
4 7
9 10
2 6
6 5
6 1
3 6
4 9
6 6
1 2
2 5
8 7
7 3
3 3
10 10
6 8
8 4
5 2
...

result:

ok 200 lines

Test #11:

score: 0
Accepted
time: 255ms
memory: 16716kb

input:

200
10 51389395003818138
274110746 812150345
151056109 770557320
72547514 777458294
160254536 662053657
251877784 469544808
296724609 128967723
339595003 352511908
978993827 835819987
641729042 704379000
382879284 754861256
10 113391077951023525
614486567 149483526
616241394 25662099
938799922 77117...

output:

624263300 692614344
719797766 358125683
645283913 632678790
409364845 599793693
198371106 491921289
779443552 336045055
183908853 687745195
439216280 605320621
189804837 305720057
275314948 637561583
659360572 276498659
416519216 491236147
419727721 173766771
707151980 450975421
395933060 876232919
...

result:

ok 200 lines

Test #12:

score: 0
Accepted
time: 37ms
memory: 17464kb

input:

40
50 121
6 13
3 8
1 4
5 8
11 15
7 9
14 11
14 9
11 7
10 7
4 6
14 7
12 6
4 3
7 4
13 6
2 1
14 5
16 1
17 4
18 5
17 9
16 10
15 10
16 13
20 12
18 15
20 16
13 16
20 19
19 19
12 16
16 19
14 19
12 18
14 20
12 19
13 20
12 20
6 20
4 20
2 20
1 20
5 18
6 15
4 16
3 13
3 14
1 16
2 11
50 141
12 9
12 6
8 1
11 4
10 ...

output:

13 19
10 14
17 11
14 12
6 4
10 16
15 8
14 15
14 16
9 6
2 12
12 9
5 8
8 16
12 18
12 9
14 7
8 14
12 17
19 19
6 9
6 3
7 14
17 12
16 17
12 12
16 20
13 9
1 3
17 6
3 18
15 9
10 13
6 9
4 6
6 12
6 17
7 13
14 10
11 14

result:

ok 40 lines

Test #13:

score: 0
Accepted
time: 229ms
memory: 17176kb

input:

40
50 482851715791165276
546326159 188010383
610974197 352600737
661025009 421289671
682778451 396215362
707879921 337976248
744033112 251622709
853159846 76598487
977808549 114660165
990265221 239686197
948363025 341661773
920139552 208511591
948006309 695934039
883615961 565728136
955215470 978862...

output:

92234837 581927490
713300757 73995563
685035698 495285272
724234348 327326739
671255782 250153225
834996919 388372002
872091985 716957981
315646104 182177912
476966746 722363817
533458828 316989502
229486465 768859315
835741088 530520918
181042984 307052453
178855411 659189295
164643632 488887550
43...

result:

ok 40 lines

Test #14:

score: 0
Accepted
time: 36ms
memory: 16308kb

input:

20
100 247
14 18
12 20
11 19
11 20
7 20
12 16
13 13
12 13
11 14
9 16
6 19
4 20
6 18
5 18
4 19
4 18
5 17
6 16
9 14
11 13
11 12
13 10
7 15
8 14
4 17
1 18
9 12
13 9
7 13
2 17
6 13
1 17
3 14
4 12
4 11
4 10
1 7
2 6
2 3
3 6
3 2
3 1
4 2
6 4
4 1
7 2
10 1
8 4
9 5
7 7
5 9
8 7
9 6
10 3
12 4
11 5
11 6
12 5
11 7...

output:

4 10
4 13
8 10
18 12
3 4
18 9
14 14
19 13
9 18
5 5
10 6
16 1
11 3
5 15
14 12
12 16
3 6
11 14
10 17
13 14

result:

ok 20 lines

Test #15:

score: 0
Accepted
time: 213ms
memory: 17736kb

input:

20
100 162153495280354252
501610500 151561800
493789150 175949847
924419080 9549341
621275716 137157995
987235435 11358215
840802570 92921005
731340935 170842820
993822978 116747213
889901111 142380493
915653395 138002865
900883723 149721622
952638180 211520865
409039435 292471770
824566184 24096776...

output:

655544886 430451996
621604657 849634990
576461780 508426508
236196302 886571780
41109900 65255472
469962250 835280239
834491251 774752441
355524414 547150300
775889340 317086741
220628210 403759047
494309101 591039187
607286316 401296265
276941560 380712192
557110380 436881862
308065002 25246685
674...

result:

ok 20 lines

Test #16:

score: 0
Accepted
time: 56ms
memory: 17168kb

input:

4
500 1572
42 49
42 48
38 42
35 38
29 29
23 20
32 33
36 38
37 37
39 39
40 40
29 27
24 20
29 26
33 30
40 38
24 19
16 9
13 5
15 3
16 8
17 8
20 8
24 5
23 16
24 11
24 14
25 11
26 9
27 14
29 6
30 5
29 10
30 8
32 3
32 7
32 9
31 8
32 10
33 3
33 1
35 10
36 16
32 20
30 16
28 16
26 20
37 23
38 27
41 35
40 29
...

output:

72 67
11 74
20 59
45 74

result:

ok 4 lines

Test #17:

score: 0
Accepted
time: 195ms
memory: 16040kb

input:

4
500 326810793396625908
923289363 281790836
977025913 317936081
811490147 245307012
831958500 251231979
877506224 261187896
680211478 156709020
727428138 189886332
740756099 213075437
938671618 312643329
897513565 300001476
821348572 270878049
733772848 233183854
708966548 233864071
693273982 23351...

output:

285650615 400437842
286617888 781545827
98064207 918136592
775281699 974464115

result:

ok 4 lines

Test #18:

score: 0
Accepted
time: 71ms
memory: 17504kb

input:

1
2000 74335
346 231
332 226
339 235
339 237
338 239
344 237
346 240
357 244
352 234
357 237
371 242
362 246
372 252
381 250
380 258
394 255
397 260
395 271
400 272
395 275
387 274
380 269
370 260
383 277
399 291
368 265
323 231
325 235
321 232
342 249
337 247
328 240
310 228
294 214
286 213
274 208...

output:

86 310

result:

ok single line: '86 310'

Test #19:

score: 0
Accepted
time: 231ms
memory: 17376kb

input:

1
2000 40203989437233947
33916963 27241751
46050915 9335619
65684829 40138915
69729772 47370582
57648515 59318446
53398946 106896533
58553292 122325552
66488088 79191623
60835391 132008742
69223973 79140473
61972249 134396814
77823236 124966861
75049875 121280444
70543780 110706477
89929906 10642862...

output:

529257085 92909258

result:

ok single line: '529257085 92909258'

Test #20:

score: 0
Accepted
time: 223ms
memory: 16656kb

input:

1
2000 119235751223864797
917033091 600790595
982044424 619234710
867754595 602222405
844493577 593056677
824431858 601614726
828307378 610236049
822027339 602658028
823800275 610582319
791931015 617586959
880336297 621886345
870802184 622666088
848576972 623660627
910447437 622581993
956966817 6271...

output:

515436269 253717829

result:

ok single line: '515436269 253717829'

Test #21:

score: 0
Accepted
time: 196ms
memory: 17784kb

input:

1
2000 156825723005340909
95116515 469306736
104543124 453847845
105751226 452862542
86679245 390045405
78995501 364397799
57867108 400694748
63009273 373024886
58547886 333579623
52889928 307846775
51356858 361462896
47357794 430184263
47367981 410144373
12136233 371719600
44437292 359415994
503604...

output:

244115273 160394672

result:

ok single line: '244115273 160394672'

Test #22:

score: 0
Accepted
time: 226ms
memory: 17872kb

input:

1
2000 196389323929026005
273199939 897631388
289914823 890943428
158976818 927499391
170244133 921967857
290337091 884472455
241760527 899314001
101040858 941283694
208434633 903630376
245530384 887194415
224481938 884632219
230996855 873872326
172576675 890594961
107375976 929113768
164729633 8702...

output:

566681712 432553739

result:

ok single line: '566681712 432553739'

Test #23:

score: 0
Accepted
time: 222ms
memory: 17160kb

input:

1
2000 80673198294743043
451283363 176212936
478513990 202599251
495594352 186386259
507746415 184446241
471007553 152953554
476203037 143258733
469913357 127811760
468359138 129128827
458477789 144872312
453722155 93747707
468556012 106210213
482967453 122718691
496373709 153291776
503906986 164270...

output:

520172771 185971123

result:

ok single line: '520172771 185971123'

Test #24:

score: 0
Accepted
time: 255ms
memory: 17700kb

input:

10
199 75665468080744538
998246910 601469
996243848 513997972
987969238 513389625
976938909 515521652
976499273 503465623
975017118 519932247
958654079 491699991
957632838 521457139
953905158 491240058
951546613 524646795
946492292 486113226
944768417 531162698
941125688 485168867
940488237 53186131...

output:

888759001 145709257
929769361 23671822
606159016 540250277
781114728 528955223
331295227 56861631
582698062 204896053
471799929 9890038
914551373 347992661
823741426 423964191
659723562 401166600

result:

ok 10 lines

Test #25:

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

input:

10
199 223887038020548999
995590859 2905885
992525378 500159669
983876600 497188487
980211540 509600623
974818641 490874044
973884140 521152391
966936042 482507417
966552207 527404351
963201987 482122216
957345382 538855655
949421816 477238508
947480249 542699205
941692551 477089203
930113852 543597...

output:

831019037 383446905
199595019 217756889
58874027 207252081
408733476 139688906
941828548 60334994
101107312 53292047
119196386 174307600
86919995 19043348
471248961 323254916
596372521 160431160

result:

ok 10 lines

Test #26:

score: 0
Accepted
time: 227ms
memory: 17808kb

input:

10
199 192415647491948020
995864039 2360823
994406411 511198418
993646595 510721217
992643004 526553654
989314220 510552995
988250483 535253183
985201100 501399274
982017750 541577304
968109912 493580925
967434253 559184848
963737382 492646168
955182632 559255350
954544693 491724053
947590988 565667...

output:

428847251 169736975
35741169 172022738
346734706 203482792
406999797 657834680
300181712 761885073
924548024 387321310
537303974 199485412
787192462 442435162
877230582 109391024
871773557 158737682

result:

ok 10 lines

Test #27:

score: 0
Accepted
time: 227ms
memory: 16872kb

input:

1
1999 197372282195117275
999602210 1261
999092115 534312295
997987225 532544949
997531367 535593465
996608188 532426275
996469938 536041700
996407245 532095135
995959882 536172059
995861337 530153792
995179705 536317740
994811677 529832896
993491560 536426878
993185524 529349952
992969877 537388270...

output:

745942633 295429882

result:

ok single line: '745942633 295429882'

Test #28:

score: 0
Accepted
time: 278ms
memory: 19084kb

input:

1
1999 321751104047913169
999913910 458152
999133909 498402055
997157204 498245084
996977228 498593767
996772461 497674531
996590923 499410661
996402131 496946559
994670031 500276421
994589458 496705711
994583793 500293277
994575665 495512152
993856032 500555092
993091845 495203611
992494536 5007461...

output:

347685052 256519434

result:

ok single line: '347685052 256519434'

Test #29:

score: 0
Accepted
time: 267ms
memory: 16988kb

input:

1
1999 347464795230406602
998566345 143858
998260702 493427579
997757700 493234598
997152288 493453752
997127897 493047635
996679397 493917026
996449610 492608504
996125707 496015206
996029682 492600374
995988102 496489714
995830082 491907665
993841155 498018701
993764311 491882159
993178941 4982816...

output:

659013918 593384614

result:

ok single line: '659013918 593384614'

Test #30:

score: 0
Accepted
time: 234ms
memory: 17700kb

input:

10
199 377970472850495883
458726 361620
979436384 414362
1865575 3669526
974478667 12147039
8961567 15975676
971688420 16222230
26157938 16489613
971664326 16551657
27598738 22385464
964627090 25177416
32989000 27438882
963995879 31144819
37680299 32007097
959041021 37190259
38882375 45222418
955125...

output:

163040694 853665543
437278254 421880982
556172253 22321669
371413280 958483424
79905529 793657825
434029162 423930666
369839144 171220982
295747087 706641870
294068632 312623985
203886320 162992053

result:

ok 10 lines

Test #31:

score: 0
Accepted
time: 238ms
memory: 16404kb

input:

10
199 147503427117916649
7812690 16060847
993840531 16119697
10921629 18738883
988620995 29784667
16381032 38345682
988060039 44239709
19895110 47650214
987019556 49378116
23307048 51079682
985752485 51090364
25067575 52566823
983940838 57476356
31219164 58102727
982945980 63994517
32751609 6563665...

output:

550464819 617049607
104099196 557401499
89796418 15482599
442938937 739737316
18762983 69601288
244542742 193731212
403863698 279047463
252573821 242910256
409522632 508850069
59114487 274582481

result:

ok 10 lines

Test #32:

score: 0
Accepted
time: 192ms
memory: 17572kb

input:

10
199 52958032434506311
5080150 937072
999359321 1923864
7553746 10418306
994978576 18508508
31279391 25760959
993316764 35089366
45104311 35813792
987467525 36130083
46469770 38377037
976949682 41619471
58426339 41860250
970821775 43856929
61231488 44909747
967712259 47599869
63264334 54191087
966...

output:

287660633 99216830
197763414 284961185
243412486 24189429
34952678 681588050
288041969 671297927
169557820 906873342
88343645 394453764
263244360 17785648
118994081 396590697
48610858 227343983

result:

ok 10 lines

Test #33:

score: 0
Accepted
time: 278ms
memory: 17708kb

input:

1
1999 76946703007919028
746745 1127282
999937634 1208824
1190186 1481677
999898136 1914736
1847606 2566558
998674639 2930257
2775090 3989849
998673972 4873274
3022121 4932418
997782348 6110572
3440276 6476643
997240428 6488240
3889125 6625313
996732423 7406214
4262466 8051392
996692180 8490889
4458...

output:

658093664 341173705

result:

ok single line: '658093664 341173705'

Test #34:

score: 0
Accepted
time: 262ms
memory: 16304kb

input:

1
1999 92960182075729971
1780194 2483537
999606436 3152345
2114525 3589114
998518535 4022968
2222110 4448102
997816399 4747113
2734411 5009367
996905723 5075400
2737930 6393915
996757901 6614823
3810137 6736802
996455683 6817747
4560695 7230538
996225912 7401898
5769358 7592839
995760659 8566675
594...

output:

328790887 214672065

result:

ok single line: '328790887 214672065'

Test #35:

score: 0
Accepted
time: 229ms
memory: 17780kb

input:

1
1999 110852529382447463
194478 91958
999925831 275656
1573289 408171
999559220 627373
1737886 877905
999319379 1160109
1780615 1944253
998943350 3037117
1944221 4407433
998729835 4571486
2146212 5113802
998477676 6039570
2304014 7047409
998327091 7672706
2501217 8213766
998120584 8278840
2559126 8...

output:

105896388 81589284

result:

ok single line: '105896388 81589284'

Test #36:

score: 0
Accepted
time: 125ms
memory: 17768kb

input:

500
3 8179003110119496
269448210 898160700
179632140 718528560
538896420 898160700
3 43692340786554
39023991 30351993
30351993 43359990
30351993 17343996
3 806029174713120
50743917 456695253
355207419 355207419
253719585 405951336
3 35370480447243542
293146225 58629245
586292450 175887735
410404715 ...

output:

351222983 834128318
36545035 30569196
258027551 397812469
400264008 249033808
215971701 376147333
652743207 473823535
42365617 81520037
208832266 137139286
671374914 379195612
730990874 535511283
351320271 427207620
221328008 133308318
305769195 594004999
374054335 381476271
111686339 190928924
1204...

result:

ok 500 lines

Test #37:

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

input:

500
3 7404006427544139
56715137 226860548
510436233 397005959
340290822 397005959
3 25038918358256316
408919585 490703502
163567834 654271336
327135668 327135668
3 1809459417492222
116608906 58304453
291522265 291522265
116608906 116608906
3 7760417177872683
313736720 627473440
439231408 376484064
5...

output:

313307704 357865197
209310794 575703905
136333273 116743504
456677882 453910024
137040513 384974569
241331492 571453390
210890246 505342001
245009067 261063011
236513201 314242123
219190386 398930379
491401349 213114186
545005553 609514789
561460477 475181152
353347802 438953281
514204803 462002388
...

result:

ok 500 lines

Test #38:

score: 0
Accepted
time: 154ms
memory: 16652kb

input:

500
4 95965839308939
53536112 53536112
46844098 53536112
60228126 33460070
66920140 46844098
4 78026743115837030
232883848 523988658
116441924 349325772
582209620 58220962
465767696 523988658
4 3673385564200733
201142270 120685362
20114227 40228454
100571135 40228454
140799589 20114227
4 26597672369...

output:

57576119 45376063
286772573 368943722
186705470 108786044
193234087 139639022
396161160 497531199
227346277 195660003
101474532 495531198
456181630 479365913
134063945 155022450
129477200 131052247
85718630 71889397
129475749 102497229
223084823 280003315
85450622 41706083
49666481 39014653
67978459...

result:

ok 500 lines

Test #39:

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

input:

500
4 594817022250013
177992392 177992392
711969568 622973372
889961960 889961960
355984784 355984784
4 42213522703171210
151526706 454580118
50508902 151526706
151526706 151526706
404071216 101017804
4 87299892778749042
783813267 174180726
87090363 609632541
174180726 435451815
174180726 261271089
...

output:

668528188 592072402
126439807 265428899
211554742 528876434
95549808 102624035
42619640 60095184
50566840 18073058
217805344 189501695
476684120 340625480
406690207 267057442
79563729 89223997
410722539 508168658
46032581 18025729
239984503 565005537
119870618 225408090
188131561 842641171
18658412 ...

result:

ok 500 lines

Test #40:

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

input:

200
10 278411292735419107
558719964 744959952
838079946 838079946
744959952 838079946
186239988 744959952
372479976 465599970
93119994 279359982
558719964 93119994
558719964 372479976
838079946 372479976
931199940 651839958
10 23709034457434826
165851244 27641874
193493118 55283748
248776866 1382093...

output:

429033930 735824552
122101574 257254692
704007946 476628956
259925022 322761188
448369555 373179142
706974975 517984870
267174303 854965116
330842139 259237881
77064644 233061195
59211193 76921596
744982525 158688990
227447483 86620671
133733685 114357635
70305055 35982958
239935872 46452292
4521264...

result:

ok 200 lines

Test #41:

score: 0
Accepted
time: 118ms
memory: 16664kb

input:

200
10 38284739875362
4726044 3544533
5907555 1181511
11815110 1181511
7089066 4726044
9452088 11815110
7089066 10633599
4726044 9452088
3544533 7089066
3544533 11815110
1181511 7089066
10 8271619677730010
131910156 113065848
150754464 37688616
131910156 150754464
56532924 188443080
18844308 9422154...

output:

4596761 7998223
89807144 162068092
347904652 152245165
29720118 80170197
153143759 91639230
136867115 161467931
443825851 639415254
331062702 480993359
45141881 71878858
82573535 40948940
300169383 409707096
232757955 59690895
97876436 450609680
71740760 67177653
397624467 488734300
229018688 217787...

result:

ok 200 lines

Test #42:

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

input:

200
10 3302335300500112
77233744 57925308
96542180 19308436
115850616 38616872
135159052 57925308
173775924 135159052
154467488 154467488
96542180 96542180
77233744 154467488
57925308 173775924
38616872 38616872
10 25375242959281507
431915930 129574779
431915930 302341151
431915930 431915930
3887243...

output:

126599102 96782808
212956416 292374431
461657686 309763591
538632384 245129729
312971260 466327293
201488157 164150704
378545897 652819210
280731845 54512985
243716772 187231230
271638421 348593552
322966180 390794610
146438503 181191716
122164562 447081919
440563521 468003527
256868124 262347870
90...

result:

ok 200 lines

Test #43:

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

input:

200
10 9166095315752107
64805314 226818599
97207971 162013285
64805314 162013285
64805314 32402657
194415942 97207971
226818599 97207971
291623913 97207971
291623913 194415942
97207971 324026570
129610628 226818599
10 14500015844861572
44629372 66944058
89258744 22314686
178517488 156202802
15620280...

output:

192478671 128637051
56553413 155694800
397152967 551556708
346556938 208578925
79435408 126716306
145641134 334813854
52279877 19612885
573760236 452417978
383527351 496305012
58680434 57630752
235954826 248213337
616545590 438653803
232556684 519879098
97728862 81059784
170514790 154619383
35863154...

result:

ok 200 lines

Test #44:

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

input:

200
10 32822749153322362
404641750 80928350
323713400 161856700
283249225 161856700
242785050 161856700
121392525 364177575
80928350 202320875
80928350 161856700
80928350 121392525
161856700 40464175
364177575 40464175
10 25235022608004957
413557400 51694675
465252075 516946750
413557400 516946750
2...

output:

182714724 201271829
252185410 127457555
340777808 489033720
262872117 348594841
394599842 206102817
149597556 272773554
114640935 95026143
317670938 362279632
398324273 509521001
45041558 33129388
105919972 225704750
89401901 74142956
241501184 280617371
255644708 153142089
612642600 453681902
15452...

result:

ok 200 lines

Test #45:

score: 0
Accepted
time: 115ms
memory: 16844kb

input:

40
50 8166019241779258
656043780 690572400
517929300 690572400
207171720 690572400
69057240 656043780
310757580 656043780
552457920 656043780
34528620 621515160
138114480 621515160
276228960 621515160
552457920 621515160
552457920 586986540
345286200 552457920
172643100 586986540
276228960 552457920...

output:

598708731 189634734
505075752 625603511
300419772 65197384
250853588 229750010
195891531 82631657
96414478 135355678
8926579 4671506
109548855 146643488
430742253 205063419
204574171 239528462
86455139 102539070
246417301 90351886
140757345 87698911
300731948 293993574
183927299 172550815
345999226 ...

result:

ok 40 lines

Test #46:

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

input:

40
50 7732936868389850
100175453 114486232
100175453 143107790
228972464 42932337
214661685 42932337
157418569 42932337
214661685 14310779
243283243 14310779
271904801 14310779
271904801 28621558
286215580 28621558
271904801 71553895
271904801 100175453
228972464 143107790
243283243 114486232
214661...

output:

239925958 117845959
516012561 104462982
144724636 250237624
777771367 365778987
56152583 33888417
54324094 54561286
70357394 345769267
302220422 114250398
165064456 108828583
258869537 38014158
670285410 535907731
64992091 187292951
793660084 942788356
595526866 210532915
150165018 341642281
1526647...

result:

ok 40 lines

Test #47:

score: 0
Accepted
time: 93ms
memory: 17160kb

input:

20
100 28105602313477997
389977728 552468448
519970304 617464736
324981440 552468448
422475872 617464736
487472160 649962880
422475872 649962880
389977728 649962880
324981440 584966592
324981440 617464736
292483296 584966592
324981440 649962880
227487008 649962880
292483296 617464736
259985152 58496...

output:

477417857 183667030
363762912 251001084
343819509 340490516
371814963 476512009
150598925 542622187
262972098 358384347
3843815 15847399
19644123 5625060
343235059 378425488
547970948 526279239
38034234 375103910
320107186 241068545
163590145 113720709
596323113 142741830
197571508 325078080
2472385...

result:

ok 20 lines

Test #48:

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

input:

20
100 18207757606619088
58462842 126669491
48719035 136413298
48719035 126669491
58462842 97438070
48719035 107181877
38975228 136413298
29231421 136413298
9743807 165644719
29231421 126669491
29231421 116925684
19487614 116925684
19487614 97438070
19487614 87694263
48719035 77950456
29231421 68206...

output:

26560446 92367311
293137399 86400007
914253299 133961432
130052103 144713303
703765558 260941975
422576191 50294151
78420748 16814165
97701261 197284933
217168832 283431634
117300433 131361274
102526411 368040389
519159540 224571620
135964539 147337806
778356997 233226664
59947700 20750925
122358087...

result:

ok 20 lines

Test #49:

score: 0
Accepted
time: 86ms
memory: 15988kb

input:

4
500 47826285034211960
441806912 296839019
393484281 317548718
428000446 324451951
393484281 331355184
372774582 338258417
379677815 338258417
379677815 345161650
414193980 338258417
379677815 365871349
365871349 372774582
407290747 372774582
379677815 393484281
407290747 428000446
421097213 421097...

output:

460742757 312886107
90140185 169760591
212137082 318086418
111622379 587586047

result:

ok 4 lines

Test #50:

score: 0
Accepted
time: 130ms
memory: 17576kb

input:

4
500 152340619463114549
185977840 548634628
176678948 548634628
241771192 530036844
251070084 511439060
223173408 520737952
232472300 502140168
241771192 455645708
232472300 446346816
204575624 502140168
223173408 455645708
213874516 446346816
232472300 427749032
185977840 437047924
130184488 39985...

output:

226909091 263855329
247908191 177402130
866479368 707527191
409208117 211067383

result:

ok 4 lines

Test #51:

score: 0
Accepted
time: 117ms
memory: 17476kb

input:

1
2000 214722131619342111
404726592 75581472
394974144 14628672
416917152 97524480
421793376 138972384
421793376 114591264
419355264 65829024
433983936 190172736
433983936 143848608
433983936 90210144
412040928 43886016
412040928 9752448
426669600 46324128
421793376 26819232
414479040 2438112
419355...

output:

586893856 538468987

result:

ok single line: '586893856 538468987'

Test #52:

score: 0
Accepted
time: 77ms
memory: 17296kb

input:

1
2000 7177955778710578
85361367 5940901
83485293 312679
85048688 1250716
88488157 2814111
89113515 3126790
88175478 2188753
88488157 312679
91302268 625358
92552984 938037
93178342 2188753
94429058 1250716
96930490 1250716
98493885 312679
98493885 2188753
99744601 2814111
100369959 4064827
95054416...

output:

14123555 57988947

result:

ok single line: '14123555 57988947'

Test #53:

score: 0
Accepted
time: 62ms
memory: 17872kb

input:

500
3 1
53656179 178853930
35770786 143083144
107312358 178853930
3 42377813772224294
612311959 612311959
262419411 174946274
787258233 262419411
3 39008513493774274
670789584 754638282
83848698 670789584
419243490 335394792
3 11175735157245155
329453640 247090230
205908525 205908525
411817050 41181...

output:

107312358 178853930
440246095 264147657
550027660 687534575
266392553 190280395
191506816 143630112
146473855 292923926
182693140 208792160
409226671 545635561
91489585 106737846
263068806 43844801
311093354 559964632
49838062 99676124
138512882 323196725
261885148 785655439
294563803 331384279
1451...

result:

ok 500 lines

Test #54:

score: 0
Accepted
time: 63ms
memory: 16616kb

input:

500
3 494470421385252
38819548 155278192
349375932 271736836
232917288 271736836
3 4232670765120727
317700820 254160656
190620492 222390574
222390574 31770082
3 995146570594483
203628190 203628190
325805104 244353828
81451276 203628190
3 1733810893952508
254418824 254418824
254418824 63604706
381628...

output:

306870593 268511770
254160656 158850410
203628190 203628190
254418824 63604706
154958070 309916140
232495279 542488984
92296271 323036952
592652064 592648815
77285188 77285188
60692200 84969080
471780248 235890124
125654960 75392976
387683048 436143429
61976960 371861760
345718280 553149247
33682828...

result:

ok 500 lines

Test #55:

score: 0
Accepted
time: 70ms
memory: 17136kb

input:

500
4 1853317
780788032 780788032
683189528 780788032
878386536 487992520
975985040 683189528
4 65896776633459157
59682392 119364784
537141528 358094352
358094352 477459136
119364784 298411960
4 1
3788470 541210
3788470 3788470
1623630 2706050
541210 1082420
4 394209544
506840841 506840841
337893894...

output:

878387330 487994734
119364784 298411960
3788470 541210
450525192 450525192
327986746 72887611
361886573 506641202
105716358 352387860
556586499 556586500
250179237 111190772
261788970 261788970
157775460 126220368
326545924 326545925
705228241 626869547
398127480 298595610
433294449 495193656
477515...

result:

ok 500 lines

Test #56:

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

input:

500
4 11718297823356024
108251086 108251086
433004344 378878801
541255430 541255430
216502172 216502172
4 1635696057174644
70050610 35025305
105075915 105075915
105075915 245177135
70050610 315227745
4 351463384479598
40789806 122369418
27193204 13596602
40789806 13596602
95176214 27193204
4 3916945...

output:

473804342 473804342
105075915 140101220
52265945 20906378
485361012 323574008
15440067 15440067
579310128 868965192
31639272 21092848
224963483 84361306
352926186 529389279
33217739 22145160
99649621 99649621
115406344 403922204
400878548 400878548
258660720 193995540
623166320 701062110
151694279 6...

result:

ok 500 lines

Test #57:

score: 0
Accepted
time: 57ms
memory: 16532kb

input:

200
10 86741714945139306
377753868 503671824
566630802 566630802
503671824 566630802
125917956 503671824
62958978 188876934
251835912 314794890
377753868 62958978
377753868 251835912
566630802 251835912
629589780 440712846
10 93221264438959788
639615648 559663692
479711736 719567604
399759780 799519...

output:

314794890 440712846
390496733 390496733
317379653 238034740
871535124 871535124
469991672 626655563
174712753 145593961
546029780 273014890
315123325 210082217
302714844 378393555
413135076 550846768
64355939 579203451
632345679 813015873
126986930 108845940
476153087 264529493
198457311 198457311
1...

result:

ok 200 lines

Test #58:

score: 0
Accepted
time: 62ms
memory: 16356kb

input:

200
10 27473219203633369
129876992 97407744
162346240 32469248
324692480 32469248
194815488 129876992
259753984 324692480
194815488 292223232
129876992 259753984
97407744 324692480
97407744 194815488
32469248 194815488
10 4560944465918408
121451585 24290317
194322536 48580634
194322536 121451585
170...

output:

98102852 156964563
100999330 57713903
596913444 464266012
51342501 205370004
173142180 76952080
75741092 16831354
55134819 36756546
73855559 590844472
248204424 248204424
403515788 907910524
339031690 610257042
102342234 102342234
380503599 326145942
61484424 163958464
471897162 424707446
523368480 ...

result:

ok 200 lines

Test #59:

score: 0
Accepted
time: 57ms
memory: 17956kb

input:

200
10 4547530164186715
227021308 170265981
283776635 56755327
340531962 113510654
397287289 170265981
510797943 397287289
454042616 454042616
283776635 283776635
227021308 454042616
170265981 510797943
113510654 113510654
10 16090857
317823310 363226640
272419980 408629970
227016650 408629970
45403...

output:

397287289 170265981
272407251 45403364
124453707 248907414
484685620 581622744
587730544 514264226
230818165 115409082
101044022 181879240
151876472 18984559
120915657 80610438
112055330 112055329
193265033 82827871
210765692 316148538
149665726 448997178
527347504 395510628
244365944 183274458
3456...

result:

ok 200 lines

Test #60:

score: 0
Accepted
time: 57ms
memory: 15940kb

input:

200
10 12854793739954670
52531194 183859179
52531194 131327985
78796791 131327985
52531194 26265597
157593582 78796791
183859179 78796791
236390373 78796791
236390373 157593582
78796791 262655970
105062388 183859179
10 958583383487912
21892731 65678193
7297577 29190308
29190308 7297577
36487885 2189...

output:

178504336 178504337
40636916 60955374
693935389 693935389
614995995 409997330
845403447 739728016
89787426 59858284
276075026 441720041
189107512 330938146
536456562 357637708
144667936 144667936
2954543 2585225
255114896 31889362
121213246 484852985
57911180 104240124
59104674 98507790
619548059 20...

result:

ok 200 lines

Test #61:

score: 0
Accepted
time: 58ms
memory: 16344kb

input:

200
10 35774766210713893
957758680 191551736
766206944 383103472
670431076 383103472
574655208 383103472
287327604 861982812
191551736 478879340
191551736 383103472
191551736 287327604
383103472 95775868
861982812 95775868
10 2732409117888208
21709410 86837640
54273525 54273525
43418820 54273525
325...

output:

766206944 191551736
41702364 27801576
52728147 316368882
284690468 284690468
59913324 59913324
96319359 256851624
307993688 123197475
554644590 462203825
203918964 262181525
12946680 7398103
198633680 297950520
114003927 380013090
288334390 259500951
348043635 348043635
493376070 328917380
20361100 ...

result:

ok 200 lines

Test #62:

score: 0
Accepted
time: 59ms
memory: 16552kb

input:

40
50 159837481406820710
637158160 670692800
503019600 670692800
201207840 670692800
536554240 637158160
536554240 603623520
301811760 637158160
67069280 637158160
268277120 603623520
536554240 570088880
335346400 536554240
134138560 603623520
402415680 503019600
268277120 536554240
167673200 570088...

output:

204963375 380646268
111520848 130107656
322583620 161291810
763925397 763925396
85642486 68513989
131548729 10962394
282510449 282510449
398315813 398315813
280916734 60196443
233422518 427941283
603561613 804748817
106363387 67176876
242187134 172990810
253408695 200059496
870644181 512143636
28380...

result:

ok 40 lines

Test #63:

score: 0
Accepted
time: 55ms
memory: 17228kb

input:

40
50 4077180329987028
326734548 373410912
513440004 140029092
326734548 466763640
700145460 46676364
793498188 46676364
700145460 140029092
746821824 140029092
886850916 46676364
886850916 93352728
606792732 560116368
933527280 93352728
793498188 373410912
886850916 233381820
886850916 326734548
74...

output:

858858887 90406199
94275424 76598782
154826601 51608867
192438804 769755216
372827227 512637437
446166545 501937363
138084558 207126837
43688502 33606540
489367344 489367344
88732985 112932890
672038532 42002408
81418286 379952001
183765565 735062260
94339425 50314360
918019173 918019173
15362326 18...

result:

ok 40 lines

Test #64:

score: 0
Accepted
time: 59ms
memory: 17640kb

input:

20
100 281448128760709759
278393370 46398895
417590055 92797790
556786740 185595580
510387845 139196685
603185635 139196685
463988950 92797790
510387845 46398895
603185635 92797790
695983425 139196685
603185635 46398895
788781215 92797790
881579005 92797790
835180110 185595580
835180110 231994475
69...

output:

371191160 603185635
75222900 37611450
502515348 335010232
74213140 89055768
844095870 234471075
77965310 62372248
620302072 165413886
49715199 81352144
169711520 148497580
158807082 272240712
167201346 212801713
133172225 506054455
499386458 470010784
179866740 215840088
1748574 971430
264731774 218...

result:

ok 20 lines

Test #65:

score: 0
Accepted
time: 59ms
memory: 16300kb

input:

20
100 48838581066917632
303928384 284932860
322923908 303928384
303928384 303928384
265937336 265937336
227946288 246941812
246941812 265937336
246941812 284932860
265937336 303928384
284932860 322923908
360914956 360914956
322923908 360914956
303928384 360914956
284932860 360914956
265937336 34191...

output:

239236866 324678604
15121443 24572345
200266192 185961464
1773908 2217385
113811569 154458558
367906092 582517979
453423026 421035667
12268296 8178864
343975185 458633580
135839232 769755648
244622249 815407497
204448205 131430989
592486244 383373452
10612740 12735288
381319730 228791838
31779545 19...

result:

ok 20 lines

Test #66:

score: 0
Accepted
time: 80ms
memory: 17764kb

input:

4
500 62294625915229369
493186531 198746811
478464545 198746811
507908517 235551776
529991496 250273762
507908517 206107804
537352489 242912769
544713482 235551776
559435468 228190783
581518447 235551776
581518447 242912769
552074475 272356741
559435468 287078727
574157454 301800713
529991496 272356...

output:

331244685 220829790
147563024 119894957
367787955 318278038
557645482 246233070

result:

ok 4 lines

Test #67:

score: 0
Accepted
time: 59ms
memory: 17428kb

input:

4
500 370365926700724210
281595720 574924595
375460960 551458285
363727805 551458285
516258820 539725130
516258820 527991975
434126735 539725130
422393580 539725130
527991975 516258820
481059355 516258820
492792510 492792510
492792510 481059355
422393580 516258820
363727805 516258820
316795185 55145...

output:

251565144 591917986
548552220 27427611
14622920 33962911
119285572 313909400

result:

ok 4 lines

Test #68:

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

input:

1
2000 232383214418332
28924020 26098110
29921400 29755170
29672055 28924020
29256480 27344835
28924020 26181225
29007135 26929260
29838285 30253860
30420090 32581080
30170745 31833045
30336975 32414850
29339595 29339595
28757790 27511065
28924020 28259100
29256480 29422710
28508445 26929260
2809287...

output:

31338106 26535643

result:

ok single line: '31338106 26535643'

Test #69:

score: 0
Accepted
time: 96ms
memory: 17684kb

input:

1
2000 192243827418647557
34705075 161276525
28580650 120447025
48995400 155152100
55119825 169442425
22456225 69410150
38788025 126571450
18373275 57161300
30622125 61244250
44912450 81659000
51036875 112281125
53078350 142903250
63285725 136778825
79617525 138820300
77576050 110239650
83700475 138...

output:

631419335 748503715

result:

ok single line: '631419335 748503715'