QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#431113#6452. Ski ResortzhouhuanyiAC ✓142ms50080kbC++144.9kb2024-06-04 23:21:082024-06-04 23:21:09

Judging History

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

  • [2024-06-04 23:21:09]
  • 评测
  • 测评结果:AC
  • 用时:142ms
  • 内存:50080kb
  • [2024-06-04 23:21:08]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
#define M 4
#define N 100000
#define K 200
using namespace std;
int read()
{
	char c=0;
	int sum=0;
	while (c<'0'||c>'9') c=getchar();
	while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
	return sum;
}
struct reads
{
	int num,data;
};
int n,m,qs,cater,lg[N+1],A[N+1],B[N+1],fas[N+1],L[N+1],R[N+1],sfa[N+1],fa[N+1][21],a[N+1],tong[N+1],length,depth[N+1],dque[N+1],top,dfn[N+1],ps[N+1],sL[K+1],sR[K+1],sz[N+1],leng,in[N+1];
__int128 dp[M+1][N+1];
bool used[N+1],vis[N+1],vst[N+1],EZ[K+1][K+1],usedt[K+1][K+1];
vector<reads>v[N+1];
vector<int>E[N+1];
vector<int>ES[N+1];
vector<int>ET[N+1];
void add(int x,int y)
{
	E[x].push_back(y),in[y]++;
	return;
}
void dfs(int x)
{
	dfn[x]=++leng,sz[x]=1;
	for (int i=0;i<ES[x].size();++i)
		if (!dfn[ES[x][i]])
			dfs(ES[x][i]),sz[x]+=sz[ES[x][i]];
	return;
}
bool LENG(int x,int y)
{
	return dfn[x]<=dfn[y]&&dfn[y]<=dfn[x]+sz[x]-1;
}
void dfs4(int x)
{
	used[x]=1;
	for (int i=0;i<E[x].size();++i)
		if (!used[E[x][i]])
			fas[E[x][i]]=x,dfs4(E[x][i]);
	return;
}
void dfs5(int x)
{
	int scnt=0;
	used[x]=1,vst[x]=vis[x];
	for (int i=0;i<E[x].size();++i)
		if (!used[E[x][i]])
			dfs5(E[x][i]),vst[x]|=vst[E[x][i]],scnt+=vst[E[x][i]];
	if (scnt>=2) vis[x]=1;
	if (vis[x]) A[x]=B[x]=++cater;
	return;
}
void dfs6(int x)
{
	used[x]=1;
	for (int i=0;i<E[x].size();++i)
		if (!used[E[x][i]])
		{
			if (!A[E[x][i]]) A[E[x][i]]|=A[x];
			dfs6(E[x][i]);
			if (!B[x]) B[x]|=B[E[x][i]];
		}
	return;
}
void dfs7(int x,int y)
{
	usedt[x][y]=1;
	for (int i=1;i<=cater;++i)
		if (EZ[y][i]&&!usedt[x][i])
			dfs7(x,i);
	return;
}
int lca(int x,int y)
{
	if (depth[x]<depth[y]) swap(x,y);
	for (int i=lg[n];i>=0;--i)
		if (depth[fa[x][i]]>=depth[y])
			x=fa[x][i];
	if (x==y) return x;
	for (int i=lg[n];i>=0;--i)
		if (fa[x][i]!=fa[y][i])
			x=fa[x][i],y=fa[y][i];
	return fa[x][0];
}
void topo_sort()
{
	int top;
	queue<int>q;
	q.push(1),depth[1]=1;
	while (!q.empty())
	{
		top=q.front(),q.pop(),tong[++length]=top;
		if (top!=1)
		{
			fa[top][0]=ps[top],depth[top]=depth[ps[top]]+1;
			for (int i=1;i<=lg[n];++i) fa[top][i]=fa[fa[top][i-1]][i-1];
		}
		for (int i=0;i<E[top].size();++i)
		{
			ps[E[top][i]]=ps[E[top][i]]?lca(ps[E[top][i]],top):top,in[E[top][i]]--;
			if (!in[E[top][i]]) q.push(E[top][i]);
		}
	}
	for (int i=1;i<=n;++i)
		if (ps[i])
			ES[ps[i]].push_back(i);
	return;
}
bool check(int x,int tl,int tr)
{
	if (!B[x]) return 1;
	return tl<=sL[B[x]]&&sR[B[x]]<=tr;
}
void dfs2(int x)
{
	int d=x;
	for (int i=0;i<ET[x].size();++i) sfa[ET[x][i]]=x,dfs2(ET[x][i]),L[x]=min(L[x],L[ET[x][i]]),R[x]=max(R[x],R[ET[x][i]]);
	if (check(d,L[x],R[x]))
	{
		for (int i=lg[n];i>=0;--i)
			if (depth[fa[d][i]]>depth[sfa[x]]&&check(fa[d][i],L[x],R[x]))
				d=fa[d][i];
		v[R[x]].push_back((reads){L[x],depth[x]-depth[d]+1});
	}
	return;
}
void dfs3(int x)
{
	for (int i=0;i<ET[x].size();++i) dfs3(ET[x][i]);
	L[x]=n+1,R[x]=0,ET[x].clear();
	return;
}
void write(__int128 x)
{
	if (x<=9)
	{
		printf("%d",(int)(x));
		return;
	}
	write(x/10),printf("%d",(int)(x%10));
	return;
}
bool cmp(int x,int y)
{
	return dfn[x]<dfn[y];
}
int main()
{
	int k,p,x,y,d,ds;
	for (int i=2;i<=N;++i) lg[i]=lg[i>>1]+1;
	n=read(),m=read(),qs=read();
	for (int i=1;i<=m;++i) x=read(),y=read(),add(x,y);
	topo_sort(),dfs(1),dfs4(1);
	for (int i=1;i<=n;++i)
	{
		used[i]=0;
		for (int j=0;j<E[i].size();++j)
			if (fas[E[i][j]]!=i)
				vis[i]=vis[E[i][j]]=1;
	}
	dfs5(1);
	for (int i=1;i<=n;++i) used[i]=0;
	dfs6(1);
	for (int i=1;i<=n;++i) L[i]=n+1,R[i]=0,sL[i]=n+1,sR[i]=0;
	for (int i=2;i<=n;++i)
		if (A[fas[i]]&&B[i])
			EZ[A[fas[i]]][B[i]]=1;
	for (int i=1;i<=n;++i)
		for (int j=0;j<E[i].size();++j)
			if (fas[E[i][j]]!=i)
				EZ[A[i]][A[E[i][j]]]=1;
	for (int i=1;i<=cater;++i) dfs7(i,i);
	for (int qt=1;qt<=qs;++qt)
	{
		k=read(),p=read(),top=length=0;
		for (int i=1;i<=cater;++i) sL[i]=p+1,sR[i]=0;
		for (int i=1;i<=p;++i) a[i]=read();
		sort(a+1,a+p+1,cmp);
		for (int i=1;i<=p;++i)
		{
			L[a[i]]=R[a[i]]=i,v[i].clear();
			for (int j=1;j<=cater;++j)
				if (usedt[j][A[a[i]]])
					sL[j]=min(sL[j],i),sR[j]=max(sR[j],i);
		}
		for (int i=1;i<=p;++i)
		{
			d=0;
			while (top&&!LENG(dque[top],a[i]))
			{
				if (d) ET[dque[top]].push_back(d);
				d=dque[top],top--;
			}
			if (d)
			{
				ds=lca(d,a[i]),ET[ds].push_back(d);
				if (dque[top]!=ds) dque[++top]=ds;
			}
			dque[++top]=a[i];
		}
		for (int i=1;i<=top-1;++i) ET[dque[i]].push_back(dque[i+1]);
		sfa[dque[1]]=0,dfs2(dque[1]);
		for (int i=0;i<=k;++i)
			for (int j=0;j<=p;++j)
				dp[i][j]=0;
		dp[0][0]=1;
		for (int i=1;i<=k;++i)
			for (int j=1;j<=p;++j)
				for (int t=0;t<v[j].size();++t)
					dp[i][j]+=dp[i-1][v[j][t].num-1]*v[j][t].data;
		write(dp[k][p]),puts(""),dfs3(dque[1]);
	}
	return 0;
}


详细

Test #1:

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

input:

4 4 4
1 2
1 3
2 4
3 4
1 1 4
2 1 4
1 1 3
2 2 3 2

output:

2
0
2
1

result:

ok 4 lines

Test #2:

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

input:

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

output:

0
0
3
2

result:

ok 4 lines

Test #3:

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

input:

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

output:

2
0
3
2

result:

ok 4 lines

Test #4:

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

input:

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

output:

9
2

result:

ok 2 lines

Test #5:

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

input:

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

output:

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

result:

ok 1020 lines

Test #6:

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

input:

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

output:

3
2

result:

ok 2 lines

Test #7:

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

input:

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

output:

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

result:

ok 1020 lines

