QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#481060#7245. Frank SinatraHadtstiAC ✓857ms20064kbC++141.4kb2024-07-16 20:17:142024-07-16 20:17:14

Judging History

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

  • [2024-07-16 20:17:14]
  • 评测
  • 测评结果:AC
  • 用时:857ms
  • 内存:20064kb
  • [2024-07-16 20:17:14]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int T,n,q,x,y,z,fa[100010],a[100010],num,dfn[200010],rk[200010],cnt[100010],s[1010],ans[100010],fg[100010];
vector<pair<int,int> >E[100010];
struct query
{
	int l,r,id;
	friend bool operator <(const query &a,const query &b)
	{
		return a.l/T^b.l/T?a.l/T<b.l/T:a.r>b.r;
	}
}Q[100010];
void dfs(int x)
{
	dfn[x]=++num;
	rk[num]=x;
	for(pair<int,int>i:E[x])
	{
		int y=i.first,z=i.second;
		if(y!=fa[x])
		{
			fa[y]=x;
			a[y]=z;
			dfs(y);
		}
	}
	rk[++num]=x;
}
inline void update(int x)
{
	if(a[x]>n)
		return;
	if(fg[x]^=1)
	{
		if(!(cnt[a[x]]++))
			s[a[x]/T]++;
	}
	else
		if(!(--cnt[a[x]]))
			s[a[x]/T]--;	
} 
int main()
{
	scanf("%d%d",&n,&q);
	T=sqrt(n);
	for(int i=1;i<n;i++)
	{
		scanf("%d%d%d",&x,&y,&z);
		E[x].push_back({y,z});
		E[y].push_back({x,z});
	}
	dfs(1);
	a[1]=n+1;
	for(int i=1;i<=q;i++)
	{
		scanf("%d%d",&x,&y);
		if(dfn[x]>dfn[y])
			swap(x,y);
		Q[i]={dfn[x],dfn[y],i};
	}
	sort(Q+1,Q+q+1);
	for(int i=1,L=1,R=1;i<=q;i++)
	{
		while(R<Q[i].r)
			update(rk[++R]);
		while(L>Q[i].l)
			update(rk[L--]);
		while(R>Q[i].r)
			update(rk[R--]);
		while(L<Q[i].l)
			update(rk[++L]);
		for(int j=0;;j++)
			if(s[j]<T)
			{
				for(int k=j*T;;k++)
					if(!cnt[k])
					{
						ans[Q[i].id]=k;
						break;
					} 
				break;
			}
	}
	for(int i=1;i<=q;i++)
		printf("%d\n",ans[i]);
	return 0;
}

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

详细

Test #1:

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

input:

7 6
2 1 1
3 1 2
1 4 0
4 5 1
5 6 3
5 7 4
1 3
4 1
2 4
2 5
3 5
3 7

output:

0
1
2
2
3
3

result:

ok 6 numbers

Test #2:

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

input:

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

output:

0
1
1
0

result:

ok 4 number(s): "0 1 1 0"

Test #3:

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

input:

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

output:

0
2
2
0
0
2
1
2
0
0
2
2
2
2
0
2
0
2
2
1
2
0
2
0
0
2
1
0
2
0
2
2
0
2
0
0
2
2
2
2
2
0
1
2
2
2
2
2
0
2
2
0
2
2
0
2
0
2
0
2
2
2
2
2
1
2
2
1
2
0
0
2
2
0
0
2
2
2
2
0
2
0
2
0
2
0
0
0
0
1
2
0
2
0
1
2
2
2
2
2

result:

ok 100 numbers

Test #4:

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

input:

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

output:

0
0
0
1
1
0
0
0
2
0
2
0
2
0
2
2
2
2
0
0
0
0
0
0
0
0
2
0
0
0
2
1
2
0
0
0
0
1
1
0
2
0
0
2
0
0
1
2
0
2
0
0
0
0
0
2
0
2
1
2
2
2
0
2
0
2
2
2
0
2
0
2
1
2
0
1
2
0
0
2
0
2
0
2
0
0
2
0
0
1
0
1
0
2
1
2
2
2
2
0

result:

ok 100 numbers

Test #5:

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

input:

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

output:

2
0
1
2
2
2
1
2
2
1
1
1
1
2
1
0
2
2
2
1
1
2
1
0
1
0
1
1
1
2
1
0
1
2
1
1
1
2
1
2
2
1
1
2
1
2
0
1
2
2
2
0
2
1
2
2
1
2
1
2
2
1
2
2
0
1
2
1
2
0
2
1
1
2
2
2
0
1
1
1
1
2
2
1
1
1
2
2
2
0
1
0
2
1
2
2
2
2
1
2

result:

ok 100 numbers

Test #6:

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

input:

316 99856
173 102 0
290 81 1
209 299 0
96 16 0
254 48 1
107 173 0
288 102 1
130 94 1
280 152 0
293 187 1
270 76 1
18 301 0
33 136 1
179 212 1
181 60 1
134 129 0
81 240 1
180 132 1
33 296 1
81 14 0
240 184 0
235 42 0
200 70 0
4 259 1
230 244 0
284 252 1
230 236 0
187 216 1
177 305 1
70 28 1
21 279 0
...

output:

2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
0
...

result:

ok 99856 numbers

Test #7:

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

input:

316 99856
15 21 1
152 21 0
58 21 0
200 21 0
21 267 0
227 21 1
21 72 1
21 270 1
21 28 0
172 21 1
26 21 1
21 257 0
90 21 1
21 134 0
21 46 1
53 21 1
21 31 0
124 21 1
21 312 0
110 21 0
189 21 1
21 150 1
178 21 0
265 21 1
21 165 0
54 21 0
21 35 0
97 21 1
102 21 0
21 96 1
161 21 1
66 21 1
21 127 1
16 21 0...

output:

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

result:

ok 99856 numbers

Test #8:

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

input:

316 99856
192 178 1
279 42 0
304 261 0
47 100 0
282 142 0
122 238 1
295 236 1
128 265 1
124 291 0
299 19 1
144 164 1
113 131 0
206 50 0
242 294 1
7 258 0
22 220 1
5 239 0
270 263 1
156 14 1
66 22 0
254 271 1
295 12 0
69 87 0
302 33 0
4 56 1
34 204 0
168 285 1
98 116 1
50 223 1
205 154 1
145 73 0
84 ...

output:

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

result:

ok 99856 numbers

Test #9:

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

input:

316 99856
173 234 1
290 158 2
143 299 2
74 16 0
254 88 0
107 187 1
288 68 2
234 94 0
280 39 0
293 219 0
270 63 0
286 301 0
181 136 1
179 199 2
221 60 1
9 129 1
143 240 1
206 132 2
33 81 1
81 79 0
313 184 2
235 187 1
200 163 2
148 259 1
230 223 0
189 252 2
204 236 1
284 216 0
259 305 0
124 28 2
21 29...

output:

3
3
3
3
3
1
3
3
3
0
3
3
3
3
3
3
2
3
3
3
3
3
3
1
3
3
3
3
2
3
3
3
3
1
3
0
3
3
3
3
3
3
3
3
0
3
3
3
3
3
3
3
0
2
1
1
3
3
3
1
3
1
0
3
1
3
3
3
3
3
3
3
1
3
3
3
3
3
0
3
3
1
3
3
3
1
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
0
3
3
3
3
3
0
3
3
3
3
3
3
3
3
1
1
3
3
3
0
0
0
3
3
3
3
3
1
0
3
0
3
3
3
3
3
2
3
0
...

result:

ok 99856 numbers

Test #10:

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

input:

