QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#329778#2210. Hamilton PathCrysflyTL 776ms41532kbC++175.0kb2024-02-17 02:24:482024-02-17 02:24:48

Judging History

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

  • [2024-02-17 02:24:48]
  • 评测
  • 测评结果:TL
  • 用时:776ms
  • 内存:41532kb
  • [2024-02-17 02:24:48]
  • 提交

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
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 mod 1000000007
struct modint{
	int x;
	modint(int o=0){x=o;}
	modint &operator = (int o){return x=o,*this;}
	modint &operator +=(modint o){return x=x+o.x>=mod?x+o.x-mod:x+o.x,*this;}
	modint &operator -=(modint o){return x=x-o.x<0?x-o.x+mod:x-o.x,*this;}
	modint &operator *=(modint o){return x=1ll*x*o.x%mod,*this;}
	modint &operator ^=(int b){
		modint a=*this,c=1;
		for(;b;b>>=1,a*=a)if(b&1)c*=a;
		return x=c.x,*this;
	}
	modint &operator /=(modint o){return *this *=o^=mod-2;}
	friend modint operator +(modint a,modint b){return a+=b;}
	friend modint operator -(modint a,modint b){return a-=b;}
	friend modint operator *(modint a,modint b){return a*=b;}
	friend modint operator /(modint a,modint b){return a/=b;}
	friend modint operator ^(modint a,int b){return a^=b;}
	friend bool operator ==(modint a,modint b){return a.x==b.x;}
	friend bool operator !=(modint a,modint b){return a.x!=b.x;}
	bool operator ! () {return !x;}
	modint operator - () {return x?mod-x:0;}
	bool operator <(const modint&b)const{return x<b.x;}
};
inline modint qpow(modint x,int y){return x^y;}

vector<modint> fac,ifac,iv;
inline void initC(int n)
{
	if(iv.empty())fac=ifac=iv=vector<modint>(2,1);
	int m=iv.size(); ++n;
	if(m>=n)return;
	iv.resize(n),fac.resize(n),ifac.resize(n);
	For(i,m,n-1){
		iv[i]=iv[mod%i]*(mod-mod/i);
		fac[i]=fac[i-1]*i,ifac[i]=ifac[i-1]*iv[i];
	}
}
inline modint C(int n,int m){
	if(m<0||n<m)return 0;
	return initC(n),fac[n]*ifac[m]*ifac[n-m];
}
inline modint sign(int n){return (n&1)?(mod-1):(1);}

#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 1000005
#define inf 0x3f3f3f3f

mt19937_64 rnd(64);
modint pw[maxn];
int n,m;
vi e[maxn];

bool vis[maxn];

int id[maxn],q[maxn],idx;
bool wk(int u){
//	cout<<"wk "<<u<<"\n";
	For(i,1,n)id[i]=q[i]=0;
	q[1]=u,id[u]=1,idx=0;
	For(i,2,n){
		++idx;
		int t=0;
		for(int v:e[u]){
			++idx;
			if(!id[v]){
				if(t!=0 && t!=v)return 0;
				t=v;
			}
		}
		if(t==0)return 0;
		u=t;
//		cout<<"u: "<<i<<" "<<u<<"\n";
		q[i]=u,id[u]=i;
	}
//	cout<<"q: ";For(i,1,n)cout<<q[i]<<" "; cout<<"\n";
	return 1;
}

vector<pii> ans;
modint F(){
	modint res=0;
	For(i,1,n)res=res*10+q[i];
	return res;
}

int mn,mn2;
void chain(){
	ans.pb(mkp(q[1],F().x));
	if(mn==n) return;
	int up=0;
	For(i,mn+1,mn2){
		for(int v:e[q[i]])
			if(id[v]<mn){
				if(up==0||up==i)up=i;
				else up=-1;
			}
	}
//	cout<<"mn,mn2,up "<<mn<<" "<<mn2<<" "<<up<<"\n";
	int qn=q[mn+1];
	if(up==0){
		if(wk(qn)) ans.pb(mkp(q[1],F().x));
	}
	else if(up!=-1 && up!=0){
	//	cout<<"up "<<up<<"\n";
	//	cerr<<"q2: "<<q[up]<<"\n";
		int t=q[up+1];
		if(wk(t)) ans.pb(mkp(q[1],F().x));
	}
}

modint w[maxn];
int c[maxn];
void circ(){
	For(i,0,n+1)c[i]=0;
	w[1]=F();
	For(i,2,n){
		w[i]=w[i-1]-pw[n-1]*q[i-1];
		w[i]*=10,w[i]+=q[i-1];
	}
	For(u,1,n){
		for(int v:e[u])
			if(id[v]<id[u]) {
				if(id[v]==1 && id[u]==n) continue;
				c[id[v]+1]++,c[id[u]+1]--;
			}
	}
	modint res=0;
	For(i,1,n){
		c[i]+=c[i-1];
		if(!c[i]) ans.pb(mkp(q[i],w[i].x));
	}
}

void work(int O)
{
	n=read(),m=read();ans.clear();
//	if(O==14){
//		cout<<n<<" "<<m<<"\n";
//		For(i,1,m){
//			int u=read(),v=read();
//			cout<<u<<" "<<v<<"\n";
//		}exit(0);
//	}
	For(i,1,n)e[i].clear();
	int tim=1;
	while((1<<tim)<n)tim++;
	tim*=4;
//	set<pii>S;
	For(i,1,m){
		int u=read(),v=read();
//		if(S.count(mkp(u,v))) continue;
//		S.insert(mkp(u,v));
		e[u].pb(v);
	}
	bool ok=0;
	
	ll sum=0;
	vi o;
	For(i,1,n) o.pb(i);
	while(o.size() && sum<=m*tim){
		int pos=o[rnd()%o.size()];
		if(wk(pos)){
			ok=1;
			o.clear();
		//	cout<<"ok "<<pos<<"\n";
			break;
		}
		sum+=idx;
		vi o2;
		for(int x:o) if(!id[x]) o2.pb(x);
		o=o2;
	}
//	if(!ok && o.size()){
//		for(int x:o) {
//			if(wk(x)){
//				ok=1;
//				break;
//			}
//		}
//	}
	
	if(!ok){
		cout<<0<<"\n";
		return;
	}
	
	mn=n,mn2=n;
	for(int v:e[q[n]]){
		if(id[v]<mn)mn2=mn,mn=id[v];
		else if(id[v]!=mn && id[v]<mn2)mn2=id[v];
	}
	
	if(mn==1 && mn!=n)circ();
	else chain();
	sort(ans.begin(),ans.end());
	cout<<ans.size()<<"\n";
	for(auto [x,y]:ans)cout<<y<<' ';cout<<"\n";
}

signed main()
{
	pw[0]=1;
	For(i,1,1000000)pw[i]=pw[i-1]*10;
	int T=read();
	For(_,1,T)work(_);
	return 0;
}
/*
1
5 12
3 5
2 3
4 5
2 5
5 3
1 4
3 2
2 4
1 4
4 1
2 5
4 5

5 3 2 4 1
1 4 5 3 2 

1 3 4 2 5
*/

詳細信息

Test #1:

score: 100
Accepted
time: 12ms
memory: 40940kb

input:

1
5 6
3 4
2 5
5 3
1 3
4 2
5 1

output:

2
13425 34251 

result:

ok 3 number(s): "2 13425 34251"

Test #2:

score: 0
Accepted
time: 67ms
memory: 39252kb

input:

67777
9 32
6 3
5 2
7 3
7 8
5 2
5 2
7 8
8 2
7 3
8 9
4 3
2 3
4 3
3 1
1 3
8 3
9 8
3 2
5 6
4 5
9 4
6 7
2 8
5 4
5 3
7 8
5 1
6 9
8 3
6 9
7 8
4 1
5 12
3 5
2 3
4 5
2 5
5 3
1 4
3 2
2 4
1 4
4 1
2 5
4 5
2 10
1 2
1 2
1 2
2 1
1 2
1 2
1 2
1 2
1 2
1 2
10 28
1 9
5 9
6 1
10 5
8 7
1 4
7 10
7 5
6 8
9 4
2 9
6 4
2 6
1 1...

output:

1
132894567 
2
14532 53241 
2
12 21 
1
594731198 
1
74123568 
2
12 21 
1
6241735 
1
1 
1
513264 
1
7241356 
2
213 312 
1
247381965 
1
123 
1
31524 
2
12 21 
1
1 
1
12 
2
132 231 
1
41268753 
1
245378846 
1
526134 
1
413652 
1
12345 
1
31542 
2
12 21 
1
5624713 
1
4675213 
3
202947333 852029431 52029...

result:

ok 148279 numbers

Test #3:

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

input:

90961
2 4
2 1
2 1
2 1
2 1
4 8
4 3
2 1
4 3
1 2
4 1
1 4
1 2
4 2
5 22
1 3
5 2
3 1
3 4
3 4
2 3
2 4
3 2
5 4
5 3
4 3
2 1
1 4
1 2
1 3
2 1
4 5
4 3
1 5
5 3
2 3
4 5
8 22
1 4
3 8
8 6
5 7
5 6
1 3
1 2
8 5
8 3
5 2
6 5
2 5
6 1
6 7
5 4
2 4
4 1
6 3
4 3
8 1
6 5
7 6
10 7
10 8
9 3
10 5
4 6
10 7
10 3
3 1
8 28
7 8
8 5
6 ...

output:

1
21 
1
2143 
0
0
0
0
1
1 
2
12 21 
0
0
0
0
2
12 21 
1
1 
0
0
1
1 
0
0
0
0
0
1
1 
0
0
1
213 
0
0
0
1
1 
0
0
0
2
123 231 
2
12 21 
0
0
1
2413 
0
0
0
1
1 
1
1 
2
12 21 
0
0
0
0
1
213 
0
0
1
132 
0
2
12 21 
0
0
1
1 
1
1 
0
0
0
0
1
21 
0
2
12 21 
1
34152 
0
0
1
1 
0
0
1
1 
0
1
1 
0
0
0
0
0
1
1 
0
0
0
0
...

result:

ok 124496 numbers

Test #4:

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

input:

64460
7 24
6 7
1 3
2 1
5 6
7 5
2 5
4 2
3 1
3 4
1 5
7 6
1 7
1 6
7 2
2 7
4 5
4 3
6 5
7 6
3 1
7 5
2 7
1 7
1 2
7 18
6 2
7 5
3 4
4 5
2 1
6 2
7 6
7 6
5 7
7 6
3 2
1 2
7 2
5 2
1 6
5 1
3 6
3 6
2 4
2 1
2 1
1 2
2 1
5 26
5 1
3 1
5 2
1 4
3 5
2 1
3 4
3 5
1 4
3 4
2 1
2 3
1 4
2 1
1 4
2 4
1 2
3 1
5 2
2 1
4 1
3 4
3 1...

output:

1
5672134 
0
2
12 21 
1
41235 
1
15324 
2
1764352 7643521 
1
1234 
1
374219658 
1
264531 
1
812937456 
1
132 
1
1 
2
12 21 
1
6174235 
1
134800596 
1
273591684 
1
321 
0
2
12 21 
1
625143 
1
1 
1
213 
1
872632014 
1
612345 
1
65384172 
1
193248657 
1
786034249 
1
85462731 
1
231 
1
31542 
1
57461839...

result:

ok 132329 numbers

Test #5:

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

input:

67484
4 19
1 3
4 3
2 3
2 3
4 3
2 3
3 4
4 1
4 1
2 4
2 3
2 1
4 1
4 1
4 3
4 2
4 1
2 1
3 1
10 23
8 4
6 4
6 5
3 2
10 9
5 4
9 5
7 10
8 1
2 6
5 4
2 9
8 4
6 2
5 7
6 3
2 4
9 4
7 1
10 1
4 8
5 2
1 7
2 10
2 1
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 0
8 22
5 4
5 4
6 2
3 2
6 1
8 5
2 3
5 3
7 4
2 6
2 3
5 4
5 6
5 3
1 ...

output:

1
1342 
1
818095235 
2
12 21 
1
1 
1
32617485 
1
3142 
2
12 21 
1
3214567 
1
218350734 
1
824796351 
1
5173264 
1
1 
1
123 
1
623918456 
2
12 21 
1
2613475 
1
491303652 
1
983561724 
1
123 
3
652314987 765231498 876523149 
1
1 
1
68451732 
1
34125876 
1
1 
2
231 312 
2
123 312 
1
81457263 
1
3214 
1...

result:

ok 147424 numbers

Test #6:

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

input:

90788
3 3
2 1
2 3
1 3
5 18
3 2
5 4
4 3
4 3
5 3
3 5
3 4
2 1
2 1
3 2
5 3
4 5
3 5
1 5
3 2
5 2
1 4
2 5
7 4
1 2
5 1
6 7
7 6
8 11
5 4
7 8
4 6
2 3
6 3
2 5
2 6
3 1
7 4
4 7
6 3
8 2
6 8
1 4
5 4
2 5
2 4
1 4
1 3
10 18
5 6
8 5
9 4
4 1
4 8
4 9
6 5
10 8
2 7
2 3
5 10
4 10
8 4
2 1
2 8
2 4
2 3
5 8
8 17
4 6
4 1
2 5
8 ...

output:

0
0
0
0
0
0
0
0
0
0
1
21 
0
0
0
0
1
1 
0
0
1
213 
0
2
12 21 
0
0
0
0
1
1432 
0
0
0
2
213 321 
0
0
0
2
12 21 
0
2
12 21 
0
0
1
52143 
2
12 21 
0
2
12 21 
1
321 
1
1 
1
1 
0
0
0
0
0
0
1
1 
1
321 
0
0
1
1 
0
0
0
0
0
0
0
0
0
0
0
1
321 
0
2
12 21 
2
12 21 
0
0
0
1
321456 
0
1
132 
1
213 
2
12 21 
0
0
0
0...

result:

ok 124312 numbers

Test #7:

score: 0
Accepted
time: 72ms
memory: 40192kb

input:

64767
2 2
1 2
1 2
6 22
4 6
4 2
2 6
1 2
2 6
1 3
5 2
5 3
5 6
1 4
2 1
4 2
2 6
6 3
3 6
5 3
6 3
2 3
6 3
5 6
4 2
6 5
8 14
5 8
7 1
8 3
3 5
1 3
5 7
1 6
2 5
6 4
8 2
3 7
2 1
6 5
4 3
5 10
3 4
4 5
2 4
2 3
2 3
5 1
1 3
3 2
2 5
2 1
8 16
2 3
6 8
2 4
5 8
7 4
3 4
2 1
1 5
1 2
4 5
2 4
8 6
6 3
7 2
7 2
2 7
3 19
1 3
1 2
3...

output:

1
12 
1
365214 
0
1
45132 
0
1
231 
1
3742516 
1
1 
7
1437625 2514376 3762514 4376251 5143762 6251437 7625143 
1
6271354 
1
789165432 
1
354612 
1
45123 
0
1
618432975 
1
891270509 
1
6521374 
0
1
213 
1
1243 
2
12 21 
0
1
351462 
1
4356127 
1
1324 
1
231 
1
3412 
1
942367815 
1
123 
1
213 
1
45321 ...

result:

ok 132887 numbers

Test #8:

score: 0
Accepted
time: 75ms
memory: 39460kb

input:

67812
6 32
2 3
4 6
1 2
2 4
2 6
3 4
1 4
4 5
1 5
3 6
1 6
6 3
3 6
2 6
4 5
5 6
2 3
1 3
2 6
1 2
2 4
2 1
1 2
4 6
1 2
2 6
3 6
1 4
2 6
2 3
4 3
4 2
7 31
6 3
4 7
1 4
6 4
3 2
6 2
2 5
3 4
2 3
6 2
5 7
7 4
6 2
1 4
1 6
1 3
4 3
4 7
6 1
1 2
5 3
3 4
3 4
5 1
1 4
5 4
2 7
4 7
1 5
5 4
6 1
7 19
1 2
1 4
3 5
1 6
1 4
2 5
1 7...

output:

1
563421 
1
7432516 
1
7532416 
1
4257316 
2
12 21 
1
5463721 
1
1 
1
51672348 
1
38174562 
1
183005348 
1
51463278 
1
2314 
1
428691705 
1
2314 
1
209642804 
1
23514 
1
1 
1
613524 
2
419682357 682357194 
2
12 21 
1
625341 
1
1 
1
3245671 
2
132 231 
1
21 
1
6152347 
2
12 21 
1
781704274 
1
8643215...

result:

ok 148213 numbers

Test #9:

score: 0
Accepted
time: 69ms
memory: 40580kb

input:

91345
2 12
2 1
2 1
2 1
1 2
2 1
2 1
2 1
1 2
2 1
2 1
1 2
2 1
2 2
2 1
1 2
7 24
1 2
4 6
5 2
7 1
2 4
3 6
6 4
7 4
4 3
2 4
6 1
6 1
3 7
4 3
7 1
2 7
1 3
7 1
7 4
5 1
5 7
6 7
6 7
1 4
3 4
1 3
1 3
1 2
1 3
7 22
7 5
4 1
5 1
2 1
7 2
3 5
6 7
4 2
4 7
1 4
1 6
5 4
1 6
2 7
1 3
6 3
7 2
1 4
4 2
1 2
6 3
3 5
5 17
1 5
2 5
4 ...

output:

2
12 21 
2
12 21 
0
0
0
1
34521 
0
1
1 
0
0
0
1
1 
0
0
0
0
0
0
0
0
0
2
12 21 
0
0
2
12 21 
2
12 21 
0
0
1
12 
1
1 
1
2143 
2
12 21 
0
2
12 21 
0
0
0
2
12 21 
0
0
2
12 21 
0
0
0
0
2
12 21 
0
0
0
0
1
4312 
2
12 21 
0
0
0
0
0
2
12 21 
1
1 
1
123 
0
0
0
0
0
0
2
12 21 
0
0
1
31254 
0
0
0
0
0
0
0
0
0
0
2
...

result:

ok 125201 numbers

Test #10:

score: 0
Accepted
time: 66ms
memory: 40120kb

input:

64447
3 4
1 2
2 3
3 1
3 2
6 21
4 3
4 6
6 3
3 5
4 6
6 2
1 5
2 5
1 5
3 4
5 2
3 1
3 1
1 6
1 5
4 1
5 1
4 2
4 6
3 6
6 5
6 13
3 2
4 1
6 5
3 5
2 5
5 2
5 3
3 4
6 3
6 5
1 6
4 3
3 2
8 32
7 3
4 2
1 4
7 4
5 4
7 1
4 3
5 6
1 4
3 4
4 2
5 7
1 7
1 7
7 8
1 4
5 1
8 6
3 8
2 8
3 7
3 4
5 4
1 7
3 6
7 6
1 3
1 5
3 2
3 6
6 4...

output:

2
123 231 
1
251634 
1
253416 
1
28643715 
1
231 
3
35124 43512 51243 
1
15234 
1
312 
1
5237461 
1
15432 
0
1
37645812 
2
12 21 
0
1
718392465 
2
12 21 
1
3124 
0
1
312 
1
684297513 
1
41682735 
1
42178356 
1
231 
2
21436875 36875142 
1
532896471 
1
261453 
1
542631 
1
1473526 
1
24513 
1
12 
1
590...

result:

ok 132279 numbers

Test #11:

score: 0
Accepted
time: 72ms
memory: 40100kb

input:

67818
6 23
2 6
2 5
3 5
4 5
2 1
2 3
3 5
2 4
3 4
5 4
4 6
1 2
2 4
3 6
2 5
6 5
1 6
3 1
6 3
2 6
6 5
4 5
1 5
9 11
8 7
3 2
8 3
6 7
4 3
1 5
5 8
8 9
6 3
7 1
2 6
9 26
8 5
6 5
4 3
3 9
5 1
2 4
4 2
6 3
6 8
2 3
8 1
2 3
4 6
4 1
7 5
8 4
5 9
1 3
7 9
9 7
1 6
8 9
5 9
8 5
2 8
2 3
6 9
1 3
3 4
1 6
5 6
2 1
4 6
4 2
4 1
6 2...

output:

1
546312 
1
432671589 
1
397516842 
1
562134 
1
321 
3
132 213 321 
1
652978480 
1
7426315 
1
1675342 
2
317289456 894562173 
1
231 
1
681429753 
1
13654827 
1
123 
1
132 
1
321645 
1
7132654 
1
81492334 
1
431526 
1
4321 
1
437295681 
1
24786315 
1
562143 
1
4231 
1
7154362 
1
83271456 
1
132 
1
1 ...

result:

ok 148279 numbers

Test #12:

score: 0
Accepted
time: 74ms
memory: 40124kb

input:

91112
1 0
9 19
2 7
7 9
2 8
6 5
4 5
2 4
8 1
1 9
1 8
4 2
2 8
7 4
9 3
9 3
8 1
8 5
1 7
6 8
3 5
1 0
4 17
1 2
4 3
3 4
1 2
1 3
1 3
3 4
1 4
2 3
4 2
2 1
3 4
1 4
1 3
1 2
2 4
3 1
3 5
2 1
1 2
3 1
3 2
3 1
4 5
2 1
3 1
1 3
3 4
3 2
3 22
3 2
2 3
2 3
3 2
1 2
1 3
2 1
2 1
3 2
1 2
1 2
3 1
3 2
3 2
2 3
1 2
2 1
1 3
2 1
3 2...

output:

1
1 
0
1
1 
0
0
1
2134 
0
2
12 21 
1
1 
0
0
0
0
0
1
1 
0
0
1
1 
0
2
12 21 
1
21 
0
0
0
0
0
0
0
0
0
1
2431 
0
0
0
0
2
12 21 
1
1 
0
0
0
0
0
2
12 21 
0
0
0
0
0
0
2
12 21 
0
2
12 21 
0
0
0
0
0
0
1
1 
0
0
0
0
0
0
0
0
1
1 
0
0
0
0
0
0
0
2
12 21 
1
1 
0
0
1
4213 
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1342 
0
0
...

result:

ok 124751 numbers

Test #13:

score: 0
Accepted
time: 69ms
memory: 39284kb

input:

64942
5 15
5 2
5 3
1 4
2 3
2 3
2 3
2 1
2 3
4 3
5 1
5 3
2 5
1 3
3 1
4 5
9 24
6 2
2 6
2 1
6 8
7 2
6 5
7 4
4 2
5 7
1 2
3 9
3 2
8 1
9 4
4 6
7 2
9 6
7 8
4 5
7 2
9 6
9 8
3 5
4 3
8 29
8 7
7 1
7 8
3 7
2 6
1 2
3 8
5 7
6 4
5 1
6 1
5 6
3 4
6 2
3 7
1 4
6 2
8 5
3 5
5 1
5 7
1 4
8 1
7 1
3 1
3 5
5 2
6 7
5 3
1 0
9 3...

output:

1
31452 
1
812657439 
0
1
1 
1
739415826 
1
12 
1
3142 
1
321 
1
24513 
1
698741532 
2
12 21 
0
1
859461723 
1
25134 
1
359174676 
2
123 321 
1
38267514 
1
81753264 
1
3214 
1
1342 
1
35214 
1
5314627 
1
87634512 
1
35612487 
1
7314265 
1
213 
1
123645 
1
1 
1
314256 
1
98674518 
1
51734826 
1
1 
1
...

result:

ok 133220 numbers

Test #14:

score: 0
Accepted
time: 73ms
memory: 40940kb

input:

67710
3 11
3 2
3 2
1 2
1 3
3 1
3 2
1 3
3 2
1 2
1 2
2 3
2 13
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
1 2
2 1
8 16
2 7
2 8
3 8
2 1
7 3
2 5
8 4
8 3
5 3
2 7
4 6
7 1
6 7
1 2
7 8
6 8
1 0
9 15
3 1
8 2
4 9
7 9
3 8
2 4
2 8
6 4
9 3
5 1
6 9
6 7
1 5
3 9
5 6
8 25
1 4
6 1
3 2
1 3
1 2
6 5
8 6
6 2
8 1
6 5
1 7
8...

output:

1
231 
2
12 21 
2
38467125 53846712 
1
1 
1
824931567 
1
32714568 
1
387195264 
1
2431 
1
21453 
1
34251 
2
12 21 
1
572136498 
1
154362 
1
67482531 
1
231 
1
25134 
1
496021846 
2
236154 542361 
1
130853701 
1
487915193 
1
73684512 
1
148395726 
1
631524 
1
83526147 
1
123 
1
1 
2
12 21 
1
126534 
...

result:

ok 148022 numbers

Test #15:

score: 0
Accepted
time: 74ms
memory: 40464kb

input:

91134
5 12
5 4
2 3
5 3
3 5
3 4
3 1
3 4
1 3
1 4
1 5
1 5
4 5
2 5
1 2
2 1
1 2
1 2
2 1
4 13
2 4
2 3
2 1
1 3
1 4
4 2
2 4
1 4
2 4
1 3
2 4
3 1
1 4
8 5
3 8
7 4
1 8
6 8
3 8
1 0
3 2
2 1
2 3
3 3
1 2
3 2
2 1
9 9
8 9
6 4
7 4
3 4
4 3
4 7
3 7
7 6
6 1
1 0
7 19
2 4
2 5
6 4
6 2
6 3
2 3
4 2
4 3
4 5
7 4
6 3
5 6
1 7
4 5...

output:

0
2
12 21 
1
3142 
0
1
1 
0
1
321 
0
1
1 
0
0
2
12 21 
1
21 
0
2
12 21 
0
1
312 
2
12 21 
0
0
1
132 
0
0
0
0
0
0
0
0
0
1
231 
0
0
0
0
2
12 21 
0
0
0
0
0
0
0
0
1
1 
0
0
0
1
1 
0
2
12 21 
0
0
0
0
1
1 
0
0
2
12345 34521 
0
0
1
1 
0
0
0
0
0
0
0
1
1 
0
0
2
12 21 
0
0
0
0
0
0
0
0
0
2
12 21 
0
0
1
1 
0
0
0...

result:

ok 124996 numbers

Test #16:

score: 0
Accepted
time: 69ms
memory: 40356kb

input:

64745
1 0
6 29
6 1
4 6
2 1
6 2
2 4
2 6
5 1
2 4
2 5
4 3
2 6
6 1
2 6
2 5
1 3
2 5
2 5
2 3
5 4
5 3
3 5
6 3
2 1
2 6
2 6
4 1
2 1
6 3
2 6
3 15
2 3
2 1
3 1
2 1
1 2
2 1
1 3
2 3
2 3
2 3
2 3
1 3
2 3
2 1
1 3
8 28
2 1
2 5
6 8
7 4
3 8
5 1
5 1
3 4
1 7
4 5
5 3
8 3
2 7
2 4
8 5
8 4
6 7
2 8
8 7
8 3
8 5
2 4
2 8
8 6
3 5...

output:

1
1 
1
135462 
1
312 
0
1
1 
1
6417325 
1
21435 
1
153624 
2
341526 634152 
1
213 
1
4123 
1
3412 
1
7134256 
1
13245 
1
1374652 
1
32145 
1
806432103 
1
83526714 
1
32451 
1
814329565 
1
165423 
1
24531 
1
521880892 
1
81367452 
2
12 21 
1
31542 
2
12 21 
1
132 
1
127835467 
4
218937465 465218937 5...

result:

ok 132955 numbers

Test #17:

score: 0
Accepted
time: 73ms
memory: 41236kb

input:

67788
6 16
1 6
3 5
3 5
5 2
5 4
3 5
5 6
5 3
4 1
1 6
4 5
6 1
3 6
1 2
2 4
3 6
1 0
6 18
1 2
3 2
5 3
5 1
3 6
5 4
2 1
4 3
3 1
3 2
3 1
6 2
5 1
4 5
4 2
3 5
1 3
4 2
2 10
2 1
2 1
2 1
2 1
2 1
2 1
1 2
2 1
2 1
2 1
1 0
2 7
2 1
2 1
2 1
1 2
2 1
2 1
2 1
3 8
1 3
3 2
1 2
3 2
2 1
3 2
1 2
3 2
10 15
3 6
3 5
9 8
4 3
5 10
...

output:

1
612453 
1
1 
1
621354 
2
12 21 
1
1 
2
12 21 
2
213 321 
1
607198422 
2
1432 3241 
1
87645231 
2
3412 4123 
2
12 21 
1
163245 
2
3241 4123 
2
12 21 
2
213 321 
1
1 
2
12 21 
3
482513976 648251397 764825139 
1
51342 
1
123 
1
192574638 
2
12 21 
1
75418632 
1
808163259 
1
842965371 
2
12 21 
1
4123...

result:

ok 148473 numbers

Test #18:

score: 0
Accepted
time: 72ms
memory: 40556kb

input:

90788
5 17
3 5
5 3
4 5
3 1
5 4
1 5
5 2
2 5
1 5
3 4
5 2
4 5
1 3
4 1
2 5
2 4
2 3
3 9
2 3
2 3
2 1
3 2
2 3
2 1
3 1
3 1
2 1
4 22
4 3
2 1
4 1
2 3
1 4
3 2
4 1
3 2
2 3
3 1
4 3
3 4
1 4
3 2
3 1
4 2
4 3
4 3
1 2
1 3
3 1
4 2
10 12
2 5
10 2
10 7
10 3
2 5
9 10
10 6
5 4
3 10
3 10
1 2
3 10
3 6
1 2
3 1
3 1
3 1
2 3
1 ...

output:

0
0
0
0
3
123 231 312 
0
0
0
0
0
0
0
0
0
2
12 21 
0
0
0
0
0
1
132 
2
12 21 
0
0
0
0
1
1 
0
0
1
321 
0
0
1
1 
2
12 21 
0
2
12 21 
0
0
0
0
0
0
1
123 
1
12 
0
1
1 
1
1 
0
0
1
1 
0
0
0
0
0
2
12 21 
0
0
0
0
0
0
0
0
0
3
132 213 321 
0
1
321 
0
1
67254138 
0
0
0
1
1 
0
1
1 
0
0
0
0
2
12 21 
0
0
0
0
1
1 
1
...

result:

ok 123950 numbers

Test #19:

score: 0
Accepted
time: 69ms
memory: 39992kb

input:

64720
3 4
1 3
1 2
1 3
3 1
9 24
9 3
2 3
4 7
1 9
7 2
1 3
8 5
8 4
9 1
4 3
4 5
9 3
1 7
5 6
9 8
6 1
4 3
3 4
1 4
8 6
5 7
3 7
8 7
1 3
2 14
1 2
1 2
1 2
1 2
1 2
1 2
2 1
1 2
1 2
1 2
1 2
1 2
1 2
1 2
7 28
4 2
5 4
4 3
6 2
5 4
6 2
4 3
7 1
4 7
6 2
3 2
6 1
4 6
4 6
2 1
7 5
5 2
5 7
2 3
6 4
5 6
1 6
5 4
7 6
6 3
7 2
5 4...

output:

1
312 
1
723456198 
2
12 21 
1
3216475 
0
3
2537614 3761425 5376142 
1
31842567 
2
12 21 
1
132 
0
1
25431 
1
5143627 
0
0
1
12 
1
36812754 
1
217940400 
1
123 
1
231 
0
1
13425 
1
273148596 
1
312 
2
12 21 
1
312 
1
632145 
1
1456327 
1
52178364 
1
1 
2
24135 35124 
1
3421 
2
12 21 
1
352750555 
1
...

result:

ok 133219 numbers

Test #20:

score: 0
Accepted
time: 75ms
memory: 37584kb

input:

67944
9 29
5 4
3 1
7 3
7 5
8 4
7 4
8 1
4 1
1 2
5 3
1 6
9 6
9 4
7 5
6 9
8 1
3 5
7 5
5 6
5 7
5 1
7 9
4 6
3 2
5 8
4 9
8 2
2 8
8 3
5 16
4 3
5 4
1 4
5 3
5 1
1 3
5 1
3 4
5 2
5 1
1 5
2 4
4 2
1 3
3 1
5 1
9 33
6 5
3 8
6 7
8 9
2 4
4 8
4 5
2 3
4 3
7 8
7 9
7 1
6 1
7 9
4 3
6 2
1 3
6 9
4 6
6 9
1 7
4 5
4 2
5 7
6 8...

output:

1
694128357 
1
24315 
1
938715246 
1
563412 
1
132 
1
329546781 
1
43512 
2
12 21 
1
32145 
2
123 231 
1
782543169 
1
213 
1
541326 
1
123 
1
26573481 
1
5741263 
1
3526174 
1
3756412 
1
968740500 
1
5461237 
1
231 
1
257198308 
1
3214 
1
568024263 
1
1 
1
4312 
1
4723615 
2
34125 41253 
1
321 
1
63...

result:

ok 148525 numbers

Test #21:

score: 0
Accepted
time: 78ms
memory: 40252kb

input:

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

output:

1
12 
0
1
123 
0
0
0
0
0
0
0
1
321 
0
0
0
0
0
2
12 21 
0
0
2
12 21 
1
1 
0
0
0
2
12 21 
2
12 21 
0
2
12 21 
0
0
0
0
2
12 21 
0
1
1 
1
1 
0
0
1
1 
0
0
2
12 21 
1
12 
0
0
0
2
12 21 
0
0
1
1 
0
0
1
312 
0
0
2
12 21 
0
0
0
0
0
1
1 
0
0
1
1 
2
12 21 
0
0
1
1 
0
0
0
1
1 
0
2
12 21 
2
12 21 
0
0
0
2
12 21 ...

result:

ok 124129 numbers

Test #22:

score: 0
Accepted
time: 68ms
memory: 39036kb

input:

64718
1 0
7 19
3 7
5 7
5 6
7 5
3 6
1 3
1 4
6 7
4 5
1 6
1 3
6 3
4 3
2 1
4 1
4 7
1 3
3 2
3 6
7 11
5 6
6 2
3 7
7 1
2 5
2 3
6 4
6 4
1 6
6 4
4 3
9 17
3 9
6 1
5 4
4 6
1 2
4 6
7 6
1 6
2 7
4 3
8 3
2 8
7 2
8 2
3 8
1 5
9 3
2 16
2 1
2 1
2 1
1 2
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
3 7
3 1
2 1
3 2
2 ...

output:

1
1 
1
7563214 
1
4371625 
1
938276154 
2
12 21 
2
132 213 
1
24531 
1
391286754 
1
21543 
1
341972498 
1
1 
1
1253467 
0
2
785392416 853924167 
1
42531 
1
64135287 
0
1
452916738 
1
619375428 
2
1243 2431 
0
1
460072575 
2
12 21 
0
1
321 
1
836752419 
1
34152 
1
2431 
1
23541 
2
3412 4123 
0
2
12 2...

result:

ok 133061 numbers

Test #23:

score: 0
Accepted
time: 72ms
memory: 41176kb

input:

67838
5 15
4 2
1 4
3 4
2 1
2 5
5 1
3 2
2 4
4 1
4 1
2 1
2 3
3 4
1 5
4 1
7 25
6 4
1 2
6 3
5 4
6 7
3 7
3 4
6 3
5 6
2 5
5 1
6 7
6 7
7 3
5 4
6 5
6 2
5 4
5 3
2 1
2 4
4 3
4 1
5 2
4 3
10 32
2 1
7 6
10 7
9 7
5 8
4 10
3 9
5 9
5 6
4 2
9 6
9 8
4 3
5 2
3 7
5 6
3 5
10 1
6 2
9 10
3 5
4 7
9 2
4 1
9 6
10 4
1 8
8 7
5...

output:

1
51423 
1
7341256 
1
762159987 
1
34612578 
1
5364721 
1
690035420 
3
1756234 4175623 7562341 
1
971260441 
1
312 
1
3412 
1
493562178 
1
1 
1
1 
1
312456 
1
231 
1
679905391 
6
164532 216453 321645 453216 532164 645321 
1
132 
1
4231 
1
43521 
1
1243 
1
52341 
1
17458236 
1
748195263 
1
1 
2
14735...

result:

ok 148527 numbers

Test #24:

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

input:

91081
10 26
5 8
3 8
7 1
2 4
1 2
10 9
4 1
9 6
1 7
5 3
8 4
7 5
1 3
10 1
8 2
10 8
8 7
2 5
2 4
1 2
10 7
3 4
5 1
2 8
9 2
6 8
10 2
7 9
1 7
5 17
1 5
5 2
4 1
2 3
5 4
2 4
2 4
4 3
1 3
4 1
4 2
3 2
3 4
4 1
1 2
4 1
4 5
1 0
6 12
3 1
6 5
5 4
5 6
3 4
6 1
4 3
2 5
1 6
1 4
3 4
1 4
8 14
5 7
5 7
2 3
3 6
1 2
7 6
7 4
5 7
...

output:

0
0
0
1
1 
0
0
1
1 
1
1 
0
0
0
0
1
1 
0
1
1 
0
0
0
0
2
12 21 
1
21 
0
0
0
0
0
1
321 
0
0
0
0
1
1 
0
0
2
12 21 
0
0
0
0
0
2
12 21 
0
0
0
0
0
1
1 
0
1
1 
0
0
0
0
0
0
0
1
3421 
0
2
12 21 
0
0
0
1
1 
0
0
0
0
0
0
2
231 312 
0
2
12 21 
0
0
0
0
2
12 21 
0
1
1 
0
0
0
0
2
12 21 
2
12 21 
0
2
123 321 
0
1
1 
...

result:

ok 124817 numbers

Test #25:

score: 0
Accepted
time: 65ms
memory: 39732kb

input:

64614
7 21
1 4
1 5
6 1
6 7
1 6
1 3
6 1
6 3
6 5
5 3
7 2
6 3
4 7
2 5
3 4
7 5
6 7
4 2
1 2
1 7
7 1
10 28
5 9
3 2
9 6
4 1
9 3
5 8
7 6
5 8
7 1
10 9
6 4
5 2
9 6
10 4
6 8
2 7
2 4
5 10
10 7
8 7
3 9
5 6
10 9
10 1
1 8
3 8
2 5
6 9
10 30
7 4
3 1
4 5
7 2
8 4
7 10
4 1
8 3
1 4
2 6
1 2
7 5
6 10
3 2
7 5
3 2
10 7
1 2
...

output:

1
2534716 
1
187693232 
0
1
825619783 
2
152364 523641 
1
4231 
1
213 
1
462351 
1
1 
1
132 
0
0
1
594376821 
0
1
650053133 
1
326154 
1
1362745 
1
4123 
1
1 
1
859732146 
1
792814365 
1
27534618 
1
87265134 
1
745628139 
1
4123 
1
5673241 
1
1 
1
45231 
2
12 21 
1
1 
1
65713842 
1
645803749 
1
3657...

result:

ok 132652 numbers

Test #26:

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

input:

67618
3 10
3 2
3 1
3 1
2 3
3 1
3 1
1 2
2 1
3 2
3 1
10 9
3 4
5 9
9 7
2 10
8 5
10 3
7 6
6 1
1 2
10 28
2 4
7 4
4 2
1 8
4 6
4 8
5 2
6 2
3 5
8 2
9 5
6 1
1 4
1 9
7 8
9 8
10 7
7 5
10 8
2 8
4 2
3 5
5 3
5 8
5 8
9 8
5 2
3 10
5 25
4 2
4 3
5 1
4 1
4 2
2 1
5 2
3 1
2 3
3 1
3 4
3 2
1 5
2 5
2 1
3 2
5 1
5 1
2 1
4 5
...

output:

1
123 
1
597612978 
1
246195351 
1
15234 
1
2351746 
1
1 
1
961374852 
1
4213 
2
12 21 
2
2761453 6145327 
1
7341256 
1
2465317 
1
279864531 
2
213 312 
1
21543 
2
12 21 
1
25341 
2
12 21 
1
876954312 
1
76541328 
2
451263 634512 
1
1 
1
4726315 
1
132 
1
380914827 
1
51423 
1
21 
1
4312 
1
42615873...

result:

ok 147867 numbers

Test #27:

score: 0
Accepted
time: 81ms
memory: 40676kb

input:

91041
4 15
4 2
3 2
1 3
4 3
1 4
4 1
3 4
4 2
1 4
4 2
3 1
1 4
4 3
2 4
2 1
2 4
1 2
1 2
2 1
1 2
2 5
1 2
2 1
2 1
2 1
2 1
8 7
1 7
1 8
1 7
7 6
8 5
5 2
3 7
2 4
1 2
1 2
1 2
2 1
5 11
4 1
1 5
1 5
5 3
5 1
5 2
1 5
3 2
3 2
4 1
1 5
9 6
9 8
9 8
6 3
4 7
9 6
4 8
4 11
3 1
3 1
3 4
3 2
3 1
2 3
4 3
3 1
2 1
4 1
3 2
9 18
6 ...

output:

0
2
12 21 
2
12 21 
0
2
12 21 
0
0
0
0
0
0
0
1
1 
2
12 21 
0
0
0
0
0
0
0
0
0
0
0
0
1
1423 
0
1
1 
1
1 
0
0
0
0
1
4312 
0
0
0
0
0
0
1
312 
0
0
1
1 
1
3421 
0
0
1
21 
0
0
1
12 
0
1
1 
0
0
0
0
0
0
0
0
0
0
1
1 
0
0
0
0
0
0
0
0
0
0
2
12 21 
0
0
0
0
0
0
0
2
12 21 
0
0
0
0
0
0
0
0
0
0
1
1 
1
1 
0
1
1324 
1...

result:

ok 124640 numbers

Test #28:

score: 0
Accepted
time: 69ms
memory: 39900kb

input:

64643
10 14
9 10
9 7
8 6
3 8
6 2
4 9
5 4
2 3
10 5
2 7
1 3
7 1
8 4
4 8
3 25
3 2
1 3
3 1
1 2
3 2
1 2
3 2
3 1
3 1
3 2
1 2
3 2
3 2
1 2
1 2
1 2
3 2
3 2
2 1
1 2
3 1
3 2
3 2
1 2
1 2
10 18
1 10
3 4
10 7
3 9
9 1
9 4
2 10
1 5
6 4
4 7
2 6
9 2
4 8
6 3
8 2
7 5
9 6
5 4
8 28
8 5
3 5
4 8
4 6
1 6
5 6
6 5
4 8
3 6
1 7...

output:

0
1
213 
1
754826321 
1
71658234 
2
1574263 5742631 
1
643125 
1
1 
2
12 21 
1
4312 
1
202378631 
1
682075903 
1
76821383 
0
2
123 321 
1
1 
2
132 321 
1
3142 
1
534216 
2
12 21 
0
1
678426086 
2
42538176 64253817 
1
4732156 
1
46173528 
2
345291786 634529178 
1
24135 
1
13425 
1
15287364 
1
1643587...

result:

ok 132863 numbers

Test #29:

score: 0
Accepted
time: 73ms
memory: 41140kb

input:

67901
9 16
7 8
8 3
4 5
1 6
9 2
3 9
5 1
7 4
6 7
8 4
8 4
7 1
9 8
6 4
2 7
3 6
3 12
3 2
2 3
2 1
1 2
3 2
3 2
3 2
2 1
3 2
3 1
3 1
3 2
4 8
1 3
4 3
2 4
4 2
3 4
2 1
4 1
2 3
3 3
1 3
3 2
2 1
7 16
5 3
5 1
1 3
6 7
3 6
3 5
4 7
1 4
3 6
7 3
7 2
5 6
2 6
5 3
1 6
4 7
4 3
1 2
3 1
4 3
3 10
3 1
1 2
2 3
3 1
3 1
3 1
3 2
2 ...

output:

1
451678392 
1
123 
1
1342 
3
132 213 321 
1
2673514 
1
4312 
1
123 
1
31452 
1
12354 
1
36815436 
2
12 21 
2
12 21 
1
753004361 
1
1 
1
83214765 
1
5264731 
1
364152 
1
62457813 
1
25143 
1
1 
1
27184563 
1
4132 
1
3124 
1
634521 
1
132 
1
649783152 
2
12 21 
1
321 
1
75438126 
1
12345 
2
12 21 
1
...

result:

ok 148469 numbers

Test #30:

score: 0
Accepted
time: 74ms
memory: 40156kb

input:

90746
9 9
3 6
6 3
1 4
9 6
7 6
6 7
4 1
5 4
3 9
6 24
5 4
1 4
3 5
6 4
2 3
4 1
3 2
5 3
2 4
2 6
2 6
6 3
4 3
3 5
1 3
6 3
3 2
6 3
2 6
6 2
1 5
6 2
4 5
5 3
4 12
4 2
3 1
2 4
1 4
4 2
2 3
2 3
3 1
3 1
4 1
3 1
3 4
7 3
3 6
2 7
6 7
8 14
3 2
2 6
4 3
5 3
3 4
3 6
2 7
1 7
1 2
3 2
4 6
3 5
7 8
3 8
6 17
4 3
5 2
5 3
1 2
1 ...

output:

0
0
1
1423 
0
0
1
361245 
0
1
4231 
2
12 21 
0
0
0
0
0
0
0
0
0
0
1
1 
0
0
0
1
1 
0
0
0
0
0
0
0
0
0
2
132 321 
0
0
1
1 
1
312 
1
1 
0
0
0
1
1 
1
132 
1
12 
0
0
1
32514 
2
12 21 
0
0
0
0
0
0
1
1 
1
1 
0
0
0
0
1
1 
0
0
0
0
2
12 21 
0
0
2
12 21 
0
0
0
1
123 
0
2
213 321 
0
0
0
1
12 
0
0
0
0
0
0
2
12 21 ...

result:

ok 124350 numbers

Test #31:

score: 0
Accepted
time: 69ms
memory: 40704kb

input:

64449
9 18
6 2
8 5
6 5
3 6
8 9
3 6
5 7
9 6
4 5
8 7
8 5
1 3
2 1
3 5
2 6
3 1
7 8
6 9
9 13
6 9
5 7
8 1
6 8
1 3
5 8
7 5
9 2
7 1
3 9
2 6
8 5
4 1
6 13
4 5
1 4
4 2
6 2
6 1
6 1
2 4
6 1
2 6
6 3
5 1
6 5
3 6
6 23
1 6
2 4
2 5
1 6
5 4
3 4
5 4
6 2
1 2
5 4
2 4
2 3
5 6
2 1
2 3
4 5
1 2
6 5
4 3
2 6
1 4
6 3
2 6
3 8
2 ...

output:

1
457896213 
1
413926857 
1
514263 
1
345621 
2
123 321 
1
23145 
0
1
5134672 
1
1 
1
1 
1
2341 
1
1 
1
1 
1
562413 
1
1 
1
51324 
1
251463 
1
1 
1
1 
1
5432167 
2
12 21 
1
469258371 
1
354621 
1
52431 
1
41352 
1
26178435 
1
53241 
1
27613485 
2
12 21 
1
2143 
1
562341 
1
4312 
1
1 
0
1
4213 
0
3
4...

result:

ok 132077 numbers

Test #32:

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

input:

1
1 0

output:

1
1 

result:

ok 2 number(s): "1 1"

Test #33:

score: 0
Accepted
time: 68ms
memory: 39944kb