Test #8:

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

input:

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

output:

3
2

result:

ok 2 lines

Test #9:

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

input:

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

output:

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

result:

ok 1020 lines

Test #10:

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

input:

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

output:

2
2

result:

ok 2 lines

Test #11:

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

input:

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

output:

1
0
0
1
1
0
0
0
0
1
1
1
1
0
0
0
0
0
0
0
1
0
0
1
0
0
0
0
0
0
0
0
0
1
1
0
0
0
0
1
1
0
0
0
0
0
0
0
0
0
3
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
1
0
1
1
1
1
0
1
1
0
0
0
1
1
0
0
0
0
0
1
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
1
0
0
0
1
0
0
0
0
0
0
0
0
1
0
0
1
1
0
0
0
0
1
0
1
1
0
0
0
1
0
0
0
0
1
1
0
...

result:

ok 1020 lines

Test #12:

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

input:

30 32 70
5 6
2 3
16 17
1 9
1 23
27 28
9 10
10 11
21 22
6 7
28 29
15 30
18 19
19 20
1 16
4 5
13 14
7 8
25 26
29 30
8 30
26 27
22 30
23 24
20 21
12 13
17 18
3 4
11 12
24 25
14 15
1 2
4 4 19 20 21 30
4 4 8 13 22 29
4 4 3 10 19 21
4 4 6 18 19 23
4 4 10 13 18 28
4 4 14 25 26 28
4 4 11 17 22 27
4 4 3 5 14...

output:

0
1715
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
84
140
0
0
0
0
0
0
0
0
0
0
420
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
108
0
0
24
105
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 70 lines

Test #13:

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

input:

30 32 70
5 6
2 3
16 17
1 9
1 23
27 28
9 10
10 11
21 22
6 7
28 29
15 30
18 19
19 20
1 16
4 5
13 14
7 8
25 26
29 30
8 30
26 27
22 30
23 24
20 21
12 13
17 18
3 4
11 12
24 25
14 15
1 2
3 3 2 11 12
3 3 2 13 26
3 3 10 26 28
3 3 5 7 8
3 3 1 4 12
3 3 9 16 17
3 3 4 19 27
3 3 3 6 9
3 3 11 17 21
3 3 15 25 26
3...

output:

0
20
0
0
0
0
60
0
0
0
0
0
120
0
0
20
0
112
96
0
0
0
18
0
6
0
196
0
28
0
0
14
49
0
0
36
0
24
10
0
0
0
0
75
0
63
0
16
0
0
0
0
90
0
64
0
0
0
84
0
0
0
0
0
0
0
28
0
0
0

result:

ok 70 lines

Test #14:

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

input:

30 32 70
5 6
2 3
16 17
1 9
1 23
27 28
9 10
10 11
21 22
6 7
28 29
15 30
18 19
19 20
1 16
4 5
13 14
7 8
25 26
29 30
8 30
26 27
22 30
23 24
20 21
12 13
17 18
3 4
11 12
24 25
14 15
1 2
2 2 3 25
2 2 7 20
2 2 14 25
2 2 9 20
2 2 9 12
2 2 18 20
2 2 10 13
2 2 7 9
2 2 2 22
2 2 16 26
2 2 5 24
2 2 5 10
2 2 12 1...

output:

6
30
18
5
0
0
0
6
7
4
8
8
0
12
35
0
24
5
6
0
0
0
30
0
0
8
6
3
30
0
2
0
6
0
2
0
5
0
0
0
21
24
1
2
0
0
0
18
49
8
1
15
35
35
12
14
30
20
9
0
0
4
28
0
18
4
14
15
20
0

result:

ok 70 lines

Test #15:

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

input:

30 32 30
5 6
2 3
16 17
1 9
1 23
27 28
9 10
10 11
21 22
6 7
28 29
15 30
18 19
19 20
1 16
4 5
13 14
7 8
25 26
29 30
8 30
26 27
22 30
23 24
20 21
12 13
17 18
3 4
11 12
24 25
14 15
1 2
1 1 20
1 1 15
1 1 28
1 1 29
1 1 25
1 1 2
1 1 19
1 1 13
1 1 22
1 1 9
1 1 17
1 1 18
1 1 24
1 1 10
1 1 3
1 1 12
1 1 1
1 1 ...

output:

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

result:

ok 30 lines

Test #16:

score: 0
Accepted
time: 10ms
memory: 26124kb

input:

30 32 19405
5 6
2 3
16 17
1 9
1 23
27 28
9 10
10 11
21 22
6 7
28 29
15 30
18 19
19 20
1 16
4 5
13 14
7 8
25 26
29 30
8 30
26 27
22 30
23 24
20 21
12 13
17 18
3 4
11 12
24 25
14 15
1 2
4 4 9 12 13 17
4 4 6 7 11 21
4 4 3 11 17 19
4 4 8 19 25 30
4 4 4 16 23 29
4 4 10 17 19 27
4 4 2 6 25 26
4 4 1 6 15 2...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
432
672
144
72
0
0
0
48
0
0
0
0
0
0
0
0
1764
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
64
0
0
0
0
0
0
0
0
0
840
0
0
0
0
0
200
0
0
0
0
0
0
0
0
0
0
0
0
0
0
840
0
96
0
0
0
0
0
0
0
336
0
0
0
0
0
36
0
0
0
0
252
0
0
0
0
0
0
0
0
300
0
0
0
0
0
0
0
0
0
0
840
0
0
0
0
0
0
0
0
84
0
0...

result:

ok 19405 lines

Test #17:

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

input:

30 38 70
1 2
2 3
3 4
4 5
5 6
6 7
7 8
1 9
9 10
10 11
11 12
12 13
13 14
14 15
1 16
16 17
17 18
18 19
19 20
20 21
21 22
1 23
23 24
24 25
25 26
26 27
27 28
28 29
16 23
18 23
27 2
28 2
2 9
3 9
15 30
29 30
22 30
8 30
4 4 20 23 29 30
4 4 1 11 26 30
4 4 3 16 18 23
4 4 5 17 19 24
4 4 7 16 18 19
4 4 5 10 18 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

result:

ok 70 lines

Test #18:

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

input:

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

output:

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

result:

ok 6195 lines

Test #19:

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

input:

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

output:

0
0
0
0
0
0
6
0
0
0
0
0
8
0
0
9
0
0
24
0
0
12
2
0
0
0
6
0
0
0
12
18
0
0
4
0
0
0
0
0
0
0
0
24
0
0
2
0
0
0
0
3
0
0
0
0
0
18
0
0
16
0
0
4
6
27
0
0
0
8
0
0
0
0
0
0
0
24
0
0
8
0
4
0
0
0
6
4
0
0
4
0
0
0
0
1
0
0
0
0
4
0
0
0
0
0
0
0
0
0
1
0
0
6
0
6
8
0
0
0
0
0
0
0
0
0
6
0
0
0
0
0
0
0
6
0
3
0
4
0
0
9
4
0
0
0...

result:

ok 6195 lines

Test #20:

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

input:

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

output:

0
0
0
0
0
0
10
0
2
0
0
8
0
0
0
0
0
0
2
2
0
0
0
0
0
0
3
4
0
2
0
5
0
4
0
0
0
0
3
0
0
0
0
4
0
1
0
4
0
2
2
0
0
0
1
1
3
6
0
8
0
2
0
1
0
0
0
0
0
0
0
0
0
4
0
0
0
6
0
0
0
6
0
0
12
0
4
0
6
0
4
0
0
8
6
6
0
0
0
4
0
2
0
0
0
0
0
0
6
12
4
0
2
12
0
0
0
0
6
0
3
1
3
0
0
0
0
0
2
0
0
2
0
2
0
0
3
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 6195 lines

Test #21:

score: 0
Accepted
time: 103ms
memory: 41888kb

input:

99998 100000 40018
56803 56804
28456 28457
7503 7504
57479 57480
60467 60468
49082 49083
96091 96092
12177 12178
14718 14719
91546 91547
32280 32281
24589 24590
68619 68620
48993 48994
66820 66821
79526 79527
66592 66593
50885 50886
6647 6648
89570 89571
95095 95096
37593 37594
95870 95871
77917 779...

output:

0
0
298286769040
0
0
0
1
1
0
1
0
194683976
0
0
0
0
1
0
1
0
0
0
0
0
1555840698120
0
0
0
1
0
69776636013
0
0
0
1
0
1
0
1
9807
1
1
14289386090658252
1
1
0
8282
38189520
0
0
361
1311799507285176
911661274353
0
1
0
0
0
2542706031866
0
0
0
149344635
0
0
154279471
1
1
1
0
0
1
1
26733661808
544261562
887482...

result:

ok 40018 lines

Test #22:

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

input:

99998 100000 18405
56803 56804
28456 28457
7503 7504
57479 57480
60467 60468
49082 49083
96091 96092
12177 12178
14718 14719
91546 91547
32280 32281
24589 24590
68619 68620
48993 48994
66820 66821
79526 79527
66592 66593
50885 50886
6647 6648
89570 89571
95095 95096
37593 37594
95870 95871
77917 779...

output:

0
118627327608
0
0
0
0
1
1
1
0
0
3978839141992800
0
0
0
500292640075200
1
0
2995892576470080
1
0
0
3503
0
0
0
9321798690233988
0
1
52245492
0
0
20266
0
0
0
53739800
0
31865956400246640
43409382192
0
0
59886792
9355330123030
1
0
1
0
1
298056461795400
212717031912000
249180259392
0
0
2639630431074
0
0...

result:

ok 18405 lines

Test #23:

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

input:

99998 100000 1982
56803 56804
28456 28457
7503 7504
57479 57480
60467 60468
49082 49083
96091 96092
12177 12178
14718 14719
91546 91547
32280 32281
24589 24590
68619 68620
48993 48994
66820 66821
79526 79527
66592 66593
50885 50886
6647 6648
89570 89571
95095 95096
37593 37594
95870 95871
77917 7791...

output:

1001950210080
1
142182748260
1
0
0
0
0
3007012336860
0
0
0
1
1
0
0
12263470896
1
0
1
0
6577637700920
0
21072165374
1
0
1
0
229878034749000
1
0
1
1
0
1
0
0
1
1
0
1551841626124800
605328014071872
79137667714560
3746658561084
0
1
595702804349040
1
368128764432
1
19993428928
1
0
0
0
0
1
0
0
801682818750...

result:

ok 1982 lines

Test #24:

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

input:

99998 100000 211
56803 56804
28456 28457
7503 7504
57479 57480
60467 60468
49082 49083
96091 96092
12177 12178
14718 14719
91546 91547
32280 32281
24589 24590
68619 68620
48993 48994
66820 66821
79526 79527
66592 66593
50885 50886
6647 6648
89570 89571
95095 95096
37593 37594
95870 95871
77917 77918...

output:

134139450
0
0
1
35252238672
0
0
20463100
44500500
0
0
1
0
0
0
0
0
483935265
0
41147647200
0
69503616
0
19423657440
0
1
0
0
1
1
1
84889
0
18496578800
0
1
4027968
0
1
1
0
0
0
590212224
0
0
5378068
0
1
0
1
0
0
0
1
0
1
320137920
1
0
0
0
5544986944
0
1
1
0
1
0
0
1
0
1348480
1
60384000
1
11867796122624
1
...

result:

ok 211 lines

Test #25:

score: 0
Accepted
time: 53ms
memory: 45972kb

input:

99998 100000 15
56803 56804
28456 28457
7503 7504
57479 57480
60467 60468
49082 49083
96091 96092
12177 12178
14718 14719
91546 91547
32280 32281
24589 24590
68619 68620
48993 48994
66820 66821
79526 79527
66592 66593
50885 50886
6647 6648
89570 89571
95095 95096
37593 37594
95870 95871
77917 77918
...

output:

0
0
0
0
0
213449804015280
0
0
373516110
1
0
1
0
0
0

result:

ok 15 lines

Test #26:

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

input:

99998 100000 40003
56803 56804
28456 28457
7503 7504
57479 57480
60467 60468
49082 49083
96091 96092
12177 12178
14718 14719
91546 91547
32280 32281
24589 24590
68619 68620
48993 48994
66820 66821
79526 79527
66592 66593
50885 50886
6647 6648
89570 89571
95095 95096
37593 37594
95870 95871
77917 779...

output:

0
0
24723477555562240
1
0
1
0
0
1
69590355
0
0
0
290660564
0
0
0
872824656600
0
1
0
120018411590
0
0
0
0
0
1296
0
0
0
1
0
0
406851372
0
0
0
0
1469
0
0
57692701815
0
0
0
0
212747894766
1
37665390
1
1
2320288257651
0
0
21569
0
0
1
0
1
0
39836748
24359
347
4765
10367
0
0
0
0
0
0
0
27720000
0
0
0
0
1
0
...

result:

ok 40003 lines

Test #27:

score: 0
Accepted
time: 122ms
memory: 43200kb

input:

99998 100000 25000
56803 56804
28456 28457
7503 7504
57479 57480
60467 60468
49082 49083
96091 96092
12177 12178
14718 14719
91546 91547
32280 32281
24589 24590
68619 68620
48993 48994
66820 66821
79526 79527
66592 66593
50885 50886
6647 6648
89570 89571
95095 95096
37593 37594
95870 95871
77917 779...

output:

34638752617398800
13087104390091816
18597902661674336
13260707158526208
34039680688570392
40370744515645170
58747123908277920
19010092301438112
1105801092830616
14874839425410176
37091165657763360
112521134825746200
84093565287669300
4185617187981600
14068003514019840
5189876927656344
69803346875316...

result:

ok 25000 lines

Test #28:

score: 0
Accepted
time: 102ms
memory: 42172kb

input:

99982 100000 40060
429 430
43935 43936
35908 35909
73132 73133
19211 19212
65777 65778
94131 94132
72015 72016
71254 71255
33126 33127
59388 59389
13649 13650
19511 19512
48 49
86111 86112
82237 82238
76191 76192
14637 14638
12313 12314
68813 68814
25386 25387
50390 50391
26817 26818
83709 83710
450...

output:

0
0
1
1
1
1239300
492684720
0
0
0
0
1
0
0
2124
0
1
1
5405405616
0
3907
0
0
0
0
1
0
0
8019748
0
0
0
0
0
6685535118
2656632
0
20659650984
3070446
7507461024
1079111856
0
0
0
0
0
0
0
0
331177980
0
0
0
352
0
1355438565
0
1
4576
0
9283260
0
1518978560
0
0
1
1
1
0
0
0
0
0
0
0
0
1
0
156
0
0
2847285
0
56080...

result:

ok 40060 lines

Test #29:

score: 0
Accepted
time: 104ms
memory: 42092kb

input:

99982 100000 18191
429 430
43935 43936
35908 35909
73132 73133
19211 19212
65777 65778
94131 94132
72015 72016
71254 71255
33126 33127
59388 59389
13649 13650
19511 19512
48 49
86111 86112
82237 82238
76191 76192
14637 14638
12313 12314
68813 68814
25386 25387
50390 50391
26817 26818
83709 83710
450...

output:

0
0
1
0
0
1
0
0
0
1
1770160
0
3399076
1
0
30953623834452
0
152334476
0
0
8110252368
1
0
0
0
0
1
479
0
1
0
0
0
0
0
0
0
0
0
0
1
0
0
1
21987480
0
0
0
0
1
1
22077527020800
1
0
0
0
0
0
3830
0
0
0
1
0
0
0
0
0
1
0
691
1
8331520483230
1
1
0
1
0
40113082035
0
1
1
4564761300
0
0
0
0
0
6949227
1
0
1016
1351213...

result:

ok 18191 lines

Test #30:

score: 0
Accepted
time: 94ms
memory: 43280kb

input:

99982 100000 1984
429 430
43935 43936
35908 35909
73132 73133
19211 19212
65777 65778
94131 94132
72015 72016
71254 71255
33126 33127
59388 59389
13649 13650
19511 19512
48 49
86111 86112
82237 82238
76191 76192
14637 14638
12313 12314
68813 68814
25386 25387
50390 50391
26817 26818
83709 83710
4500...

output:

0
0
0
1
0
0
1
0
0
0
1
0
0
0
0
1
0
1
0
0
0
0
1
1
0
0
0
1
1
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
7102612
0
0
1
0
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
1
0
0
0
0
0
1
0
1
0
0
0
0
1
0
0
0
1
495756450
0
1
0
0
0
0
0
0
0
0
1
0
1
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
1
0
1
0
1
0
0
0
0
0
...

result:

ok 1984 lines

Test #31:

score: 0
Accepted
time: 83ms
memory: 43944kb

input:

99982 100000 213
429 430
43935 43936
35908 35909
73132 73133
19211 19212
65777 65778
94131 94132
72015 72016
71254 71255
33126 33127
59388 59389
13649 13650
19511 19512
48 49
86111 86112
82237 82238
76191 76192
14637 14638
12313 12314
68813 68814
25386 25387
50390 50391
26817 26818
83709 83710
45000...

output:

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

result:

ok 213 lines

Test #32:

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

input:

99982 100000 13
429 430
43935 43936
35908 35909
73132 73133
19211 19212
65777 65778
94131 94132
72015 72016
71254 71255
33126 33127
59388 59389
13649 13650
19511 19512
48 49
86111 86112
82237 82238
76191 76192
14637 14638
12313 12314
68813 68814
25386 25387
50390 50391
26817 26818
83709 83710
45000 ...

output:

0
0
0
0
0
0
0
0
1
0
0
0
0

result:

ok 13 lines

Test #33:

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

input:

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

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
6694
0
41984350
0
0
1
0
23751
0
1
0
1
0
0
1
0
0
0
23668
0
0
0
0
0
12161
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
12947
0
0
0
1
1
0
0
0
202
0
0
1
0
0
0
16093
0
0
0
0
1
24184
0
0
0
1
6019
0
0
0
0
0
0
0
0
19160
1
0
0
0
0
21840
12001
0
0
0
0
0
1
8877
0
0
1
1
1
0
0
0
10619
...

result:

ok 40077 lines

Test #34:

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

input:

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

output:

0
0
1
0
1
1
0
0
0
12579
1
0
1
1
1
0
0
0
0
0
0
5443
9600
0
1
0
0
0
0
0
0
0
1
1
21489
0
1
1
0
0
0
1
0
0
0
0
1
23994450
0
1
0
0
0
0
9744
1
0
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
0
23023225
0
0
1
0
0
0
0
0
0
0
1
0
1
0
0
0
0
0
0
0
0
1
1
0
0
0
0
1
0
1
0
0
0
0
75260304
0
1
0
0
0
0
0
0
0
0
0
0
0
0
7627
0
1
24576
1...

result:

ok 18232 lines

Test #35:

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

input:

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

output:

0
0
0
1
0
0
0
1
0
0
0
1
1
1
0
0
0
0
0
0
0
0
1
0
0
0
1
1
0
0
0
0
0
1
0
1
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
0
0
1
1
0
0
0
1
0
1
1
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
1
1
0
1
1
0
1
0
0
0
0
1
0
1
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
1
0
0
0
0
0
0
0
0
0
1
1
0
0
0
0
1
0
0
0
...

result:

ok 1984 lines

Test #36:

score: 0
Accepted
time: 53ms
memory: 49844kb

input:

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

output:

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

result:

ok 198 lines

Test #37:

score: 0
Accepted
time: 41ms
memory: 50080kb

input:

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

output:

1
0
0
0
0
0
0
1
0
0
0
1
0
1
0
0
0

result:

ok 17 lines

Test #38:

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

input:

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

output:

1
0
0
0
0
0
12400
0
1
1
1
0
0
0
0
0
1
0
0
0
0
9617230
1
0
0
0
0
0
0
12776
1
1
0
0
0
0
0
1
0
0
3407
0
0
1039208112150516
0
0
48779016
0
0
0
69035843616
0
1
0
1
0
0
0
0
0
0
0
1
0
1
0
1
1
0
1
0
66372150
1
9607
14390
0
0
0
0
0
0
0
1
0
0
0
30299235
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
1
0
0
0
0
1
0
1
0
...

result:

ok 39850 lines

Test #39:

score: 0
Accepted
time: 87ms
memory: 46340kb

input:

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

output:

0
0
0
0
0
0
0
0
455861090472660
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2789201369093840
0
0
0
0
0
0
0
2061545277789660
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
797988378283712
0
0
0
1668993541667100
0
1956836957525280
0
1492705368707520
0
0
0
0
0
0
0
0
0
0
6402650306547684
0
0
0
0
0
2226206025139200
0
0
0
0
0
0
1...

result:

ok 25000 lines

Test #40:

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

input:

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

output:

0
0
0
0
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
0
0
0
0
1
1
0
1
1
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
1
0
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
17169
0
2967
0
1
16439
0
1
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
7251
0
991
1
0
1
0
0
0
0
0
4092
1
0
0
0...

result:

ok 40146 lines

Test #41:

score: 0
Accepted
time: 95ms
memory: 47888kb

input:

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

output:

0
0
0
0
0
0
0
0
0
1
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
1
11249
1
0
0
0
24696
0
0
0
0
0
0
0
0
0
0
1
0
0
0
24309
0
1
0
0
0
0
0
0
0
0
0
0
1874
0
0
0
0
0
0
1
5215
0
0
0
0
1
0
0
6710
0
0
0
0
1
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
6677
0
0
0
18410
0
0
10942908
0
1
0
0
0
0
1
0
1
0
0
1
0
0
1
0
0
142...

result:

ok 40035 lines

Test #42:

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

input:

100000 99999 100000
5541 8237
18051 93161
39292 28423
39951 50802
70539 55736
21230 93162
93714 96830
97206 75839
80861 45890
85303 44198
7649 61828
34399 6757
16385 14680
52314 72478
16605 76186
58131 9693
31198 16693
75353 46182
34523 41478
48258 38326
93349 90553
14740 67406
66890 98367
51410 734...

output:

21380
20452
31337
30716
12448
29927
39922
2142
609
16691
37451
69645
22177
38667
17458
46523
19883
93319
56400
78603
22007
77996
51467
41195
98987
11487
58108
6736
7606
69893
48088
13469
93494
24074
83925
7251
98879
77731
38874
420
53807
77101
59271
11856
77004
77999
96865
233
28393
68475
91172
5019...

result:

ok 100000 lines

Test #43:

score: 0
Accepted
time: 133ms
memory: 42160kb

input:

100000 100050 100000
46437 23373
42030 47052
43923 24855
81127 33614
11690 62561
42403 40964
37781 8082
47323 35137
91690 35377
57081 41842
217 86286
74432 26613
58449 29919
17809 17649
66787 84151
75754 59501
64730 63008
12899 58601
39565 16859
30299 90805
39122 18823
40085 6851
32105 71175
87628 5...

output:

10907
9429
1287
11865
9442
556
21033
15121
4752
15871
15240
12411
9102
11851
17840
11559
13246
16041
14276
14438
10605
8709
18041
8653
9062
13169
1703
9053
10382
15493
8687
11607
14197
19339
211
13518
13292
10571
19506
9808
15396
15682
10659
9712
14833
16347
8950
9008
15691
13262
12380
18336
3504
13...

result:

ok 100000 lines

Test #44:

score: 0
Accepted
time: 142ms
memory: 44568kb

input:

100000 100050 40021
31171 91593
76166 29603
34976 14476
79185 90655
68947 30608
2530 67866
60582 65562
56951 95533
90995 10438
16334 40971
57663 41751
64799 24446
42422 43105
43213 97403
67933 25494
78953 16697
66828 85848
73327 24938
48961 70556
78162 1172
93474 11462
20572 95540
50643 19624
81478 ...

output:

0
0
0
0
1371
0
9227
0
3536
0
0
0
9085
0
1371
1605
0
0
0
113
1371
13325
0
0
0
1371
1371
0
1371
0
3037
459
0
2010
0
1371
0
0
0
0
0
3905
0
1371
1371
0
0
0
0
0
0
0
0
0
1371
0
0
0
1371
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
15228
0
0
0
0
0
0
0
0
0
0
1371
2633
0
0
0
13325
1371
0
0
13325
0
0
0
0
0
0
0
1371
...

result:

ok 40021 lines

Test #45:

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

input:

100000 100050 18030
31171 91593
76166 29603
34976 14476
79185 90655
68947 30608
2530 67866
60582 65562
56951 95533
90995 10438
16334 40971
57663 41751
64799 24446
42422 43105
43213 97403
67933 25494
78953 16697
66828 85848
73327 24938
48961 70556
78162 1172
93474 11462
20572 95540
50643 19624
81478 ...

output:

0
0
1371
0
113
0
1371
0
1371
0
12765
0
0
0
1371
0
0
962
1371
1371
0
702
21282
1371
13325
0
1371
1371
1371
0
0
0
0
1371
0
0
0
1371
0
1371
1371
1371
1371
0
0
0
1371
1371
0
0
0
0
5707
0
1371
0
0
0
0
0
0
0
0
0
0
1371
0
0
0
0
0
0
0
0
0
0
1371
1371
2075
0
0
0
0
0
76
0
0
0
0
113
1371
0
0
0
0
0
1371
7808
0
...

result:

ok 18030 lines

Test #46:

score: 0
Accepted
time: 107ms
memory: 45524kb

input:

100000 100050 1998
31171 91593
76166 29603
34976 14476
79185 90655
68947 30608
2530 67866
60582 65562
56951 95533
90995 10438
16334 40971
57663 41751
64799 24446
42422 43105
43213 97403
67933 25494
78953 16697
66828 85848
73327 24938
48961 70556
78162 1172
93474 11462
20572 95540
50643 19624
81478 4...

output:

1371
0
0
1371
0
113
0
0
0
0
0
0
0
0
0
0
0
0
0
113
0
0
0
113
0
1266
0
0
0
0
1371
0
0
113
0
0
0
0
0
0
113
0
1371
0
0
0
0
113
113
440
113
0
0
0
994
0
0
0
0
1371
0
113
0
0
0
0
0
0
0
0
0
0
113
0
0
0
0
0
0
0
0
0
0
113
0
113
0
1371
113
0
1371
0
0
0
91
1371
0
0
0
0
1371
0
0
113
1371
0
113
0
0
0
1371
0
0
0
1...

result:

ok 1998 lines

Test #47:

score: 0
Accepted
time: 90ms
memory: 46528kb

input:

100000 100050 207
31171 91593
76166 29603
34976 14476
79185 90655
68947 30608
2530 67866
60582 65562
56951 95533
90995 10438
16334 40971
57663 41751
64799 24446
42422 43105
43213 97403
67933 25494
78953 16697
66828 85848
73327 24938
48961 70556
78162 1172
93474 11462
20572 95540
50643 19624
81478 46...

output:

0
113
0
113
113
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
58
0
0
0
50
0
0
38
0
0
0
113
0
0
0
0
0
0
0
0
0
0
101
0
113
0
0
113
113
0
39
0
0
113
0
0
0
0
0
0
0
0
0
1371
0
0
0
0
0
3
0
0
0
0
108
0
0
0
113
0
0
113
0
0
0
0
0
113
0
0
0
0
2
113
0
0
113
0
0
0
0
0
0
0
0
0
0
0
0
0
0
113
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
31
...

result:

ok 207 lines

Test #48:

score: 0
Accepted
time: 85ms
memory: 46728kb

input:

100000 100050 10
31171 91593
76166 29603
34976 14476
79185 90655
68947 30608
2530 67866
60582 65562
56951 95533
90995 10438
16334 40971
57663 41751
64799 24446
42422 43105
43213 97403
67933 25494
78953 16697
66828 85848
73327 24938
48961 70556
78162 1172
93474 11462
20572 95540
50643 19624
81478 469...

output:

0
2
8
0
46
0
0
0
1371
0

result:

ok 10 lines

Test #49:

score: 0
Accepted
time: 50ms
memory: 34720kb

input:

100000 99999 100000
15789 54102
46515 22591
28936 7417
83198 94111
94760 65891
35733 17960
16371 7105
24200 9087
31448 27438
70386 57790
42195 40016
51605 47914
38402 23090
51851 34269
8649 13743
78608 89915
62767 75127
20732 70360
99154 89410
70212 18686
20234 5404
68024 94566
12286 31623
64236 290...

output:

0
0
0
0
0
16
0
15
16
0
16
16
0
14
16
16
16
16
14
0
16
17
16
0
0
17
0
0
16
17
16
17
0
0
0
0
17
0
17
17
0
15
17
17
16
16
16
0
0
0
13
0
0
0
16
0
13
17
0
17
0
17
17
15
17
0
0
0
17
0
16
15
16
16
14
17
0
0
0
17
14
15
0
0
0
16
15
0
16
0
0
0
15
16
0
14
0
16
15
17
16
0
0
0
15
0
0
17
0
15
16
17
0
15
17
0
0
15...

result:

ok 100000 lines

Test #50:

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

input:

100000 99999 66715
15789 54102
46515 22591
28936 7417
83198 94111
94760 65891
35733 17960
16371 7105
24200 9087
31448 27438
70386 57790
42195 40016
51605 47914
38402 23090
51851 34269
8649 13743
78608 89915
62767 75127
20732 70360
99154 89410
70212 18686
20234 5404
68024 94566
12286 31623
64236 2901...

output:

225
2
0
72
16
16
0
240
0
0
11
15
240
1
17
1
17
15
2
168
0
1
2
0
225
14
1
1
225
75
132
0
1
17
0
17
256
1
1
0
0
16
0
16
0
17
17
1
1
4
0
2
2
0
17
0
120
1
169
0
1
0
156
210
15
17
224
210
5
0
0
1
1
182
2
17
2
1
2
2
2
143
0
3
16
0
17
196
4
143
17
1
1
192
225
16
1
0
0
1
1
0
70
0
17
0
0
4
0
0
17
5
0
1
2
12
...

result:

ok 66715 lines

Test #51:

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

input:

100000 99999 40054
15789 54102
46515 22591
28936 7417
83198 94111
94760 65891
35733 17960
16371 7105
24200 9087
31448 27438
70386 57790
42195 40016
51605 47914
38402 23090
51851 34269
8649 13743
78608 89915
62767 75127
20732 70360
99154 89410
70212 18686
20234 5404
68024 94566
12286 31623
64236 2901...

output:

18720
2366
0
21780
0
1
30
28
30
15
210
0
3
17
5
0
1
0
2
0
121
0
0
0
0
0
0
20475
154
15
0
0
196
0
0
16
0
28
15
13
0
15
224
0
0
0
13
1
450
0
466
0
0
17
132
90
0
1
15
15
1
0
1
2080
0
0
0
1
0
546
2940
0
130
15
0
45
1
1
6
2
0
2744
210
0
23100
225
0
22308
0
16
0
0
0
1
2
0
128
0
0
3
240
0
15
0
3
2112
23760...

result:

ok 40054 lines

Test #52:

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

input:

100000 99999 18261
15789 54102
46515 22591
28936 7417
83198 94111
94760 65891
35733 17960
16371 7105
24200 9087
31448 27438
70386 57790
42195 40016
51605 47914
38402 23090
51851 34269
8649 13743
78608 89915
62767 75127
20732 70360
99154 89410
70212 18686
20234 5404
68024 94566
12286 31623
64236 2901...

output:

224
2
14157
3136
0
1
225
1
1
15
284
1
0
2
17325
0
364
124
6300
1
15
1
406
24024
1
1
2
2
1
704
3
15
4
1
18
1
1
148
1
7920
1
0
15
159
0
1
2287
0
15
1
1
29
2
0
1
195
530
24
0
2100
0
1
15
1
0
1
17
177
1
4
32
0
3964
13
144
1
1859
15
1
210
2
1
14
1
0
1
2955
15
3
158
6370
4
760
4
3
12
2
0
15
1
1
114
2
1
16...

result:

ok 18261 lines

Test #53:

score: 0
Accepted
time: 84ms
memory: 38920kb

input:

100000 99999 1915
15789 54102
46515 22591
28936 7417
83198 94111
94760 65891
35733 17960
16371 7105
24200 9087
31448 27438
70386 57790
42195 40016
51605 47914
38402 23090
51851 34269
8649 13743
78608 89915
62767 75127
20732 70360
99154 89410
70212 18686
20234 5404
68024 94566
12286 31623
64236 29012...

output:

1
31
6
1
2
1
1
1
0
23
2
1
1
2
3
5
2664
2
2
992
5
26
31
1
31
2
1
1
10
5
2
1
1
1
2
1
1
1
23
1
17
5
2
1
1
1
1
2
2
0
2
1
6
1
19
1
29
133
1
1
1
9
6
44
1
1
5
1
1
1
34
5
1
1
1
1
5
1
17
18
2
1
1
1
1
1
1
1
2
19
1
1
2
2
1
1
1
8
1
215
2
134
1
1
2
2
1
0
1
13
2
2
12
5
1
1
2
1
1
2
1
5
1
1
1
5
1
5
1
2
1
2
240
2
2
...

result:

ok 1915 lines

Test #54:

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

input:

100000 99999 201
15789 54102
46515 22591
28936 7417
83198 94111
94760 65891
35733 17960
16371 7105
24200 9087
31448 27438
70386 57790
42195 40016
51605 47914
38402 23090
51851 34269
8649 13743
78608 89915
62767 75127
20732 70360
99154 89410
70212 18686
20234 5404
68024 94566
12286 31623
64236 29012
...

output:

2
2
2
2
1
5
2
1
1
1
2
1
1
5
2
2
1
1
5
1
1
2
1
2
5
38
1
1
1
1
2
2
5
5
5
2
1
5
1
2
1
2
5
2
1
1
1
1
1
5
5
5
5
1
1
1
1
2
1
2
1
1
2
2
1
5
1
2
1
1
2
840
1
5
5
141
1
1
2
1
1
2
1
2
5
2
1
5
1
1
1
1
5
5
1
1
2
199
5
5
5
5
1
1
2
2
5
1
1
2
1
1
1
1
2
1
1
1
1
2
5
2
5
2
1
1
6
1
2
5
2
1
2
1
1
5
5
1
1
5
5
1
1
1
1
5
1...

result:

ok 201 lines

Test #55:

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

input:

100000 99999 7
15789 54102
46515 22591
28936 7417
83198 94111
94760 65891
35733 17960
16371 7105
24200 9087
31448 27438
70386 57790
42195 40016
51605 47914
38402 23090
51851 34269
8649 13743
78608 89915
62767 75127
20732 70360
99154 89410
70212 18686
20234 5404
68024 94566
12286 31623
64236 29012
16...

output:

2
0
2
1
1
0
0

result:

ok 7 lines

Test #56:

score: 0
Accepted
time: 34ms
memory: 34248kb

input:

100000 99999 100000
38493 93031
50259 83194
75839 1089
88883 45209
92982 95451
82019 80080
63806 37083
3799 83600
57 75363
38897 41484
91730 92697
92982 13707
88236 17290
77237 55294
88798 74067
2376 13158
11381 27692
19580 43791
91423 36132
86322 70710
38897 73337
31960 75701
91743 52634
75839 4350...

output:

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

result:

ok 100000 lines

Test #57:

score: 0
Accepted
time: 35ms
memory: 34508kb

input:

100000 99999 66807
38493 93031
50259 83194
75839 1089
88883 45209
92982 95451
82019 80080
63806 37083
3799 83600
57 75363
38897 41484
91730 92697
92982 13707
88236 17290
77237 55294
88798 74067
2376 13158
11381 27692
19580 43791
91423 36132
86322 70710
38897 73337
31960 75701
91743 52634
75839 43509...

output:

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

result:

ok 66807 lines

Test #58:

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

input:

100000 99999 39922
38493 93031
50259 83194
75839 1089
88883 45209
92982 95451
82019 80080
63806 37083
3799 83600
57 75363
38897 41484
91730 92697
92982 13707
88236 17290
77237 55294
88798 74067
2376 13158
11381 27692
19580 43791
91423 36132
86322 70710
38897 73337
31960 75701
91743 52634
75839 43509...

output:

0
4
1
16
0
0
0
3
3
4
4
3
0
16
0
0
3
1
0
0
0
1
0
0
0
1
0
16
0
1
1
0
0
0
3
0
0
0
1
0
8
0
1
0
16
0
0
16
0
1
0
0
0
1
1
0
1
1
8
0
3
0
0
1
0
1
1
0
3
0
8
0
0
0
2
0
4
0
1
0
0
0
1
1
0
1
0
0
1
0
0
0
0
8
0
0
1
8
8
1
4
8
1
0
16
0
0
0
16
3
1
3
0
0
0
0
4
0
1
0
0
0
0
0
1
16
16
1
0
0
0
1
0
3
0
0
0
1
0
0
0
0
0
0
0
1...

result:

ok 39922 lines

Test #59:

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

input:

100000 99999 18276
38493 93031
50259 83194
75839 1089
88883 45209
92982 95451
82019 80080
63806 37083
3799 83600
57 75363
38897 41484
91730 92697
92982 13707
88236 17290
77237 55294
88798 74067
2376 13158
11381 27692
19580 43791
91423 36132
86322 70710
38897 73337
31960 75701
91743 52634
75839 43509...

output:

1
0
0
0
0
0
0
0
1
0
16
0
1
0
0
0
0
0
0
1
4
1
1
1
0
0
0
0
0
0
0
0
0
1
1
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
8
0
1
1
1
1
0
0
0
0
0
2
0
1
0
0
0
0
0
1
0
0
1
0
1
0
8
0
1
0
0
1
0
0
0
0
0
0
0
1
0
0
1
0
4
0
0
0
0
1
1
0
0
4
4
0
0
16
0
0
0
0
1
0
0
1
0
1
0
4
0
0
0
0
1
0
0
0
0
1
0
0
1
1
1
1
1
1
1
0
0
8
1
0
1
1
...

result:

ok 18276 lines

Test #60:

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

input:

100000 99999 2005
38493 93031
50259 83194
75839 1089
88883 45209
92982 95451
82019 80080
63806 37083
3799 83600
57 75363
38897 41484
91730 92697
92982 13707
88236 17290
77237 55294
88798 74067
2376 13158
11381 27692
19580 43791
91423 36132
86322 70710
38897 73337
31960 75701
91743 52634
75839 43509
...

output:

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

result:

ok 2005 lines

Test #61:

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

input:

100000 99999 198
38493 93031
50259 83194
75839 1089
88883 45209
92982 95451
82019 80080
63806 37083
3799 83600
57 75363
38897 41484
91730 92697
92982 13707
88236 17290
77237 55294
88798 74067
2376 13158
11381 27692
19580 43791
91423 36132
86322 70710
38897 73337
31960 75701
91743 52634
75839 43509
3...

output:

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

result:

ok 198 lines

Test #62:

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

input:

100000 99999 6
38493 93031
50259 83194
75839 1089
88883 45209
92982 95451
82019 80080
63806 37083
3799 83600
57 75363
38897 41484
91730 92697
92982 13707
88236 17290
77237 55294
88798 74067
2376 13158
11381 27692
19580 43791
91423 36132
86322 70710
38897 73337
31960 75701
91743 52634
75839 43509
384...

output:

1
1
1
0
0
0

result:

ok 6 lines

Test #63:

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

input:

100000 99999 100000
80026 50204
80026 52866
1 40664
80026 50244
80026 28855
80026 77422
80026 12672
80026 64209
1 99069
1 64511
1 85415
80026 24763
1 61598
1 94857
80026 99972
1 29460
80026 12172
1 21327
80026 19131
80026 81241
1 32924
1 37332
80026 47286
1 22738
80026 35669
80026 97849
80026 11376
...

output:

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

result:

ok 100000 lines

Test #64:

score: 0
Accepted
time: 32ms
memory: 33348kb

input:

100000 99999 66656
80026 50204
80026 52866
1 40664
80026 50244
80026 28855
80026 77422
80026 12672
80026 64209
1 99069
1 64511
1 85415
80026 24763
1 61598
1 94857
80026 99972
1 29460
80026 12172
1 21327
80026 19131
80026 81241
1 32924
1 37332
80026 47286
1 22738
80026 35669
80026 97849
80026 11376
8...

output:

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

result:

ok 66656 lines

Test #65:

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

input:

100000 99999 40150
80026 50204
80026 52866
1 40664
80026 50244
80026 28855
80026 77422
80026 12672
80026 64209
1 99069
1 64511
1 85415
80026 24763
1 61598
1 94857
80026 99972
1 29460
80026 12172
1 21327
80026 19131
80026 81241
1 32924
1 37332
80026 47286
1 22738
80026 35669
80026 97849
80026 11376
8...

output:

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

result:

ok 40150 lines

Test #66:

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

input:

100000 99999 18237
80026 50204
80026 52866
1 40664
80026 50244
80026 28855
80026 77422
80026 12672
80026 64209
1 99069
1 64511
1 85415
80026 24763
1 61598
1 94857
80026 99972
1 29460
80026 12172
1 21327
80026 19131
80026 81241
1 32924
1 37332
80026 47286
1 22738
80026 35669
80026 97849
80026 11376
8...

output:

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

result:

ok 18237 lines

Test #67:

score: 0
Accepted
time: 43ms
memory: 35496kb

input:

100000 99999 1929
80026 50204
80026 52866
1 40664
80026 50244
80026 28855
80026 77422
80026 12672
80026 64209
1 99069
1 64511
1 85415
80026 24763
1 61598
1 94857
80026 99972
1 29460
80026 12172
1 21327
80026 19131
80026 81241
1 32924
1 37332
80026 47286
1 22738
80026 35669
80026 97849
80026 11376
80...

output:

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

result:

ok 1929 lines

Test #68:

score: 0
Accepted
time: 44ms
memory: 33176kb

input:

100000 99999 212
80026 50204
80026 52866
1 40664
80026 50244
80026 28855
80026 77422
80026 12672
80026 64209
1 99069
1 64511
1 85415
80026 24763
1 61598
1 94857
80026 99972
1 29460
80026 12172
1 21327
80026 19131
80026 81241
1 32924
1 37332
80026 47286
1 22738
80026 35669
80026 97849
80026 11376
800...

output:

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

result:

ok 212 lines

Test #69:

score: 0
Accepted
time: 51ms
memory: 37112kb

input:

100000 99999 11
80026 50204
80026 52866
1 40664
80026 50244
80026 28855
80026 77422
80026 12672
80026 64209
1 99069
1 64511
1 85415
80026 24763
1 61598
1 94857
80026 99972
1 29460
80026 12172
1 21327
80026 19131
80026 81241
1 32924
1 37332
80026 47286
1 22738
80026 35669
80026 97849
80026 11376
8002...

output:

1
0
0
0
0
0
0
0
0
0
0

result:

ok 11 lines

Test #70:

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

input:

100000 99999 100000
71323 62656
67523 92668
67883 99732
43605 66117
53267 11250
53620 9853
73248 13385
17703 66469
72615 82239
21837 2920
51630 92973
12880 83004
46057 732
40254 12029
34508 50308
8475 16470
64209 88348
51612 50041
92599 90023
39030 30010
88293 64970
43994 52388
18473 54253
58657 603...

output:

12
11
0
10
19
0
0
13
0
0
0
11
10
14
12
11
0
0
0
12
9
0
6
0
12
0
11
0
14
12
0
0
9
0
0
0
0
10
16
0
0
0
7
9
0
12
12
11
13
17
9
15
0
9
0
0
0
0
6
11
11
8
8
0
11
10
0
12
7
11
0
0
11
0
12
9
0
18
0
18
18
0
0
0
14
6
0
14
16
7
0
16
10
0
12
10
0
0
12
0
0
0
0
12
12
12
0
0
14
0
0
12
11
0
7
0
0
0
11
0
12
0
0
11
9...

result:

ok 100000 lines

Test #71:

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