316 99856
15 21 1
152 21 1
58 21 1
200 21 1
21 267 1
227 21 1
21 72 0
21 270 1
21 28 1
172 21 2
26 21 2
21 257 2
90 21 0
21 134 0
21 46 1
53 21 2
21 31 2
124 21 2
21 312 1
110 21 2
189 21 2
21 150 1
178 21 1
265 21 0
21 165 2
54 21 2
21 35 2
97 21 1
102 21 2
21 96 0
161 21 1
66 21 2
21 127 0
16 21 0...

output:

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

result:

ok 99856 numbers

Test #11:

score: 0
Accepted
time: 21ms
memory: 9472kb

input:

316 99856
192 178 1
279 42 0
304 261 0
47 100 2
282 142 1
122 238 2
295 236 0
128 265 2
124 291 0
299 19 2
144 164 1
113 131 1
206 50 0
242 294 2
7 258 0
22 220 2
5 239 2
270 263 2
156 14 0
66 22 1
254 271 2
295 12 2
69 87 2
302 33 1
4 56 1
34 204 1
168 285 1
98 116 0
50 223 2
205 154 2
145 73 1
84 ...

output:

3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
1
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
1
3
3
3
3
0
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
2
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
0
3
3
3
3
3
3
3
3
3
3
3
3
3
3
0
3
3
0
3
3
3
3
3
3
3
3
1
3
3
3
3
3
3
3
0
3
3
3
3
3
3
3
...

result:

ok 99856 numbers

Test #12:

score: 0
Accepted
time: 27ms
memory: 9876kb

input:

316 99856
173 193 2
290 193 3
249 299 3
91 16 2
254 306 3
107 6 1
288 63 3
75 94 3
280 1 0
293 105 1
270 42 0
255 301 2
188 136 0
179 234 3
288 60 2
48 129 0
76 240 3
186 132 1
33 1 2
81 187 3
77 184 0
235 48 3
200 11 2
211 259 0
230 24 2
36 252 3
306 236 0
310 216 0
68 305 2
43 28 3
21 192 3
196 16...

output:

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

result:

ok 99856 numbers

Test #13:

score: 0
Accepted
time: 23ms
memory: 9776kb

input:

316 99856
15 21 2
152 21 0
58 21 3
200 21 3
21 267 2
227 21 1
21 72 1
21 270 1
21 28 0
172 21 0
26 21 2
21 257 3
90 21 0
21 134 2
21 46 0
53 21 3
21 31 1
124 21 3
21 312 3
110 21 1
189 21 2
21 150 3
178 21 1
265 21 0
21 165 0
54 21 1
21 35 0
97 21 0
102 21 0
21 96 3
161 21 0
66 21 0
21 127 0
16 21 2...

output:

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

result:

ok 99856 numbers

Test #14:

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

input:

316 99856
192 178 1
279 42 0
304 261 2
47 100 2
282 142 2
122 238 0
295 236 0
128 265 0
124 291 2
299 19 1
144 164 3
113 131 1
206 50 2
242 294 3
7 258 0
22 220 2
5 239 3
270 263 2
156 14 1
66 22 2
254 271 1
295 12 1
69 87 3
302 33 1
4 56 2
34 204 2
168 285 3
98 116 0
50 223 3
205 154 3
145 73 3
84 ...

output:

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

result:

ok 99856 numbers

Test #15:

score: 0
Accepted
time: 720ms
memory: 14312kb

input:

100000 100000
16002 62285 0
94338 15156 0
16232 69491 0
78830 42791 0
42291 79934 0
25280 42281 0
43246 84026 0
81015 59152 0
26228 85524 0
77807 16621 0
87239 27802 0
45572 68749 0
46470 21413 0
91385 31600 0
39840 65919 0
63409 52046 0
61637 45889 0
96346 70771 0
21432 11753 0
38616 69335 0
32943 ...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 100000 numbers

Test #16:

score: 0
Accepted
time: 738ms
memory: 14364kb

input:

100000 100000
18058 1882 1
77635 23818 0
9851 91935 0
16218 67969 0
45198 25980 1
34560 43159 1
1776 39890 0
98660 22738 1
26971 8570 1
2179 17775 0
62019 51220 0
62891 66989 0
16522 90763 1
18870 64357 0
87537 98200 0
77096 4652 1
23186 24016 0
75961 12188 0
93342 52219 0
92566 95797 0
93844 1045 1...

output:

2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 100000 numbers

Test #17:

score: 0
Accepted
time: 633ms
memory: 13812kb

input:

100000 100000
28219 35524 1
28219 53586 0
64427 28219 0
28219 42140 0
45389 28219 0
28219 52860 0
28219 35426 1
28219 90684 1
80876 28219 0
82716 28219 1
28219 3235 1
28219 71380 0
91782 28219 1
81272 28219 1
36766 28219 0
28219 98110 0
82939 28219 0
28219 38431 0
28219 10730 0
26093 28219 1
28219 1...

output:

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

result:

ok 100000 numbers

Test #18:

score: 0
Accepted
time: 159ms
memory: 18108kb

input:

100000 100000
6196 12153 0
41017 63946 1
50788 1093 0
73450 8393 0
39953 43098 1
79223 31673 0
52002 80524 0
17987 71772 1
30033 94926 1
71307 89317 0
54060 27606 1
19745 34037 0
41237 8207 1
63416 54551 1
53426 80067 1
53006 8664 0
48006 34930 0
80417 39489 1
20067 80710 1
6662 17711 1
30332 56310 ...

output:

2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 100000 numbers

Test #19:

score: 0
Accepted
time: 731ms
memory: 14300kb

input:

100000 100000
7760 13303 1
82993 83715 2
62730 56484 0
83039 50548 2
78786 87514 2
10559 10618 1
66287 67668 0
41493 8689 0
57586 13866 2
30300 26277 1
80847 82736 1
78087 44949 1
56814 18488 0
3770 25564 0
92765 44117 1
51973 57772 0
4986 3551 0
48055 89097 1
93264 84315 2
8010 19209 0
14291 53007 ...

output:

3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
0
3
3
3
3
3
3
3
3
3
3
3
3
...

result:

ok 100000 numbers

Test #20:

score: 0
Accepted
time: 573ms
memory: 13608kb

input:

100000 100000
47746 88433 0
59039 47746 0
47746 20905 2
85710 47746 1
44992 47746 1
79653 47746 2
47746 14548 0
31210 47746 0
47746 89755 2
47746 73218 0
22700 47746 0
47746 35494 1
47746 49441 2
11681 47746 0
53229 47746 2
47746 44731 0
47746 95088 1
99629 47746 0
47746 96352 1
47746 54190 0
11523 ...

output:

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

result:

ok 100000 numbers

Test #21:

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

input:

100000 100000
48973 53883 0
12063 14772 2
6775 32451 0
66201 77174 0
65550 77996 2
98741 34355 1
77638 13750 2
3352 77664 0
59883 33050 1
17186 14578 2
69513 82629 0
1006 42174 1
18820 60006 1
66415 65700 1
44740 71182 1
71950 13297 1
89729 50426 2
63573 67261 1
98428 25648 0
45987 53708 0
29113 418...

output:

3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
...

result:

ok 100000 numbers

Test #22:

score: 0
Accepted
time: 822ms
memory: 14172kb

input:

100000 100000
17024 36523 84
26573 32514 116
6731 63527 277
63675 63578 182
71445 49677 83
93835 37340 98
12434 61092 239
80203 96847 68
39780 56175 178
74379 71676 309
11723 41464 194
80813 7960 202
46447 85185 108
92345 34067 298
24118 386 276
76948 48980 2
81038 16844 152
18924 48647 162
67518 96...

output:

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

result:

ok 100000 numbers

Test #23:

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

input:

100000 100000
56477 56831 270
98074 56831 256
56831 4716 244
56831 93132 278
56831 55319 278
56831 45061 10
56831 82924 297
56831 89764 133
56831 24375 134
56831 93793 143
99474 56831 60
56831 91587 316
3678 56831 217
57831 56831 63
56831 36997 34
71852 56831 191
56831 17774 146
28274 56831 23
56831...

output:

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

result:

ok 100000 numbers

Test #24:

score: 0
Accepted
time: 176ms
memory: 18480kb

input:

100000 100000
59093 75611 137
581 51203 162
54074 97112 126
10865 36786 69
48055 95244 116
7450 56728 259
92624 69291 173
47563 55140 31
5600 93920 299
78509 28861 31
36582 32778 12
32218 12904 274
22103 41376 264
70187 41753 92
68731 46857 59
19576 17703 87
38244 38734 261
86217 25250 142
51486 750...

output:

317
317
317
317
317
317
317
317
317
317
317
317
317
317
317
317
317
317
317
317
317
317
317
317
317
317
317
317
317
317
317
317
317
176
317
317
317
317
317
317
317
317
317
317
317
317
317
317
317
0
317
317
317
317
317
317
317
317
317
317
317
317
317
317
317
317
317
317
317
317
317
317
317
317
317
31...

result:

ok 100000 numbers

Test #25:

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

input:

100000 100000
29817 84458 99033
53836 73640 55741
85871 77126 61666
9307 90386 93376
27860 95044 41557
44965 31261 54827
43096 31875 8808
80483 5330 46039
43765 53043 74867
20184 92680 35161
97963 1663 63541
44742 37678 74162
39039 85798 62232
26111 88918 91944
72075 65425 80469
81160 17251 3282
661...

output:

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

result:

ok 100000 numbers

Test #26:

score: 0
Accepted
time: 562ms
memory: 13768kb

input:

100000 100000
29382 88834 53974
29382 57274 94233
10731 29382 1925
86336 29382 41723
29382 47685 67161
29382 86187 46850
29382 49401 75461
29382 52775 463
29382 52512 94610
29382 2198 51328
29382 66408 85039
29382 20966 65595
7677 29382 79698
29382 56627 90013
29382 47420 35452
29382 49571 35199
293...

output:

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

result:

ok 100000 numbers

Test #27:

score: 0
Accepted
time: 256ms
memory: 18680kb

input:

100000 100000
11208 90864 41319
69713 36976 82808
5673 82820 88653
90771 86971 16656
44320 31482 69488
90842 27639 69183
97064 18787 81145
95572 84656 69616
62816 99192 43797
28980 71465 38685
98312 71846 71935
3920 14594 18922
55938 56713 95626
92446 97247 25224
63877 56068 72051
600 41372 40806
99...

output:

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

result:

ok 100000 numbers

Test #28:

score: 0
Accepted
time: 275ms
memory: 18064kb

input:

100000 100000
31487 91825 80102
14052 39724 70104
60913 65623 53858
52759 45279 12555
26508 38599 58675
24857 32040 22919
90422 18212 91938
8556 79194 83731
92901 7879 26910
19646 91008 17362
37867 97263 79821
80509 83200 85420
61946 86430 28972
46276 21482 3115
40418 27917 38733
76576 63520 55605
3...

output:

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

result:

ok 100000 numbers

Test #29:

score: 0
Accepted
time: 382ms
memory: 17936kb

input:

100000 100000
46081 56728 87434
41721 57709 39847
47289 57325 82863
71592 56671 56190
50629 26161 72715
68091 23434 13167
33555 83693 9854
93132 92350 93506
95820 62321 13005
29465 8569 52834
90455 66279 28764
6303 23873 85796
12953 57014 91264
34385 1967 6788
22819 55248 94095
65734 55510 66134
273...

output:

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

result:

ok 100000 numbers

Test #30:

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

input:

100000 100000
61993 32628 566
90306 18856 41965
82394 97521 58280
15339 14513 77634
97256 58919 20919
49273 6329 15161
71532 11414 34889
91564 35619 7820
93082 1266 38003
28949 4752 87191
73214 26829 50244
57161 6738 95579
84608 63054 10555
41446 59389 37703
40931 53939 33640
82657 54304 13173
72330...

output:

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

result:

ok 100000 numbers

Test #31:

score: 0
Accepted
time: 499ms
memory: 19208kb

input:

100000 100000
2847 38872 9696
51923 68347 29536
97953 1131 63398
77267 26389 52045
26036 62687 25961
34138 89576 69171
41044 16083 72298
29706 15566 27225
80235 79053 79302
7200 7169 67224
10694 49135 36384
19336 57256 31963
75795 51711 19573
22691 87786 10001
25755 64830 91333
72199 21420 28026
720...

output:

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

result:

ok 100000 numbers

Test #32:

score: 0
Accepted
time: 857ms
memory: 14384kb

input:

100000 100000
78016 31373 6273
25172 69767 98366
41726 7757 38984
29804 84793 190736
23976 87714 166838
30967 38411 113203
14107 95938 167542
20350 55263 65934
49016 29504 64497
13256 95353 28103
43901 42349 56304
78967 65066 34190
44284 75517 111454
80968 6309 184111
34535 38116 21107
52842 47532 1...

output:

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

result:

ok 100000 numbers

Test #33:

score: 0
Accepted
time: 548ms
memory: 13712kb

input:

100000 100000
88476 27520 188900
27520 19020 170095
27520 77957 72455
27520 49777 111220
39894 27520 22334
27520 44256 129828
40306 27520 186208
1225 27520 93176
1354 27520 19131
35498 27520 177992
36854 27520 121671
72668 27520 114524
27520 29292 43517
37075 27520 114515
65296 27520 189661
27520 99...

output:

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

result:

ok 100000 numbers

Test #34:

score: 0
Accepted
time: 728ms
memory: 19828kb

input:

100000 100000
82563 20660 14283
78140 84188 178320
14220 78346 71916
49986 52616 62334
23246 36387 194134
58504 87058 193652
98571 49651 173108
15053 86639 72744
86697 26937 72256
92518 92801 53993
97387 79394 189858
97039 29489 76802
40633 16977 102792
94188 94625 185000
33912 41249 94951
45503 561...

output:

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

result:

ok 100000 numbers

Test #35:

score: 0
Accepted
time: 131ms
memory: 14488kb

input:

100000 100000
55055 96434 651140566
24155 12753 872543761
42896 36913 338685975
18137 68703 877247129
55237 92158 581592710
30939 56157 993862556
24989 68463 626964829
60957 83530 95662669
41230 39429 179967013
90362 56173 407005510
86314 27321 183788875
91965 42003 418234070
25143 7264 191659112
45...

output:

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

result:

ok 100000 numbers

Test #36:

score: 0
Accepted
time: 138ms
memory: 13860kb

input:

100000 100000
95001 77630 285419475
77630 40150 578222826
77630 64980 525062947
77630 74373 593607633
14826 77630 318394029
50545 77630 901130259
77630 78462 265621353
94760 77630 438495820
36893 77630 135254096
77630 55311 68186979
26938 77630 386502465
77630 23028 96948756
41357 77630 343270404
10...

output:

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

result:

ok 100000 numbers

Test #37:

score: 0
Accepted
time: 82ms
memory: 20064kb

input:

100000 100000
23341 13859 337344545
88054 51201 495153335
81099 68466 738762065
58318 98756 682294144
20608 34320 557942759
9122 5233 8671929
34565 90744 863023338
71890 8973 635417123
80495 54125 413642412
31172 39396 440696415
46560 92778 702079619
78443 69926 770589257
65607 75902 934050630
85437...

output:

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

result:

ok 100000 numbers

Test #38:

score: 0
Accepted
time: 206ms
memory: 16384kb

input:

100000 100000
53491 67838 947
26701 16555 542
37592 38375 774
58172 78267 807
21810 79141 162
50784 67878 748
48134 56191 741
99514 65145 687
47534 10787 238
72141 76818 26
82180 79875 220
11598 94694 371
67238 58805 375
31042 78504 944
82928 6370 198
29911 16861 957
26937 52602 624
23678 13644 556
...

output:

0
1001
1001
0
1001
1001
0
1001
1001
1
1001
0
1001
1001
2
0
1001
0
0
0
0
1001
1001
1001
1001
1001
0
1
1001
1001
0
1001
0
1001
0
1001
0
0
1001
1001
1001
1
1001
1001
1001
0
1
1001
1001
1001
1001
1001
1001
0
0
1001
0
0
1001
1001
1001
1001
0
0
1001
0
1001
1001
0
0
0
0
0
0
1001
0
1001
1001
1001
0
1001
100...

result:

ok 100000 numbers

Test #39:

score: 0
Accepted
time: 205ms
memory: 16856kb

input:

100000 100000
81356 62066 465
37105 25297 150
11412 81890 1904
89997 14859 958
79515 55365 152
49789 51167 756
77461 40522 1796
97705 70535 506
79201 30952 475
61839 19311 295
39233 89287 1778
44046 94706 1714
2788 38312 1191
95767 22034 1007
51270 50622 1712
22623 59214 1555
82203 88456 1486
70981 ...

output:

2001
2001
2001
2001
2001
2001
0
0
0
2001
2001
2001
2
0
2001
0
2001
0
0
2001
2001
1
0
2001
2001
0
2001
0
0
2001
2001
0
0
2001
0
2001
0
2001
0
2001
0
0
0
2001
2001
0
0
2001
0
0
2001
2001
2001
0
0
0
2001
2001
0
2001
2001
2001
2001
2001
2001
0
1
2001
2001
0
2001
1
2001
2001
0
0
0
0
0
2001
0
2001
2001
0
...

result:

ok 100000 numbers

Test #40:

score: 0
Accepted
time: 164ms
memory: 16380kb

input:

100000 100000
11448 35167 2462
987 91322 1841
36468 82383 2341
65194 27822 19
64583 63415 2714
22660 85532 2869
57878 25186 2400
41224 27903 2116
81847 84528 2829
97231 357 2086
59127 95901 196
1891 52748 1493
79659 60362 825
55859 21010 563
10953 74061 1937
33108 82279 1815
23697 25200 2986
23791 5...

output:

3001
0
3001
1
3001
0
0
3001
3001
3001
3001
3001
3001
3001
3001
0
3001
3001
0
0
0
0
3001
0
3001
3001
3001
0
3001
0
0
1
0
3001
0
0
3001
0
3001
0
3001
3001
3001
3001
0
3001
3001
0
0
0
3001
1
3001
3001
3001
3001
3001
0
0
0
0
0
3001
3001
3001
3001
0
3001
3001
0
3001
0
3001
0
3001
0
3001
3001
0
0
0
3001
3...

result:

ok 100000 numbers

Test #41:

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

input:

100000 100000
64855 43536 3321
73240 92730 1131
83069 19578 910
7126 84397 765
8431 17196 1648
52140 66857 3775
40777 34278 3474
97947 44071 3113
44710 91199 3322
98578 41609 2198
69268 51170 50
25596 94369 2662
35466 3274 3416
19835 31295 2223
63415 80013 2922
47806 77726 1614
81943 12936 62
36953 ...

output:

0
4001
0
0
0
4001
4001
4001
4001
4001
4001
4001
0
4001
4001
0
4001
0
0
0
0
1
0
0
4001
4001
4001
4001
0
4001
4001
4001
0
4001
0
4001
4001
4001
4001
4001
4001
4001
1
4001
4001
4001
0
0
4001
0
4001
4001
4001
0
0
0
0
0
0
0
4001
4001
4001
4001
0
4001
0
0
4001
4001
0
0
4001
4001
0
0
4001
4001
4001
4001
0
...

result:

ok 100000 numbers

Test #42:

score: 0
Accepted
time: 165ms
memory: 15840kb

input:

100000 100000
26633 56759 1494
79705 56169 1287
62289 71531 2104
96060 69160 1289
20209 89259 4517
87458 62468 3577
14765 47478 4600
64170 86311 810
58354 16761 4318
53487 51462 3222
35058 63627 4346
94318 5404 2826
26540 47500 708
67458 92199 1764
86452 35067 55
82238 77390 2797
32095 35135 4001
17...

output:

0
0
0
0
5001
0
0
5001
5001
0
5001
5001
5001
0
0
5001
0
0
5001
5001
5001
5001
5001
5001
0
0
0
5001
0
0
5001
0
0
0
5001
0
0
5001
5001
1
0
0
5001
5001
0
0
5001
5001
0
0
0
0
0
0
5001
5001
5001
5001
0
5001
5001
0
5001
0
5001
0
0
5001
5001
5001
5001
0
5001
5001
0
0
5001
0
0
0
0
0
5001
5001
5001
0
5001
500...

result:

ok 100000 numbers

Test #43:

score: 0
Accepted
time: 175ms
memory: 15764kb

input:

100000 100000
79517 92246 440
93754 99086 4477
66889 62757 1003
88463 55412 1283
16935 91637 2664
67051 65430 1926
26205 8970 1682
85501 24184 324
57703 96284 2182
17187 31805 141
46667 72460 3323
83066 58584 3194
15261 20399 3707
95640 74 2587
21516 11648 2237
95758 68843 5657
18306 81560 2145
2093...

output:

0
350
350
350
0
0
350
0
350
350
350
350
350
0
350
350
350
0
350
350
0
0
0
350
0
0
350
0
350
350
350
0
0
0
0
0
350
350
350
0
350
0
0
350
350
0
0
0
350
0
0
350
350
0
0
0
350
0
0
350
350
350
350
350
350
6001
0
0
0
0
0
350
0
350
0
0
350
0
350
350
0
0
0
0
0
0
0
0
350
350
350
0
350
350
350
0
0
350
350
350...

result:

ok 100000 numbers

Test #44:

score: 0
Accepted
time: 260ms
memory: 16576kb

input:

100000 100000
99746 65022 1317
87301 62560 4189
48175 33150 364
32603 71980 4524
61076 62902 4233
3392 40302 4525
42188 31855 1581
53477 79600 2444
61768 72132 5762
5238 86515 3353
8205 87866 4242
3340 3499 3222
26927 56880 2826
38227 30935 2529
85928 85266 164
41764 11071 3597
74583 23230 5377
3543...

output:

6150
6150
6150
6150
0
0
6150
0
6150
6150
0
6150
0
0
0
6150
6150
0
6150
6150
0
6150
6150
6150
0
0
6150
6150
6150
6150
6150
6150
0
6150
0
6150
0
0
6150
6150
0
0
0
6150
0
0
0
6150
6150
0
6150
6150
0
6150
0
0
6150
0
0
6150
6150
0
6150
6150
6150
6150
6150
6150
0
6150
0
6150
0
6150
0
0
6150
6150
6150
6150...

result:

ok 100000 numbers

Test #45:

score: 0
Accepted
time: 177ms
memory: 16312kb

input:

100000 100000
64794 66896 7814
48103 59505 519
19497 25996 4441
87721 87723 6925
47309 26577 6493
74976 36191 2020
95738 25511 5289
25866 47758 3063
95060 99742 7436
78790 56794 4057
48555 22063 639
38728 96724 6936
99597 76534 6517
27246 37392 5349
43168 47370 4021
11756 63342 6230
81901 50205 823
...

output:

123
0
0
0
0
123
123
0
0
1
0
0
0
123
0
0
123
123
123
123
123
123
0
0
0
0
0
0
123
123
123
0
123
123
123
0
123
0
123
123
0
123
0
1
0
0
123
0
0
123
123
123
0
0
0
123
0
0
123
123
0
0
0
123
123
123
123
0
0
0
123
123
0
123
123
0
0
0
123
123
0
123
123
123
123
0
0
123
123
123
0
0
0
0
0
123
0
123
0
123
123
12...

result:

ok 100000 numbers

Test #46:

score: 0
Accepted
time: 219ms
memory: 17044kb

input:

100000 100000
32984 36225 4672
22170 17431 4977
58788 93093 320
30654 62791 1508
11713 86532 2811
2844 89067 4107
66220 84009 6582
1269 75435 2328
27009 6856 3513
68054 54442 1068
35650 22325 5282
77891 46373 622
22373 77858 6758
20802 55069 846
23367 28507 5976
97983 5750 2979
8929 44299 1771
44699...

output:

0
183
0
0
183
183
183
0
183
0
0
183
183
183
0
183
183
183
183
183
183
0
0
183
0
0
0
183
183
183
183
0
183
0
183
183
183
0
0
183
0
183
183
183
0
183
0
0
183
0
0
0
0
183
0
183
183
183
0
183
0
0
183
183
0
183
183
0
183
183
183
0
0
183
0
0
183
0
183
0
0
0
183
0
252
183
0
0
0
0
183
0
183
183
0
183
0
183
...

result:

ok 100000 numbers

Test #47:

score: 0
Accepted
time: 281ms
memory: 17148kb

input:

100000 100000
51978 95838 4377
58935 7834 1751
46366 56116 7489
86998 32339 9200
33586 98823 998
2341 75803 4555
96762 87738 7522
63870 97009 9653
52508 75535 4585
61188 68697 9831
8047 1756 7866
85105 20336 2446
58260 81419 8730
10968 15191 3673
17053 27361 5868
36528 22487 4927
32932 60312 9080
99...

output:

249
0
249
0
249
249
249
249
0
0
0
0
0
249
249
0
0
0
0
0
0
0
249
249
249
249
1
0
249
0
249
0
249
249
249
249
0
249
0
249
0
249
249
0
0
249
249
0
249
0
249
249
0
249
0
0
249
0
249
249
0
249
249
249
249
249
0
0
0
249
0
249
0
249
249
249
249
249
249
249
0
249
249
249
0
0
249
249
0
0
249
0
0
0
0
249
249
...

result:

ok 100000 numbers

Test #48:

score: 0
Accepted
time: 143ms
memory: 15920kb

input:

100000 100000
87310 72006 50059
19417 87052 9406
74761 96445 50060
17925 6984 47111
24744 30671 50047
2723 62017 12070
19635 44290 50054
81819 76438 655
79966 58785 40862
47780 73309 23510
10840 16861 50058
59683 8606 50045
56798 311 49427
97893 3193 19609
36263 18766 6609
62465 70849 50052
55919 97...

output:

0
50061
50061
50061
50061
50061
50061
50061
0
0
50061
50061
50061
0
0
50061
50061
0
50061
0
50061
50061
50061
0
50061
0
0
50061
0
0
50061
50061
50061
50061
50061
0
0
0
50061
50061
0
50061
0
50061
0
0
50061
0
50061
0
50061
0
0
0
50061
0
50061
50061
50061
0
0
0
50061
0
50061
50061
50061
50061
0
50061
...

result:

ok 100000 numbers

Test #49:

score: 0
Accepted
time: 157ms
memory: 15416kb

input:

100000 100000
37140 71772 50049
27458 56240 50068
14859 80443 13487
11837 79376 50067
43606 23330 14628
46355 22869 50062
95540 6237 30014
96554 98334 50060
33006 75549 50060
62236 80264 50064
5786 79770 4781
82749 3663 50060
5092 65051 50054
42553 92068 50053
29571 64837 6735
57406 58430 50059
5760...

output:

0
0
50071
50071
0
50071
0
0
0
0
0
0
0
0
50071
0
50071
50071
50071
50071
50071
50071
0
50071
0
50071
0
50071
0
0
50071
0
50071
0
0
0
0
50071
0
0
50071
0
50071
0
50071
0
50071
0
0
0
50071
50071
50071
50071
0
50071
0
0
0
50071
0
0
50071
0
50071
0
0
50071
0
0
0
50071
50071
0
0
0
0
0
0
50071
50071
0
0
0
...

result:

ok 100000 numbers

Test #50:

score: 0
Accepted
time: 205ms
memory: 16908kb

input:

100000 100000
54543 23861 50064
40848 95799 50060
35618 68888 50053
44137 76410 13201
85405 33836 50060
40608 82830 50075
63152 89055 7522
22116 2512 50065
51870 86354 50056
63804 83065 50072
64671 52024 33943
13076 48082 50048
31809 65392 50050
99536 44763 50051
87285 31257 2940
84873 54298 50062
1...

output:

50081
50081
50081
0
50081
50067
50081
0
0
0
0
50081
0
0
0
0
0
50081
0
0
50081
0
50081
50081
0
0
0
50081
0
50081
0
50081
0
0
0
50081
50081
50081
0
50081
50081
50081
50081
0
50081
0
50081
0
0
0
50081
50081
0
0
0
50081
0
0
0
50081
50081
0
0
50081
50081
0
0
0
50081
0
50081
50081
0
50081
0
0
0
50081
5008...

result:

ok 100000 numbers

Test #51:

score: 0
Accepted
time: 210ms
memory: 17100kb

input:

100000 100000
12953 56814 50073
23930 77258 50056
98492 5316 26920
56517 78161 50086
9212 37041 13842
78607 18447 42578
11795 62311 20457
23699 66894 50080
24267 83954 50086
82307 65537 50047
70598 79033 50084
26704 21766 50078
65251 56805 50079
6192 66540 43428
55537 15813 50082
20885 93414 43912
5...

output:

50091
50091
0
0
0
50091
50087
50091
50091
50091
0
0
50063
50091
0
50049
50091
50091
50091
0
0
50091
0
0
50091
50091
50091
50091
50091
0
0
0
0
0
0
50091
0
0
0
0
0
0
0
50091
50091
0
50051
50077
50091
0
50065
50091
0
50079
50091
50091
50091
0
50060
50091
0
50060
50056
0
50091
0
0
0
0
0
50091
0
0
0
0
0
...

result:

ok 100000 numbers

Test #52:

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

input:

100000 100000
88369 33091 47571
24846 8410 20246
2496 19370 23833
58738 8500 2430
10664 2919 50094
10724 83561 37642
41498 36044 50087
93693 40697 48110
30340 31740 12427
34095 29256 22735
46155 34501 26891
15407 99506 48005
74762 90025 50097
23947 45009 50083
89997 35483 50095
59264 54978 38915
112...

output:

0
0
50077
0
0
0
0
50054
0
50067
50101
50089
0
50089
0
50076
50101
0
50101
50073
50069
0
50101
50101
0
50101
50053
0
50065
50055
0
50098
0
0
50101
50101
0
0
50101
0
50066
0
0
50101
0
50056
0
0
0
0
0
50101
50094
0
0
0
50063
50059
50101
50101
0
0
50056
0
0
50101
0
0
50098
50070
0
50101
0
0
50049
0
0
50...

result:

ok 100000 numbers

Test #53:

score: 0
Accepted
time: 250ms
memory: 15828kb

input:

100000 100000
93945 41075 50090
14349 12559 50084
79790 44771 50051
62324 33722 1948
54826 9675 42961
64122 93392 50080
47066 64714 50092
55550 89300 50082
22536 27671 33943
45915 49018 50094
2297 59128 14182
64854 58493 50076
26511 20121 50091
98908 54045 15539
66245 31805 36809
59220 88670 50139
6...

output:

50073
50052
0
50050
50057
50052
0
50052
50066
0
50060
0
50052
0
0
50055
0
50050
50053
0
0
0
0
0
50052
0
50071
0
50056
50054
0
50054
0
50066
0
0
50055
50049
50058
0
50078
50053
50056
50049
0
0
0
0
50050
50051
50051
0
0
50062
0
0
50050
50064
50064
50065
50049
50049
50049
0
0
50053
0
50051
0
0
50050
0
...

result:

ok 100000 numbers

Test #54:

score: 0
Accepted
time: 372ms
memory: 16892kb

input:

100000 100000
62131 21867 14870
87247 39351 26433
38118 97847 24471
49128 85345 46383
15071 40753 25170
57103 99663 50106
37756 78093 50047
1755 15682 50192
1464 73421 15137
20944 73333 50109
69161 51190 50095
73714 12119 41687
16847 19611 25541
18358 20480 50071
85572 28106 4111
9380 6618 50116
338...

output:

50066
0
0
50052
50057
50051
0
0
50053
50050
50053
50055
0
50056
50050
50051
0
50058
50051
0
50056
50050
0
0
50058
0
50051
0
50059
50049
50055
0
0
50054
50053
50051
0
0
0
50049
50049
0
50049
0
0
50052
50051
0
50049
0
0
0
0
50049
50050
0
50052
0
0
50051
50053
0
0
0
0
50056
50051
0
50052
50054
50049
0
...

result:

ok 100000 numbers

Test #55:

score: 0
Accepted
time: 341ms
memory: 16564kb

input:

100000 100000
61046 19540 50213
66919 54158 50072
10031 38724 25422
88568 9460 35277
17293 57701 15288
48320 28700 50164
28910 82828 2695
67662 83344 50199
57476 70622 4289
88522 52042 50121
55498 31733 30581
60535 14886 50136
69935 33053 45101
77131 54695 8403
90409 23607 50197
88447 37621 32875
20...

output:

50049
50049
0
50050
50051
50058
50049
0
50049
0
50049
50056
50049
0
0
0
50050
0
50050
0
50050
50050
50051
0
50050
0
50051
50050
0
50050
0
0
50051
50051
50053
0
0
50052
0
50049
50054
50055
0
50052
50049
50050
50049
50054
50049
50052
50052
0
50049
0
50055
0
50051
0
0
50052
0
50051
0
0
0
0
50051
0
0
50...

result:

ok 100000 numbers

Test #56:

score: 0
Accepted
time: 365ms
memory: 16792kb

input:

100000 100000
3103 33729 31661
34139 20491 50095
79140 5403 28738
40429 69681 50178
50627 98770 50179
91902 33208 50118
284 4688 19780
70079 40841 50197
14919 35840 50065
95940 82384 50258
7318 53055 46550
2520 49350 50130
89943 75108 50085
98976 35536 50103
21654 8021 16542
53244 44045 50250
47835 ...

output:

0
0
50049
0
0
50052
0
0
50049
0
0
0
50052
50053
0
0
0
50049
50049
50050
0
0
50060
50053
0
0
50050
50050
0
0
50050
0
0
50050
50049
50051
50053
0
0
0
0
50049
50052
50051
0
50054
50049
0
50051
50049
0
50052
50049
50050
50049
0
50049
0
0
50049
0
0
0
50051
0
0
0
50051
50050
50050
50049
50050
50049
50051
...

result:

ok 100000 numbers

Test #57:

score: 0
Accepted
time: 170ms
memory: 15832kb

input:

100000 100000
87310 72006 50057
19417 87052 12886
74761 96445 2
17925 6984 29157
24744 30671 50056
2723 62017 40510
19635 44290 4
81819 76438 26529
79966 58785 22337
47780 73309 42156
10840 16861 50060
59683 8606 50048
56798 311 32636
97893 3193 10963
36263 18766 5955
62465 70849 7
55919 97142 43587...

output:

50061
50061
16
50061
50049
16
50061
0
50049
50061
16
50049
50049
50049
50061
16
16
16
50061
50061
16
16
50049
16
16
16
16
50061
50061
50049
0
50061
50061
50061
50061
16
16
50061
50061
50061
16
16
0
50061
50061
0
50061
50061
16
50049
50061
50061
50049
16
16
50061
50049
0
0
16
16
0
50061
16
16
50049
1...

result:

ok 100000 numbers

Test #58:

score: 0
Accepted
time: 183ms
memory: 15544kb

input:

100000 100000
37140 71772 50047
27458 56240 50062
14859 80443 10707
11837 79376 31
43606 23330 44714
46355 22869 50069
95540 6237 27906
96554 98334 40
33006 75549 29
62236 80264 50069
5786 79770 43581
82749 3663 50055
5092 65051 17
42553 92068 3
29571 64837 31474
57406 58430 50070
5760 96887 50049
3...

output:

50049
50071
0
4
50071
18
50071
0
23
24
50049
19
50071
50049
50071
50049
50050
1
50049
48
18
2
50054
2
0
0
50071
51
50071
50049
50071
50049
50049
50071
50049
50071
0
50071
50071
50071
50068
50071
0
50071
50071
50071
12
33
0
4
0
0
10
50071
50049
50071
2
50071
15
50071
50071
19
51
0
50071
6
0
50071
500...

result:

ok 100000 numbers

Test #59:

score: 0
Accepted
time: 225ms
memory: 16852kb

input:

100000 100000
54543 23861 50058
40848 95799 9
35618 68888 7
44137 76410 2322
85405 33836 10
40608 82830 50064
63152 89055 8544
22116 2512 50060
51870 86354 50070
63804 83065 50055
64671 52024 40911
13076 48082 50074
31809 65392 50056
99536 44763 11
87285 31257 30255
84873 54298 13
16398 33148 6805
2...

output:

16
50081
0
50081
50057
50049
50081
50049
16
16
16
50078
16
50066
50081
50049
16
50081
16
50081
16
0
16
16
50049
50059
0
0
16
16
16
16
16
50061
0
50081
16
16
50081
0
50081
16
1
50049
50081
0
50081
50049
50081
50071
16
50054
16
50056
50068
0
16
16
50061
16
50049
50081
50081
16
16
0
16
16
16
50081
16
1...

result:

ok 100000 numbers

Test #60:

score: 0
Accepted
time: 250ms
memory: 16836kb

input:

100000 100000
12953 56814 50080
23930 77258 50054
98492 5316 17071
56517 78161 8
9212 37041 21542
78607 18447 38429
11795 62311 40629
23699 66894 50047
24267 83954 18
82307 65537 39
70598 79033 14
26704 21766 18
65251 56805 50059
6192 66540 31406
55537 15813 50052
20885 93414 47178
50291 47808 15016...

output:

50053
4
50051
50068
50049
50049
50056
50063
0
0
50050
50078
3
50091
0
0
13
50068
51
0
50055
51
6
50049
50049
50053
50049
0
51
50049
4
50049
50050
50051
36
50059
50059
50049
50049
1
10
50070
50052
18
50049
0
4
50051
50052
2
50054
2
51
50068
50050
50050
0
0
4
50063
50050
1
1
50091
50049
51
50049
50053...

result:

ok 100000 numbers

Test #61:

score: 0
Accepted
time: 282ms
memory: 16668kb

input:

100000 100000
88369 33091 11712
24846 8410 5639
2496 19370 30562
58738 8500 39279
10664 2919 50081
10724 83561 4240
41498 36044 15
93693 40697 34625
30340 31740 36284
34095 29256 27815
46155 34501 17397
15407 99506 32585
74762 90025 50065
23947 45009 50067
89997 35483 9
59264 54978 4085
1128 91483 1...