input:

6940
26 139
16 2
17 12
22 10
19 18
26 15
1 25
11 4
16 21
20 2
2 16
6 2
14 22
19 16
26 21
14 9
6 19
16 8
24 8
2 11
20 5
7 24
5 7
13 25
14 23
19 1
14 9
8 23
9 1
6 14
12 23
20 10
3 14
18 26
15 1
7 5
26 2
13 11
22 11
17 25
6 23
5 10
12 8
15 12
23 10
9 14
12 23
10 22
21 8
26 5
8 13
15 1
26 22
3 10
21 17
...

output:

1
803039395 
1
679703927 
1
11572817 
1
321 
1
263139408 
1
708258723 
1
502336119 
1
971692203 
1
63736713 
1
761840921 
1
749807540 
1
562280948 
1
386746264 
1
611363905 
1
1 
1
18500621 
1
555755517 
1
11166572 
1
914077790 
1
247021350 
1
642331762 
1
436089852 
1
9147086 
1
68132479 
1
6329216...

result:

ok 14007 numbers

Test #34:

score: 0
Accepted
time: 78ms
memory: 39992kb

input:

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

output:

1
388507692 
0
0
0
1
156020537 
1
284536366 
0
1
727118253 
1
388820796 
1
736200787 
1
161284473 
1
313096436 
1
542983761 
1
962253439 
1
168218591 
1
75679272 
1
890016350 
0
1
214216675 
1
927708107 
1
481359317 
0
0
1
362777158 
1
371762968 
1
947135918 
1
632415 
1
893571038 
1
463536214 
1
22...

result:

ok 12537 numbers

Test #35:

score: 0
Accepted
time: 64ms
memory: 40000kb

input:

7003
88 182
13 88
47 35
19 52
67 10
11 40
64 65
74 42
85 68
77 83
67 35
80 14
7 34
75 62
23 71
15 52
80 81
81 77
41 58
44 76
24 88
32 48
70 33
79 59
28 2
5 31
41 18
22 17
71 64
60 87
48 39
14 76
25 45
39 43
49 15
61 55
56 64
50 2
53 81
1 28
49 45
22 31
41 49
30 36
86 6
7 28
6 53
8 38
45 28
87 78
9 5...

output:

1
451227539 
1
131855669 
1
41532 
1
713022243 
1
92175039 
1
312 
1
256902889 
1
413670047 
1
4123 
1
657690484 
1
934115646 
1
764219351 
1
331455716 
1
325882276 
1
607023112 
1
912156566 
1
630092241 
1
512736498 
1
501177006 
1
957284644 
1
712963882 
1
16852593 
1
158131925 
1
1546327 
1
44576...

result:

ok 14168 numbers

Test #36:

score: 0
Accepted
time: 65ms
memory: 40328kb

input:

6938
45 47
13 38
41 34
39 44
6 8
23 2
5 18
17 36
29 31
15 28
14 12
31 23
21 7
38 25
38 29
27 3
26 33
32 2
35 30
30 16
11 26
44 45
1 22
24 16
42 10
36 5
34 13
9 37
25 21
3 25
43 11
40 27
2 41
20 15
24 43
18 32
12 1
37 14
4 42
8 40
45 19
22 35
7 24
19 6
33 17
28 9
16 39
23 4
77 235
28 68
66 52
52 70
2...

output:

1
497890422 
1
413170815 
1
119378997 
1
1432 
1
222636575 
2
12 21 
0
1
587631343 
0
1
6573241 
0
1
384690319 
1
976808357 
0
1
642475800 
1
338951218 
0
1
190599764 
1
499299789 
1
203371564 
1
626616407 
1
89573008 
0
0
1
596729601 
1
269581249 
1
362486781 
1
352259823 
1
823046738 
1
182174505 ...

result:

ok 12702 numbers

Test #37:

score: 0
Accepted
time: 73ms
memory: 40056kb

input:

6948
88 187
86 34
80 13
41 83
23 46
66 38
45 11
26 41
86 42
66 20
13 40
30 78
72 47
58 71
60 77
39 34
3 9
8 60
14 35
18 62
41 77
48 74
34 74
20 16
55 67
57 24
20 9
81 19
52 36
23 31
33 45
43 30
42 33
23 56
64 66
10 57
1 80
61 14
64 4
57 3
38 16
15 49
37 60
87 70
74 65
68 48
67 13
27 58
76 37
48 24
6...

output:

1
401212610 
1
356165523 
1
732947595 
1
199079125 
1
447152043 
1
162522825 
1
13665319 
1
442051664 
1
184752936 
1
729047645 
1
34910122 
1
627216143 
1
369949441 
1
795876247 
1
1 
1
140895523 
1
316737166 
1
654902144 
1
971765679 
1
452138860 
1
586826781 
1
399662798 
1
7423615 
1
76246669 
1...

result:

ok 14038 numbers

Test #38:

score: 0
Accepted
time: 64ms
memory: 37692kb

input:

6890
93 234
51 12
19 32
26 45
44 4
47 20
22 10
66 58
76 48
10 40
45 40
59 52
76 53
1 5
84 9
33 13
21 68
5 14
35 5
14 6
19 93
45 52
68 78
27 43
5 85
6 46
4 29
9 58
50 42
50 78
19 25
22 48
8 23
31 45
73 81
60 88
31 2
23 22
69 26
45 38
73 34
92 52
61 47
34 84
7 1
84 2
14 59
39 48
35 37
35 48
49 16
8 55...

output:

1
485236895 
1
974600791 
1
125042643 
1
865704398 
1
978965606 
0
1
158603509 
1
92035595 
1
1752436 
1
622147275 
0
1
212851437 
1
170135681 
1
47835162 
0
1
615839673 
0
1
824551671 
1
1635274 
1
776475342 
1
429537995 
1
276306888 
1
193324560 
0
1
155880424 
1
705887130 
1
505040505 
1
57695535...

result:

ok 12667 numbers

Test #39:

score: 0
Accepted
time: 68ms
memory: 41020kb

input:

6900
67 121
62 29
32 34
55 22
50 32
13 31
47 37
11 45
51 30
9 46
2 6
64 47
46 33
37 7
18 42
8 3
54 56
63 64
10 27
29 4
23 12
45 17
22 47
19 17
62 48
42 66
28 2
10 13
31 45
12 37
59 62
58 33
27 35
67 39
35 36
24 59
27 1
30 25
21 38
44 23
31 36
25 52
12 34
35 61
39 26
23 37
17 41
61 24
45 41
40 11
44 ...

output:

1
496320022 
1
977403196 
1
169652565 
1
947340828 
1
892495025 
1
472785294 
1
613004675 
1
429877516 
1
582223548 
1
72228082 
1
80301878 
1
722218452 
1
729370452 
1
752194532 
1
921478357 
1
710350409 
1
76451778 
1
430312054 
1
852975341 
1
1 
1
503156510 
1
200197215 
1
978521959 
1
288344877 ...

result:

ok 13920 numbers

Test #40:

score: 0
Accepted
time: 69ms
memory: 40184kb

input:

6862
76 257
45 59
11 69
31 23
66 64
55 16
64 27
39 69
31 9
35 76
62 73
31 53
47 51
5 53
28 76
4 30
31 55
30 18
43 73
1 69
73 15
2 34
49 33
62 7
50 3
30 21
2 4
15 60
21 40
35 18
1 20
24 17
59 13
34 9
14 66
18 32
27 13
22 47
28 41
11 18
53 64
27 63
43 40
12 26
6 68
45 5
51 40
38 40
9 55
75 66
17 44
1 ...

output:

1
22943897 
1
341509455 
0
1
972454968 
1
311612880 
1
910867812 
1
1 
0
1
454252677 
1
566468766 
1
516205411 
1
337875927 
1
307260979 
0
1
739019713 
0
1
232083397 
1
20067691 
1
800363339 
1
139042106 
1
801224705 
1
524136 
0
1
791674534 
1
231 
0
0
1
1423 
1
341303469 
1
965303101 
1
809306997...

result:

ok 12516 numbers

Test #41:

score: 0
Accepted
time: 67ms
memory: 37848kb

input:

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

output:

1
169353088 
1
333805780 
2
12 21 
1
545566944 
1
367828843 
1
313683340 
1
243805889 
1
750201723 
1
274127649 
1
665996923 
1
494913767 
1
803297657 
1
862046582 
1
174330274 
1
260214252 
1
313873857 
1
228124726 
1
231 
1
149783592 
1
146265513 
1
565902017 
1
910328595 
1
617238033 
1
807723011...

result:

ok 14026 numbers

Test #42:

score: 0
Accepted
time: 69ms
memory: 40936kb

input:

6924
96 134
58 79
16 66
47 78
23 70
15 93
55 94
11 8
14 22
76 30
80 84
95 35
17 48
77 14
43 89
30 18
37 12
37 73
51 63
67 39
31 91
57 29
55 2
85 4
43 24
34 78
71 64
71 88
88 44
50 40
38 72
11 44
45 95
39 45
49 34
45 83
89 68
90 52
1 67
68 20
78 15
44 34
20 95
9 2
96 80
70 19
92 12
48 9
86 50
43 60
4...

output:

1
603332242 
1
595767421 
1
862472115 
1
364292733 
0
1
708695053 
1
328891809 
0
1
813337090 
1
123 
1
659995401 
1
209623436 
1
840756701 
0
0
1
914704904 
0
1
232576593 
1
925468756 
1
434706327 
0
1
513865543 
1
463606787 
1
112319403 
1
565819967 
1
926357629 
0
1
780795368 
1
211765277 
1
5342...