input:

100000 99999 66662
71323 62656
67523 92668
67883 99732
43605 66117
53267 11250
53620 9853
73248 13385
17703 66469
72615 82239
21837 2920
51630 92973
12880 83004
46057 732
40254 12029
34508 50308
8475 16470
64209 88348
51612 50041
92599 90023
39030 30010
88293 64970
43994 52388
18473 54253
58657 6039...

output:

0
0
9
14
50
1
1
0
8
0
11
0
238
110
168
11
9
2
1
8
10
0
0
165
1
84
1
1
108
135
0
30
63
7
70
11
1
0
99
7
80
40
0
88
1
144
63
56
11
0
0
1
1
72
10
0
121
2
0
13
90
2
1
120
14
0
1
13
10
1
4
9
110
63
16
1
0
8
0
1
1
0
0
35
1
13
0
48
0
196
0
10
168
9
112
14
0
0
1
13
11
0
0
10
0
2
11
4
14
2
1
1
1
1
10
12
0
4
...

result:

ok 66662 lines

Test #72:

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

input:

100000 99999 39809
71323 62656
67523 92668
67883 99732
43605 66117
53267 11250
53620 9853
73248 13385
17703 66469
72615 82239
21837 2920
51630 92973
12880 83004
46057 732
40254 12029
34508 50308
8475 16470
64209 88348
51612 50041
92599 90023
39030 30010
88293 64970
43994 52388
18473 54253
58657 6039...

output:

2
0
72
0
5
11
882
1
0
1
90
1008
1
0
1
10
0
1
1
0
14040
0
501
0
1
2520
0
1
0
0
11520
0
0
1
130
50
0
0
1
1
0
0
1
2
1
0
1
12
0
26
0
0
700
9
1
1
780
344
18
1
0
0
240
0
0
0
8
0
45
0
0
0
84
0
0
240
0
0
8
156
1080
1
0
2
1188
0
0
0
0
1
0
1
0
8064
100
0
0
0
1
1
3
0
22
1
0
0
16
0
0
1584
5616
0
0
0
10
1
1
0
1
...

result:

ok 39809 lines

Test #73:

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

input:

100000 99999 18244
71323 62656
67523 92668
67883 99732
43605 66117
53267 11250
53620 9853
73248 13385
17703 66469
72615 82239
21837 2920
51630 92973
12880 83004
46057 732
40254 12029
34508 50308
8475 16470
64209 88348
51612 50041
92599 90023
39030 30010
88293 64970
43994 52388
18473 54253
58657 6039...

output:

0
110
1512
0
0
0
1
198
3360
1
260
1
0
0
0
1
1
0
1
0
0
0
1
162
0
61
1
1
1
804
7
0
0
0
22
1
0
1
0
1
1
0
0
0
1
0
1
1
0
0
0
254
1
9
30
0
1
156
2970
0
1
0
0
7920
0
0
0
0
0
1
1
65
880
0
0
0
1
0
10
1
320
0
0
0
0
44
0
0
0
4
1
0
0
0
1
1
500
0
0
0
0
0
0
4
1
0
0
77
1
0
350
0
0
1
0
0
0
1
0
1
0
0
144
1
0
0
1
0
9...

result:

ok 18244 lines

Test #74:

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

input:

100000 99999 2009
71323 62656
67523 92668
67883 99732
43605 66117
53267 11250
53620 9853
73248 13385
17703 66469
72615 82239
21837 2920
51630 92973
12880 83004
46057 732
40254 12029
34508 50308
8475 16470
64209 88348
51612 50041
92599 90023
39030 30010
88293 64970
43994 52388
18473 54253
58657 60398...

output:

1
4
0
0
0
1
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
1
0
0
0
12
0
1
0
0
0
1
1
0
0
0
0
0
0
1
0
0
0
0
1
0
0
1
0
0
0
0
0
0
1
0
0
1
1
0
1
0
0
0
1
1
0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
1
9
1
0
0
1
0
0
20
1
0
0
0
1
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
1
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
1
0
1
0
0
1
0
0
0
0
1
0
0
0
0
0
0
0
0
0
...

result:

ok 2009 lines

Test #75:

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

input:

100000 99999 208
71323 62656
67523 92668
67883 99732
43605 66117
53267 11250
53620 9853
73248 13385
17703 66469
72615 82239
21837 2920
51630 92973
12880 83004
46057 732
40254 12029
34508 50308
8475 16470
64209 88348
51612 50041
92599 90023
39030 30010
88293 64970
43994 52388
18473 54253
58657 60398
...

output:

1
1
0
1
0
1
0
1
0
0
0
0
0
1
0
0
0
1
0
1
0
0
1
0
0
0
0
1
0
0
0
0
1
1
1
0
0
0
0
0
0
0
0
0
0
0
1
1
0
0
1
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
1
1
0
1
0
0
1
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
1
0
0
1
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
1
1
0
0
0
1
0
0
0
0
0
1
0
0
0
0
0
...

result:

ok 208 lines

Test #76:

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

input:

100000 99999 9
71323 62656
67523 92668
67883 99732
43605 66117
53267 11250
53620 9853
73248 13385
17703 66469
72615 82239
21837 2920
51630 92973
12880 83004
46057 732
40254 12029
34508 50308
8475 16470
64209 88348
51612 50041
92599 90023
39030 30010
88293 64970
43994 52388
18473 54253
58657 60398
25...

output:

1
1
1
0
0
0
0
0
0

result:

ok 9 lines

Test #77:

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

input:

100000 99999 39934
52654 43751
40425 40265
73922 20638
83588 59702
40285 45608
40282 47982
52587 77112
39551 75997
65450 26386
94100 26913
51411 5427
64007 71365
53032 46356
83889 82806
43498 93005
9310 27085
48617 44979
57709 15181
37392 92192
58743 37265
52621 42129
1543 79440
54314 36224
52767 39...

output:

0
28
0
0
0
0
88
60
465
0
0
160
10
2
0
0
0
14
2
0
2
4
0
0
80
756
2
21
0
0
13
0
0
13
0
384
0
2
0
13
2
63
2
0
8
0
2
0
0
0
0
0
0
9360
36
0
0
9
10
4950
0
3
0
0
0
0
45
0
0
0
0
630
2880
14
0
0
0
8
6
110
2
70
3
14
3402
0
0
0
490
0
2
2
0
2520
1
0
35
0
88
0
0
12672
96
2
0
0
2
15
2
0
9360
0
2
2
12
0
0
2
2
0
0
...

result:

ok 39934 lines

Test #78:

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

input:

100000 99999 39906
81596 81870
38060 21524
46033 46391
33892 3480
31637 37404
94175 11305
40200 67338
37351 93517
49822 62269
48922 91756
95118 90533
1290 51958
12623 66441
5121 8528
25858 69106
15414 86223
31192 41253
2251 90033
65919 33974
42505 87166
94131 836
91591 94910
52197 60005
66297 3964
3...

output:

0
1232
0
1
1
4212
0
0
0
1
7
1512
0
0
36
1
0
1
952
1
0
2
0
1125
0
5040
8
120
0
96
1
0
13
0
0
0
6048
1
0
132
0
0
1
54
1
0
1
0
30
3888
0
1
80
0
0
1
0
1
0
0
0
7776
1050
0
1890
0
99
0
0
1
0
0
0
0
1
1274
1000
0
2
0
0
8
70
7722
12
0
1
0
0
0
0
0
7150
0
0
792
0
3
0
0
0
0
0
10
0
308
0
12
1
0
1
360
0
1
10
0
91...

result:

ok 39906 lines

Test #79:

score: 0
Accepted
time: 53ms
memory: 38644kb

input:

100000 99999 39976
74306 80196
2814 22944
57079 4730
44626 70108
99716 78536
77026 82310
48918 8529
91212 84541
81242 11543
69459 3514
36071 9259
54537 16440
39563 61716
22236 25860
90179 38158
58382 56651
44132 41714
40685 52249
58303 51265
58009 59280
15205 68010
94100 8901
41198 21268
91959 95681...

output:

0
0
0
0
0
2
6000
1071
108
1
11
0
1
0
1
11700
0
0
120
108
0
0
0
2
0
0
396
156
0
19
2
4950
2574
1
6720
7
0
0
1
14
12240
5
0
99
0
1
1
0
13
0
9
192
0
22
8190
0
3744
1
0
594
1320
14
0
1
14
1
0
104
12
1
6720
0
0
1
12
0
0
0
2
12
20
0
0
0
8100
0
210
0
90
0
1
7
2
1
1
0
0
0
6
6
0
3
0
2
0
0
0
2058
108
0
80
540...

result:

ok 39976 lines

Test #80:

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

input:

100000 99999 100000
38713 62886
90145 68989
58044 72308
47431 68806
24723 83036
76389 7731
99902 43819
71131 16181
33402 85327
7089 74246
28138 42574
1258 68880
86706 55600
88966 79065
17617 27080
63178 24076
63657 26180
43901 51945
48377 64869
508 99204
55801 27717
82873 96195
80731 27530
48113 821...

output:

11167
8259
0
4443
0
14467
0
0
0
0
4988
0
0
15643
0
8170
11728
0
6180
0
784
15478
0
0
0
0
0
0
5684
3895
0
0
6753
0
0
0
4695
0
0
0
0
8848
9947
0
0
9460
11847
7077
9984
0
9671
10142
1180
0
0
0
0
12635
6133
0
0
0
0
0
2324
0
15768
272
0
12554
14046
0
0
8987
0
5159
0
11891
0
693
0
1936
0
0
0
0
318
3290
0
...

result:

ok 100000 lines

Test #81:

score: 0
Accepted
time: 90ms
memory: 36928kb

input:

100000 99999 66644
38713 62886
90145 68989
58044 72308
47431 68806
24723 83036
76389 7731
99902 43819
71131 16181
33402 85327
7089 74246
28138 42574
1258 68880
86706 55600
88966 79065
17617 27080
63178 24076
63657 26180
43901 51945
48377 64869
508 99204
55801 27717
82873 96195
80731 27530
48113 8217...

output:

277
11888
10108
4809
179
0
28431
2072
0
7185
7878
0
2010
5330
14097
6519
11667
10260
11070
15490
0
74207
0
14729
0
10050
7527
0
1367
88980
0
49131
43012
0
0
7365
0
0
9678
2615
2061
2740
129800
2229
2250
2247
0
6687
3826
1629
0
2706
6199
0
8788
8004
9198
0
0
1879
6090
0
1570
21772
0
170775
2123
7008
...

result:

ok 66644 lines

Test #82:

score: 0
Accepted
time: 98ms
memory: 40892kb

input:

100000 99999 39988
38713 62886
90145 68989
58044 72308
47431 68806
24723 83036
76389 7731
99902 43819
71131 16181
33402 85327
7089 74246
28138 42574
1258 68880
86706 55600
88966 79065
17617 27080
63178 24076
63657 26180
43901 51945
48377 64869
508 99204
55801 27717
82873 96195
80731 27530
48113 8217...

output:

0
8385
0
0
122192
0
70660
5330
0
0
17578
1669
0
0
0
1062
732
25182
0
5581
0
6686
11244
0
6320
0
0
66000
8104
7165
5769
0
0
103374
0
19975
0
2321
0
5599
779
0
0
0
2871
3291
4232
0
13138
41545
0
0
63600
0
5250
0
13788
9209
0
18366
0
0
61110
0
0
7126
0
3335
4234
6350
2910
0
0
4398
4682
14403
7378
9687
...

result:

ok 39988 lines

Test #83:

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

input:

100000 99999 18171
38713 62886
90145 68989
58044 72308
47431 68806
24723 83036
76389 7731
99902 43819
71131 16181
33402 85327
7089 74246
28138 42574
1258 68880
86706 55600
88966 79065
17617 27080
63178 24076
63657 26180
43901 51945
48377 64869
508 99204
55801 27717
82873 96195
80731 27530
48113 8217...

output:

136500
9541
0
0
834
2540
0
858
28392
0
1645
0
10179
43920
3144
2947
133380
668304
0
0
403368
0
13664
27215
0
12341
21216
496800
1305
3179
2758
31464
0
332
0
5730
0
2120
6304
1698
0
38456
595
0
1218
8192
0
6507
0
1171
0
6035
204
4155
2485
705
22560
9752
108376
0
0
72135
1775
1046
27972
0
0
2490
3704
...

result:

ok 18171 lines

Test #84:

score: 0
Accepted
time: 101ms
memory: 40828kb

input:

100000 99999 1970
38713 62886
90145 68989
58044 72308
47431 68806
24723 83036
76389 7731
99902 43819
71131 16181
33402 85327
7089 74246
28138 42574
1258 68880
86706 55600
88966 79065
17617 27080
63178 24076
63657 26180
43901 51945
48377 64869
508 99204
55801 27717
82873 96195
80731 27530
48113 82177...

output:

0
3240
2982
0
944
0
0
837
0
131
79
25350
0
14025
32994
42
0
3860
146
2286
349
9366
0
5
0
1072
0
915
32
1312
4060
18
4340
4020
197
1475
6012
2988
2785
2256
16908
2085
14880
0
241
855
0
1602
109382
33890
10185
89
24
0
2565
155
0
195
0
0
0
99792
1967
241
518
6288
321
0
0
882
94
1735
26910
3960
22036
16...

result:

ok 1970 lines

Test #85:

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

input:

100000 99999 200
38713 62886
90145 68989
58044 72308
47431 68806
24723 83036
76389 7731
99902 43819
71131 16181
33402 85327
7089 74246
28138 42574
1258 68880
86706 55600
88966 79065
17617 27080
63178 24076
63657 26180
43901 51945
48377 64869
508 99204
55801 27717
82873 96195
80731 27530
48113 82177
...

output:

0
1980
5
504
11
79
152
581
192
0
18
5148
240
0
0
43
0
0
58842
0
0
267
96
380
510
20640
14
125
0
2052
18
70
950
3136
600
11
324
20
0
53
602
56
116
16
45
37
0
44
0
65
144
23
170
42
135
14
48
486
176
156
0
0
353
16
1
120
12512
180
7360
0
36
23058
110
31
2872
30240
1404
0
24
5040
528
35
0
0
8
110
216
48...

result:

ok 200 lines

Test #86:

score: 0
Accepted
time: 101ms
memory: 44620kb

input:

100000 99999 8
38713 62886
90145 68989
58044 72308
47431 68806
24723 83036
76389 7731
99902 43819
71131 16181
33402 85327
7089 74246
28138 42574
1258 68880
86706 55600
88966 79065
17617 27080
63178 24076
63657 26180
43901 51945
48377 64869
508 99204
55801 27717
82873 96195
80731 27530
48113 82177
27...

output:

0
135
1012
0
199346
0
335664
0

result:

ok 8 lines

Test #87:

score: 0
Accepted
time: 102ms
memory: 41164kb

input:

100000 99999 39812
42864 30628
21291 37783
51013 73694
7043 26968
87375 65178
8082 31171
95946 80616
55879 98405
57639 55482
58303 26178
26617 57210
88396 37011
19938 21337
73411 93845
86400 89516
75005 44714
79846 14065
4483 3639
53763 36101
44097 2707
52902 80349
60441 80169
80571 71806
55954 3933...

output:

9489
25896
0
2149
0
0
18990
580
6758
11653
0
0
10222
127886
9188
474
0
0
11157
0
0
24896
0
0
0
3810
0
1910
0
0
16238
2348
13393
9837
6266
0
0
97591
24854
0
0
0
0
50400
11611
0
5242
34830
0
33216
8107
5138
828
17955
38340
0
20352
43820
33168
5554
542
3492
114656
0
0
1767
32784
2826
0
0
0
0
0
0
15062
...

result:

ok 39812 lines

Test #88:

score: 0
Accepted
time: 99ms
memory: 41460kb

input:

100000 99999 39857
48879 92492
26558 26709
79059 21134
97937 87419
84586 942
57298 40966
84618 74494
78472 29723
52907 78228
92631 74459
74102 20221
89835 91567
32391 63397
42384 62294
47337 54266
54808 83800
42630 55760
9427 10631
37538 34519
17980 38734
39871 46152
12045 45708
43791 61168
34255 72...

output:

9845
1719
20692
10704
0
0
11674
0
0
119
31952
34497
0
2198
15888
6180
0
3645
0
0
15744
0
19824
0
0
43158
0
5444
0
11299
4716
7399
496
34764
2833
392
0
6115
0
0
6022
2618
0
865
1877
4465
0
249655
0
833
0
0
18888
337250
0
33666
16214
0
210
0
0
0
15235
2726
5536
160
31400
3999
13116
0
0
180420
0
0
7711...

result:

ok 39857 lines

Test #89:

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

input:

100000 99999 40118
97853 27947
20885 51663
50245 33672
50573 68189
71859 60816
51950 15001
43021 28248
66280 34931
16326 6261
37443 36510
6151 13681
72497 53944
16768 14614
27600 72506
83910 54783
14147 46253
82237 44493
54847 67658
34417 65424
22299 23104
74818 58613
38845 96760
34407 6567
25021 49...

output:

0
1453
0
0
0
29913
0
0
0
0
0
7855
846
19106
0
0
0
0
0
5989
28155
4505
1047
0
729912
421344
81804
0
0
0
0
0
4516
0
0
15460
0
8488
0
723008
4143
530
2475
0
0
1715
8448
44304
0
2865
12444
51696
0
0
0
0
0
0
4622
0
171
0
0
0
5961
6188
88578
8744
0
9868
87840
0
4844
1812
15992
0
0
9051
63840
0
0
4836
0
15...

result:

ok 40118 lines