output:

50066
50049
0
0
50051
16
50101
16
16
50060
50049
50049
16
16
16
50050
16
50058
0
16
50049
16
0
16
50050
0
50051
0
50049
50056
0
0
50049
16
50080
16
0
50053
16
50049
16
16
16
16
16
16
16
50067
50049
0
50049
50049
16
50077
50083
50058
50053
50049
50056
16
50085
50054
50050
16
50066
50050
16
50049
0
50...

result:

ok 100000 numbers

Test #62:

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

input:

100000 100000
93945 41075 50101
14349 12559 30
79790 44771 50120
62324 33722 26235
54826 9675 40299
64122 93392 3
47066 64714 22
55550 89300 50058
22536 27671 297
45915 49018 46
2297 59128 4431
64854 58493 16
26511 20121 28
98908 54045 30959
66245 31805 3217
59220 88670 10
63642 62896 12932
93051 51...

output:

0
0
0
2
0
50049
50055
50049
50049
50050
0
0
50049
0
50054
50049
0
0
50049
0
50050
24
50049
0
26
51
4
0
0
50050
50054
8
39
50049
0
17
23
50055
0
51
50049
27
26
50058
29
50051
50049
50054
50049
2
50051
50055
50052
50051
13
1
0
50049
50049
1
51
50050
50049
0
50054
50054
0
0
1
50052
11
0
50049
5
50051
5...

result:

ok 100000 numbers

Test #63:

score: 0
Accepted
time: 288ms
memory: 16848kb

input:

100000 100000
62131 21867 19523
87247 39351 39062
38118 97847 33464
49128 85345 25597
15071 40753 11673
57103 99663 50131
37756 78093 50059
1755 15682 6
1464 73421 26645
20944 73333 11
69161 51190 50125
73714 12119 33497
16847 19611 35687
18358 20480 1
85572 28106 28677
9380 6618 0
33891 37299 0
470...

output:

50049
50049
0
16
16
16
16
0
16
50050
0
16
0
50049
16
50050
16
50049
16
50049
16
0
16
50049
50049
50049
16
50070
50049
50053
16
50049
50049
50049
16
0
50049
50050
50049
50049
16
16
16
16
16
50049
50053
16
50050
50049
50051
16
0
50049
16
16
16
50050
50049
50049
50049
0
16
16
16
50049
16
16
16
50049
50...

result:

ok 100000 numbers

Test #64:

score: 0
Accepted
time: 249ms
memory: 16428kb

input:

100000 100000
61046 19540 1
66919 54158 34
10031 38724 620
88568 9460 41758
17293 57701 13462
48320 28700 14
28910 82828 30688
67662 83344 25
57476 70622 40872
88522 52042 31
55498 31733 41786
60535 14886 29
69935 33053 2711
77131 54695 47246
90409 23607 50067
88447 37621 5857
20461 50560 35132
4156...

output:

0
26
0
0
50052
50049
51
50049
2
50049
5
50052
50051
50049
50049
0
0
50049
50050
51
0
50053
0
50049
16
50049
50049
50050
50050
7
50049
50049
50053
50050
50050
50049
0
16
0
2
50049
50055
50050
50049
51
50050
18
0
1
22
50050
8
50
0
50050
50049
7
50049
39
50049
50052
50049
35
2
51
50049
50049
23
50053
1...

result:

ok 100000 numbers

Test #65:

score: 0
Accepted
time: 260ms
memory: 16888kb

input:

100000 100000
3103 33729 2919
34139 20491 50170
79140 5403 12045
40429 69681 50186
50627 98770 50108
91902 33208 50101
284 4688 15591
70079 40841 50265
14919 35840 7
95940 82384 10
7318 53055 37752
2520 49350 50199
89943 75108 50288
98976 35536 50121
21654 8021 41643
53244 44045 50080
47835 74089 50...

output:

16
50049
0
16
50049
50049
16
50049
16
0
16
50049
50050
0
16
0
50049
50049
50049
50049
50050
16
50049
0
50049
50050
0
50049
0
16
16
16
16
50049
16
50049
50049
16
16
16
2
50049
50049
16
16
50050
16
50049
50049
50049
50049
16
2
50049
16
16
16
50052
16
50049
50049
16
0
50049
50050
16
50049
50049
50049
5...

result:

ok 100000 numbers

Test #66:

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

input:

100000 100000
22511 51327 20025
82065 43465 50611
15846 11662 30885
63679 22702 23101
83340 63545 54468
45545 83209 58102
83894 65158 68630
13570 78428 50769
22382 45284 85543
97141 76873 8664
85316 27246 34921
46398 20555 39942
88047 75392 86245
32059 84480 97187
32244 49903 75856
45818 14845 24357...

output:

48506
14906
10633
28019
29076
27770
33406
18762
6381
72654
46589
32721
34054
58764
24617
25765
13289
2880
4551
6209
73032
64634
23527
5453
14173
26188
22728
29606
97021
30982
43328
31524
78202
41976
11254
2535
2831
61326
28550
17708
77777
30762
4239
39645
34149
66455
27380
81786
10685
15719
5821
159...

result:

ok 100000 numbers

Test #67:

score: 0
Accepted
time: 127ms
memory: 17944kb

input:

99999 100000
70700 56415 5212
33906 28791 45436
61304 67739 42541
55279 83005 93246
89708 59275 15463
22384 83825 6445
21046 28347 29660
14177 14914 82173
24966 35874 93180
59038 8403 36799
15293 60988 64940
40188 81028 93814
3806 65340 16076
26240 79945 53654
86549 49683 37233
56260 11038 45117
556...

output:

30556
12929
61791
22780
1872
11805
26889
33623
28513
13640
18292
54618
41656
81848
24219
41393
25322
41327
61025
13985
9111
9000
68775
21651
40449
42399
76569
83646
24562
13300
53209
52006
52934
42567
13654
21485
15590
11479
80682
40801
13456
72445
5933
61479
81523
19076
33689
8171
45960
16543
13184...

result:

ok 100000 numbers

Test #68:

score: 0
Accepted
time: 126ms
memory: 18940kb

input:

99998 100000
55075 59313 92689
11771 44422 50049
84963 68794 64622
58586 24383 6721
10569 6625 31470
67748 7293 93228
20485 83868 11855
29428 3853 98110
76056 56933 29433
33305 90102 83942
83928 38524 82061
95271 73287 42452
64690 14692 42304
87271 81425 89345
29176 67488 99129
94186 20764 5465
7064...

output:

49968
21534
33453
49105
67659
9801
27620
19599
16030
64291
22171
20415
59581
14769
22384
1043
53636
15531
22407
3077
39729
70037
672
12931
8618
21264
31973
3114
32028
29132
33371
31456
8301
73800
23292
3798
2035
15338
2668
22292
60205
60442
46301
3343
61846
5973
26929
61947
38375
17432
22191
29132
3...

result:

ok 100000 numbers

Test #69:

score: 0
Accepted
time: 152ms
memory: 18156kb

input:

100000 77028
24567 26815 41414
31883 82545 23341
73446 6486 26870
14220 18811 92303
82899 38406 37742
84458 27524 95455
8209 29066 54623
31510 7693 92282
48144 49640 64617
302 26112 64037
12676 44105 26766
46140 90734 58950
30843 66818 85777
23571 29027 78743
12578 20575 66847
48773 37160 73483
7575...

output:

21383
0
0
0
0
0
0
9653
50963
61163
68888
69323
4118
11693
0
0
31073
0
29543
6593
84113
94898
0
0
0
3533
0
57158
29033
74498
55043
0
0
0
0
15773
6083
0
0
0
0
0
3608
56063
63203
0
50963
0
36758
0
0
0
29033
0
0
0
0
29108
24518
0
3023
12713
58688
0
2588
10163
52568
0
53588
0
0
0
0
9143
0
0
0
0
0
0
0
372...

result:

ok 77028 numbers

Test #70:

score: 0
Accepted
time: 134ms
memory: 17456kb

input:

100000 55611
83663 59459 64534
16313 44205 59790
43817 98703 97167
59751 60272 955
8542 8477 61580
36525 28506 57127
98865 69269 7390
88080 49730 9072
78940 51131 19538
80063 54053 17563
86124 66348 69331
74473 83195 52804
87474 90259 41100
85192 1536 60408
36417 30360 56641
15304 1191 44425
54709 9...

output:

0
0
23798
0
69803
0
0
0
41603
24398
26003
42203
60398
17798
0
0
0
0
0
60203
0
0
0
0
15998
0
6203
0
0
0
2603
0
33998
77603
0
41198
21998
57803
64403
0
42398
20603
0
33203
0
0
79598
0
32798
803
0
35798
0
0
61403
0
12803
0
0
69998
0
0
0
398
0
44198
37403
39998
0
0
52598
0
0
0
0
62003
45398
12398
0
0
0
...

result:

ok 55611 numbers

Test #71:

score: 0
Accepted
time: 181ms
memory: 17224kb

input:

100000 40755
26904 13295 73220
8377 32373 11881
21219 97874 93574
66399 3431 51009
26649 15384 14114
55406 77848 90873
37601 47952 3425
59060 99730 22170
89174 72019 94734
57997 97893 94985
77709 57580 75397
71023 32802 1736
67381 22597 64753
80830 16333 71700
17528 27748 54434
42293 44225 53612
421...

output:

0
0
0
0
51698
30903
0
0
95098
0
64998
0
0
0
0
0
0
0
0
54498
21103
5003
0
21598
0
47003
0
37698
0
9698
19003
0
0
0
29503
0
3398
0
0
34403
0
0
35103
0
46303
0
0
7103
0
29503
0
30698
15998
0
62898
0
64998
0
0
19003
0
0
19498
14803
32098
49803
43998
35103
36998
20198
48898
0
48898
28103
0
0
33498
0
7990...

result:

ok 40755 numbers

Test #72:

score: 0
Accepted
time: 193ms
memory: 18876kb

input:

100000 31125
50768 54050 35239
47026 1698 23646
88033 90962 53770
202 59425 9724
62611 41722 10048
37276 88053 74933
67081 3563 10700
47427 82643 36655
9455 84778 50597
33929 19516 21025
7398 32624 20046
9604 91500 88692
96690 66548 84378
81308 28262 65044
24492 56129 81387
34177 84047 87623
9886 90...

output:

3203
0
0
0
48798
20003
1603
35198
16798
0
49603
26398
0
30398
56003
59203
48003
0
71198
0
0
0
5598
14403
0
0
0
0
31998
803
43203
55203
0
64798
0
44003
0
3203
0
31198
12003
61603
24803
0
0
15203
0
0
0
0
3203
39198
28798
62403
798
0
35198
0
27198
0
0
23198
0
2403
11203
0
0
0
0
20798
0
0
803
82403
2240...

result:

ok 31125 numbers

Test #73:

score: 0
Accepted
time: 164ms
memory: 18156kb

input:

100000 24753
86178 88642 63109
47583 92237 43784
14715 72120 243
16562 57823 72225
26547 34821 87691
5835 83284 52474
2922 54958 94136
72226 66100 63567
24064 11227 99846
86071 91551 63834
69488 25065 55140
38594 28674 36651
76047 19718 43076
50031 99823 90512
71936 68187 75745
59946 36011 13584
847...

output:

13403
0
0
0
60398
0
31598
2798
0
38603
1898
0
59303
0
17903
0
21698
4598
44198
17198
0
0
36998
0
1898
17003
0
0
32498
29798
54998
25103
23303
0
0
0
0
0
0
0
0
30503
19898
0
0
17003
45998
8903
0
0
72803
803
0
0
41303
0
0
0
0
64898
67403
8003
3503
0
47603
79298
0
0
14498
45803
36998
0
0
0
53903
3503
0
...

result:

ok 24753 numbers

Test #74:

score: 0
Accepted
time: 109ms
memory: 16708kb

input:

100000 19900
22879 5817 21809
10712 77817 61127
2231 46927 71418
1916 38562 3165
56869 36743 81136
83184 84220 76199
99840 40757 27688
44120 73605 20619
37275 44527 52045
15894 26405 71792
63647 52488 87857
29194 93004 93806
48210 8321 88825
57319 28849 65662
50304 79988 21832
42976 124 76353
25368 ...

output:

22003
18998
0
0
61003
26998
73998
0
0
68003
0
18003
0
86998
44003
17998
81998
64003
23003
49003
0
21003
0
46998
0
3998
0
22003
7998
0
51003
0
0
0
0
0
72003
5998
6003
0
0
28998
0
67998
50003
31003
0
0
2003
0
0
70998
8998
0
0
0
42998
14998
94998
45003
58998
998
998
53998
10003
27998
24003
9998
0
57003...

result:

ok 19900 numbers

Test #75:

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

input:

100000 100000
91710 97109 19917
31781 7092 49832
86115 41151 16549
5993 76698 3633
89303 8817 56300
79032 54979 91485
75800 5675 25875
17304 19533 36629
60939 33480 29895
688 50721 62047
63322 26370 42830
4343 24702 90596
9450 62176 49608
13111 30534 78758
84361 67917 33114
11949 68318 78278
68859 7...

output:

99651
99564
99438
99532
99349
99718
99730
99482
99633
99566
99685
99527
99376
99191
99271
99669
99330
99319
99172
99412
99361
99590
99216
99289
99580
99728
99583
99459
99649
99390
99843
99581
99608
99770
99411
99626
99248
99527
99783
99676
99406
99825
99686
99781
99519
99766
99767
99866
99732
99162
...

result:

ok 100000 numbers

Test #76:

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

input:

99999 100000
37763 26021 4917
48141 38269 48952
68904 29941 77209
27772 56659 601
69714 48931 99479
97690 71341 17251
25292 71801 39188
96587 92592 34295
10392 96893 93933
67652 31800 2780
11774 58390 54988
7188 36631 28574
77948 82332 10358
15531 40051 85497
17607 74544 69027
29731 72824 56515
1096...

output:

99848
99428
99518
99268
99623
99243
99663
99446
99607
99425
99724
99275
99434
99854
99559
99131
99613
99545
99849
99837
99713
99502
99372
99341
99822
99609
99577
99523
99541
99455
99486
99476
99573
99610
99239
99740
99282
99617
99663
99273
99351
99405
99412
99611
99644
99443
99166
99740
99364
99962
...

result:

ok 100000 numbers

Test #77:

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

input:

99998 100000
49392 15040 82107
12233 49952 40429
85500 67446 39234
36816 36125 13828
48900 96108 5140
44669 33812 82082
78321 80028 1933
69933 35242 35907
15973 37043 3740
89242 16117 7646
87652 62940 83571
95445 7186 47622
45329 77458 37190
32983 21280 60321
31701 23029 46149
77781 15304 66985
3642...

output:

99544
99148
99709
99331
99808
99595
99603
99678
99772
99694
99511
99641
99597
99338
99761
99427
99696
99181
99334
99687
99856
99358
99530
99762
99641
99473
99718
99369
99638
99297
99613
99315
99729
99439
99883
99364
99643
99827
99250
99791
99757
99598
99595
99316
99669
99417
99477
99730
99882
99585
...

result:

ok 100000 numbers

Extra Test:

score: 0
Extra Test Passed