result:

ok 12679 numbers

Test #43:

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

input:

662
293 1513
137 170
221 230
24 5
270 96
241 139
182 35
246 50
218 19
94 9
110 251
150 249
282 288
103 64
211 51
136 255
7 102
291 95
117 189
35 207
137 266
267 38
281 80
203 285
179 204
269 225
141 192
159 108
205 66
160 277
187 218
166 206
217 206
280 45
50 277
105 272
66 167
263 191
205 174
272 1...

output:

1
181059484 
1
973989468 
1
190554490 
1
3125476 
1
90434053 
1
546449599 
1
766763267 
1
898279070 
1
91398660 
1
96367749 
1
490557476 
1
805710236 
1
969586974 
1
18085359 
1
15327684 
1
389893138 
1
349291242 
1
781265581 
1
962053930 
1
538995493 
1
523960706 
1
532998841 
1
267097996 
1
653515...

result:

ok 1324 numbers

Test #44:

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

input:

664
616 636
394 310
540 13
146 292
580 570
119 77
588 408
235 427
498 513
140 41
599 346
24 504
34 272
549 62
578 576
277 226
493 163
301 517
309 404
244 447
154 512
381 436
206 477
606 460
158 554
457 86
431 413
561 28
406 212
61 497
465 78
53 241
152 420
386 433
361 47
587 540
99 231
84 357
577 36...

output:

1
607899049 
1
552086229 
0
1
159458666 
1
155416062 
1
122655178 
0
1
936737201 
1
25710828 
1
889491795 
1
111329478 
1
617193217 
1
303021676 
1
437878428 
1
583734713 
1
567060643 
1
570928855 
1
395631489 
1
830200402 
1
714998229 
1
871271554 
1
219127143 
1
176778278 
1
393084108 
1
999414712...

result:

ok 1210 numbers

Test #45:

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

input:

661
279 1780
8 117
124 154
96 268
246 172
148 216
17 261
277 254
217 72
186 118
126 108
21 274
16 137
47 195
199 29
249 28
69 108
239 200
55 117
209 89
7 212
194 166
91 176
164 143
210 137
212 103
257 64
39 183
215 198
65 222
112 252
39 132
41 235
41 234
191 192
101 145
92 45
204 193
189 133
165 259...

output:

1
186441506 
1
736726884 
1
642987525 
1
990299401 
1
157634630 
1
267527648 
1
405759120 
1
483243140 
1
278710947 
1
486468248 
1
643438893 
1
351654068 
1
356088632 
1
987056462 
1
634794448 
1
313747891 
1
125413567 
1
280179346 
1
883236183 
1
262837096 
1
286095133 
1
690442814 
1
402073952 
1...

result:

ok 1323 numbers

Test #46:

score: 0
Accepted
time: 110ms
memory: 40360kb

input:

672
915 1561
833 607
261 462
646 35
869 520
356 197
567 642
546 826
181 497
512 177
370 696
598 112
204 678
295 667
374 461
813 745
491 753
431 42
883 820
701 546
459 487
186 164
266 108
514 329
549 647
302 232
514 427
546 111
535 436
779 455
453 249
521 615
242 125
597 104
644 169
365 716
379 302
8...

output:

1
478466136 
1
556229992 
1
858646559 
1
27497148 
1
116021313 
1
364502512 
1
769753897 
1
315256505 
1
794988912 
1
308148972 
1
283043483 
0
1
161744604 
1
526350336 
1
984519307 
1
967395425 
1
819709662 
1
303325881 
1
446472793 
1
101479984 
1
907508921 
1
50327843 
1
795816947 
1
127365677 
1...

result:

ok 1211 numbers

Test #47:

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

input:

667
976 1890
684 253
83 540
547 380
69 50
289 628
290 395
465 933
116 964
968 638
194 445
555 624
602 491
122 89
170 613
713 777
389 291
330 70
302 16
849 570
829 716
364 613
698 11
449 714
620 912
22 69
315 155
689 426
527 318
931 814
559 312
956 58
194 606
558 564
819 258
676 909
65 301
223 865
30...

output:

1
147885323 
1
763146998 
1
485843444 
1
407002767 
1
155481760 
1
187826259 
1
746778590 
1
810668677 
1
630150503 
1
530154162 
1
247805558 
1
929882930 
1
394262719 
1
758751045 
1
974805557 
1
820754412 
1
313897223 
1
335536948 
1
586166508 
1
595867798 
1
839898354 
1
873596757 
1
235231725 
1...

result:

ok 1334 numbers

Test #48:

score: 0
Accepted
time: 121ms
memory: 40388kb

input:

664
983 2507
50 866
154 677
498 337
267 889
950 702
484 174
83 550
329 761
458 435
83 733
750 237
361 456
248 335
817 352
227 317
179 979
678 570
466 603
971 745
795 424
261 173
404 773
6 763
657 331
162 429
547 54
165 905
880 9
586 761
272 459
906 881
881 703
931 452
474 235
464 520
170 140
983 527...

output:

1
306503252 
1
881308607 
1
810455706 
1
750634051 
1
299467002 
1
437718528 
1
396252044 
1
670578492 
1
537094618 
1
407739296 
0
1
937661981 
1
497772135 
1
956582507 
1
633776951 
1
716277341 
0
1
230411693 
0
1
290740318 
0
0
1
645237641 
1
8870827 
1
543086052 
0
1
128738153 
1
177361950 
1
32...

result:

ok 1199 numbers

Test #49:

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

input:

658
605 1502
256 350
102 453
405 528
327 36
279 183
301 411
151 383
140 166
187 372
102 40
366 477
428 598
257 142
339 75
483 551
596 221
92 468
373 280
3 189
325 309
310 330
52 371
58 107
109 27
470 51
109 355
521 461
393 294
506 379
135 293
475 195
363 427
213 449
265 278
314 532
604 282
522 321
5...

output:

1
694373305 
1
704401004 
1
64672955 
1
628382945 
1
654219082 
1
874680069 
1
692540540 
1
590026642 
1
463510138 
1
950237338 
1
869667412 
1
504960425 
1
389539797 
1
950198961 
1
927069292 
1
186392365 
1
534221627 
1
600181810 
1
698603830 
1
602941752 
1
10734852 
1
568851613 
1
448318872 
1
6...

result:

ok 1316 numbers

Test #50:

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

input:

685
318 874
318 83
67 243
7 51
294 51
212 304
143 160
187 91
117 205
32 100
291 172
298 166
78 295
242 273
284 166
121 26
72 281
263 299
10 17
97 3
105 308
79 76
8 153
74 83
257 281
204 196
167 115
234 216
242 230
28 6
188 90
96 193
185 77
147 102
78 165
122 217
270 136
135 190
70 246
260 9
257 95
5...

output:

1
149568141 
1
108311773 
0
0
1
222303294 
1
126483282 
1
916803136 
1
6725143 
1
61987326 
1
108370698 
1
235475114 
1
989798625 
1
379914449 
1
594546546 
1
834382431 
1
436802570 
0
1
655406207 
1
73379656 
1
973100024 
0
0
1
597482727 
1
656135001 
1
563256688 
1
123 
0
1
299799483 
1
430519868 ...

result:

ok 1221 numbers

Test #51:

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

input:

664
996 1573
235 930
876 289
954 905
551 38
736 191
287 890
231 120
915 934
432 846
762 42
937 196
391 333
12 618
681 351
885 471
188 233
470 614
166 112
500 843
525 361
468 420
303 872
39 799
665 457
721 456
883 770
139 905
478 443
803 248
487 655
697 839
582 39
145 913
444 863
827 180
344 519
595 ...

output:

1
182640664 
1
330559594 
1
330781557 
1
59122909 
1
485840724 
1
704566951 
1
905490204 
1
503796328 
1
196101531 
1
293895476 
1
697154237 
1
711381994 
1
726351918 
1
847005659 
1
679404671 
1
536629987 
1
761550149 
1
479486460 
1
977776212 
1
84490640 
1
972862595 
1
732190660 
1
278996861 
1
1...

result:

ok 1330 numbers

Test #52:

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

input:

663
565 2423
250 205
449 563
125 372
272 410
188 228
167 160
237 175
242 262
278 480
252 59
221 360
433 175
319 82
84 28
225 530
534 457
54 526
464 314
242 163
530 122
495 13
535 291
326 502
435 291
530 285
420 307
234 367
100 189
531 219
273 492
281 349
192 11
419 526
532 342
504 358
260 281
410 54...

output:

0
1
496937675 
0
0
1
410986631 
1
397058154 
1
427157446 
1
137465239 
1
41161052 
1
674085312 
1
849055944 
1
432925350 
1
511700440 
1
458042793 
1
994875144 
1
365466127 
1
913347510 
1
509686315 
1
162013570 
0
1
969896047 
0
1
686019701 
1
596574458 
1
658364933 
1
4586670 
0
1
536521052 
1
739...

result:

ok 1191 numbers

Test #53:

score: 0
Accepted
time: 721ms
memory: 40844kb

input:

63
2677 2754
1197 2566
2610 824
1414 843
2217 1173
2564 432
9 926
2435 2468
2567 874
733 1455
2334 1104
2342 1779
125 2668
1265 2231
293 761
1792 1588
1208 1773
1847 331
1984 339
2403 1361
532 2658
1257 2604
1545 877
700 1237
1969 1952
2620 790
2265 186
2259 2475
835 1552
517 756
1595 470
448 702
13...

output:

1
235973941 
1
553576965 
1
557412870 
1
972365467 
1
702386867 
1
525359996 
1
223169878 
1
935244540 
1
874031747 
1
365225770 
1
91857388 
1
563501532 
1
396685995 
1
241370007 
1
666835886 
1
385963076 
1
411444134 
1
342630155 
1
517456469 
1
195285068 
1
749664278 
1
491045488 
1
639795059 
1
...

result:

ok 126 numbers

Test #54:

score: 0
Accepted
time: 776ms
memory: 38588kb

input:

62
7913 24223
4139 7174
4829 4044
7176 2350
6023 2473
1792 4540
1065 700
738 4701
597 1566
3427 6024
4752 1251
4397 6284
3220 3090
5397 5532
2179 4902
5692 2351
3661 1749
4304 3382
836 2615
6611 3530
5859 1496
2542 7907
1770 833
7469 122
2930 7699
1001 539
4329 1292
3662 6782
5825 91
4566 196
6758 3...

output:

1
871975606 
1
724919956 
1
933967825 
1
330851524 
0
1
64713963 
1
774317332 
1
752794235 
0
0
1
509952099 
1
834587901 
1
889738719 
1
634465788 
1
742309555 
1
950315102 
1
64482131 
1
581865268 
1
71228343 
1
186886606 
1
220385272 
0
1
404897201 
1
491101085 
1
799414160 
0
0
1
40063471 
0
1
52...

result:

ok 108 numbers

Test #55:

score: 0
Accepted
time: 707ms
memory: 40480kb

input:

66
4613 23099
1045 4489
473 1604
2959 361
120 773
323 2719
3242 2235
3034 4538
841 1717
2590 2585
4056 3784
2412 275
1718 3509
749 390
2786 1287
3594 4517
4352 4444
813 1598
2011 1901
2126 4258
2864 342
2346 3425
205 3934
3026 4112
84 3453
4303 3275
4245 2205
1057 552
4013 800
2816 1922
383 3582
156...

output:

1
135830770 
1
198550031 
1
913030677 
1
630459844 
1
52895823 
1
517546085 
1
707218629 
1
296608390 
1
632938668 
1
77055165 
1
221146140 
1
544090446 
1
788986050 
1
963168961 
1
988155906 
1
401091200 
1
539600858 
1
804116936 
1
38872988 
1
339011012 
1
993785769 
1
305195893 
1
953500187 
1
75...

result:

ok 132 numbers

Test #56:

score: 0
Accepted
time: 601ms
memory: 40656kb

input:

69
9250 12888
7772 8562
1855 5823
28 289
3677 2708
7490 5941
5559 9017
1427 7612
9242 1295
8943 2789
3529 3917
2850 577
1535 8151
6027 9020
3118 5958
2817 1647
1463 2167
5649 4060
4242 8018
4223 5525
7172 965
2652 1921
2415 6972
2195 8936
1730 2393
5279 2997
6006 1685
4460 5503
3093 8608
1199 8888
2...

output:

1
530757421 
1
624641123 
1
768184123 
1
51939164 
1
264026386 
1
360697261 
1
788831548 
0
1
977281226 
1
502917641 
1
474311829 
1
784429914 
1
654463509 
1
97885749 
1
336252525 
0
0
1
544128912 
1
213915845 
0
1
12490729 
0
1
138763417 
1
413477176 
1
58353605 
1
336541830 
1
131197300 
0
1
3642...

result:

ok 124 numbers

Test #57:

score: 0
Accepted
time: 588ms
memory: 41532kb

input:

71
8051 8780
1719 3289
3159 5107
1521 3624
3284 1065
1999 6606
5557 220
2337 5842
1564 2105
7093 4661
7021 3248
3542 2861
46 3837
4757 4353
5619 5385
5101 2987
2810 6663
1782 7014
2074 4624
2851 2041
4857 779
7078 4795
3317 4469
7389 4075
7516 3937
6369 959
5400 6572
1328 5247
6138 3273
5290 1669
16...

output:

1
634684453 
1
406765255 
1
628989759 
1
294014984 
1
938764507 
1
386577589 
1
715681614 
1
172295904 
1
817546159 
1
868306845 
1
685377526 
1
451768225 
1
729714951 
1
868674141 
1
890078132 
1
827179632 
1
457116423 
1
931859929 
1
601579110 
1
166376242 
1
206944899 
1
118336619 
1
66119523 
1
...

result:

ok 142 numbers

Test #58:

score: 0
Accepted
time: 636ms
memory: 41416kb

input:

70
348 8993
198 279
224 283
326 299
66 308
221 174
7 14
204 176
118 195
142 156
1 48
196 13
135 160
107 160
122 80
80 329
343 250
241 309
107 97
2 63
12 113
128 99
228 334
288 235
155 312
312 30
211 247
9 14
117 43
337 156
199 41
66 10
69 132
314 310
279 229
98 167
20 109
45 291
223 333
345 109
90 7...

output:

1
253698303 
1
408473513 
1
412429805 
0
0
1
445960951 
1
10459489 
0
1
1901863 
1
305696103 
0
1
400940510 
1
996536447 
1
179949735 
1
910913051 
1
246593605 
1
857908408 
1
732969471 
1
833745919 
1
680205097 
1
370782775 
1
696262714 
0
1
974827852 
1
273029853 
1
37076770 
0
0
0
1
80144808 
1
8...

result:

ok 124 numbers

Test #59:

score: 0
Accepted
time: 701ms
memory: 41092kb

input:

71
981 6750
808 432
452 447
330 384
326 761
371 235
711 149
275 640
421 716
841 637
513 325
914 144
946 792
31 131
295 140
244 612
721 26
57 487
146 733
262 782
208 136
808 806
911 350
253 233
674 202
251 837
753 346
912 308
195 779
485 200
69 305
977 819
252 353
283 14
799 618
495 896
506 717
44 15...

output:

1
637999634 
1
471368864 
1
109622535 
1
249560453 
1
224258733 
1
548968902 
1
174554935 
1
283733495 
1
286114865 
1
992489502 
1
343964575 
1
708708995 
1
357310420 
1
154591146 
1
239574974 
1
557155512 
1
374603048 
1
264079287 
1
995674320 
1
21518983 
1
81235123 
1
765570446 
1
469782730 
1
9...

result:

ok 142 numbers

Test #60:

score: 0
Accepted
time: 748ms
memory: 41228kb

input:

67
3549 14773
3145 408
936 1643
1782 3333
2606 244
1470 1529
2940 1764
2586 466
428 875
3351 2117
398 498
3431 3441
493 3215
217 633
3115 2530
1565 1379
2652 1043
1073 1440
3451 2327
324 2984
218 3342
3485 1303
3179 88
874 860
2213 1572
804 122
3167 2307
964 1812
1296 3410
2898 2649
1248 962
1045 40...

output:

1
949828419 
1
625190053 
0
1
792739050 
1
169057093 
0
0
1
823153949 
1
40191129 
1
525117389 
1
191280312 
1
221798665 
1
941200741 
1
240269737 
1
778471162 
0
0
0
0
1
577041976 
1
35639021 
1
436461239 
1
363900320 
1
349959243 
1
167334415 
1
739385810 
1
538878695 
1
805366097 
1
233134287 
1
...

result:

ok 120 numbers

Test #61:

score: 0
Accepted
time: 645ms
memory: 40248kb

input:

63
5617 20424
5001 4990
4802 1836
924 3405
1426 1439
1263 3896
4066 1020
5166 4315
401 89
1548 1158
5065 2656
3831 610
3346 4785
952 2457
1072 2988
5319 1314
2313 4426
3377 5173
226 1888
575 1732
5466 3443
4987 1215
5177 5073
4644 2952
2162 3815
4862 4263
4716 3313
954 5343
2468 4031
4604 738
1182 1...

output:

1
607140508 
1
230815116 
1
494635283 
1
631597170 
1
267986791 
1
257525332 
1
156870541 
1
148636670 
1
677420110 
1
87693454 
1
492105038 
1
268515856 
1
84234960 
1
47482977 
1
523329407 
1
142773743 
1
378300993 
1
668822931 
1
80520187 
1
640101499 
1
730628758 
1
477488296 
1
882877805 
1
359...

result:

ok 126 numbers

Test #62:

score: 0
Accepted
time: 707ms
memory: 41100kb

input:

73
7423 19443
4484 5521
6497 2155
2118 3951
5892 2389
1500 1275
1908 2630
3419 5212
367 3482
3470 6824
1046 2108
543 5742
2924 3940
6489 3653
2920 6115
658 4036
748 3039
1842 2432
5237 1330
4638 4405
4597 2041
2660 764
20 601
6752 6394
690 3525
3230 6100
6713 2889
6094 3762
1188 7245
1740 1898
6132 ...

output:

1
91127391 
1
47588902 
1
386320714 
1
351034561 
1
362937023 
1
831964107 
1
851291829 
1
77696681 
1
98910905 
0
0
1
169879280 
1
308171317 
1
397235260 
1
292963932 
1
98543600 
1
569327608 
1
392804279 
1
858903137 
1
666337899 
1
899821481 
1
565144169 
1
309169815 
1
299838172 
0
1
435351820 
...

result:

ok 138 numbers

Test #63:

score: -100
Time Limit Exceeded

input:

6
82541 233545
32809 47652
29466 50404
28655 6662
73745 67621
55118 18402
35296 31854
52702 72985
36571 71863
31511 15493
56903 27007
62753 43167
10773 27940
77158 47857
30942 33449
79630 35998
76306 28312
70440 45671
82159 77052
8576 9094
11691 55283
33212 15336
39542 14946
51209 9522
41754 57924
2...

output:


result: