QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#425821#6452. Ski ResortlmeowdnWA 266ms59044kbC++144.5kb2024-05-30 17:18:302024-05-30 17:18:30

Judging History

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

  • [2024-05-30 17:18:30]
  • 评测
  • 测评结果:WA
  • 用时:266ms
  • 内存:59044kb
  • [2024-05-30 17:18:30]
  • 提交

answer

//Shirasu Azusa 2024.5
#include <bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define mp make_pair
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 i128;
template<class T,class S>
bool chmax(T &a,const S b) {return (a<b?a=b,1:0);}
template<class T,class S>
bool chmin(T &a,const S b) {return (a>b?a=b,1:0);}
int popcnt(int x) {return __builtin_popcount(x);}
int popcnt(ll x)  {return __builtin_popcountll(x);}
int topbit(int x) {return (x==0?-1:31-__builtin_clz(x));}
int topbit(ll x)  {return (x==0?-1:63-__builtin_clzll(x));}
int lowbit(int x) {return (x==0?-1:__builtin_ctz(x));}
int lowbit(ll x)  {return (x==0?-1:__builtin_ctzll(x));}

#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
typedef pair<int,int> pii;  
typedef vector<int> vi;
typedef vector<pii> vp;
typedef tuple<int,int,int> tiii;
int read() {
  int x=0,w=1; char c=getchar(); 
  while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
  while(isdigit(c)) {x=x*10+(c-'0'); c=getchar();} 
  return x*w;
}

const int N=1e5+5;
int n,m,q,p[N],deg[N],fa[N][22],d[N],dfn[N],tick,b[N],sz[N],f[N][7],K,L;
vi e[N],r[N],t[N],g[N];

namespace Reach {
  int vst[N],dfn[N],tick,sz[N]; bool rt[N];
  vi p; bitset<N> fr[55],to[55];
  void dfs(int u) {
    dfn[u]=++tick, sz[u]=1; vst[u]=1;
    for(int v:e[u]) {
      if(vst[v]) rt[u]=1;
      else dfs(v), sz[u]+=sz[v];
    }
  }
  void work(int d,int s) {
    queue<int>q; fr[d][s]=1; q.push(s);
    while(!q.empty()) {
      int u=q.front(); q.pop();
      for(int v:e[u]) if(!fr[d][v]) fr[d][v]=1, q.push(v);
    } to[d][s]=1; q.push(s);
    while(!q.empty()) {
      int u=q.front(); q.pop();
      for(int v:r[u]) if(!to[d][v]) to[d][v]=1, q.push(v);
    }
  }
  bool reach(int x,int y) {
    if(dfn[x]<=dfn[y]&&dfn[y]<dfn[x]+sz[x]) return 1;
    rep(i,0,(int)p.size()-1) if(fr[i][y]&&to[i][x]) return 1;
    return 0;
  }
  void init() {
    dfs(1);
    rep(i,1,n) if(rt[i]) p.eb(i);
    rep(i,0,(int)p.size()-1) work(i,p[i]);
  }
} using Reach::reach;

int lca(int x,int y) {
  if(d[x]<d[y]) swap(x,y); if(!x||!y) return x+y;
  per(h,18,0) if(d[fa[x][h]]>=d[y]) x=fa[x][h];
  per(h,18,0) if(fa[x][h]!=fa[y][h]) x=fa[x][h], y=fa[y][h];
  return x==y?x:fa[x][0];
}
int climb(int x,int y) {
  per(h,18,0) if(y&(1<<h)) x=fa[x][h]; return x;
}
void buildom() {
  queue<int>q; q.push(1); d[1]=1;
  while(!q.empty()) {
    int u=q.front(); q.pop();
    d[u]=d[fa[u][0]]+1, t[fa[u][0]].eb(u);
    rep(h,1,20) fa[u][h]=fa[fa[u][h-1]][h-1];
    for(int v:e[u]) {
      fa[v][0]=lca(fa[v][0],u);
      if(!--deg[v]) q.push(v);
    }
  }
}
void dfs(int u) {
  dfn[u]=++tick, sz[u]=1;
  for(int v:t[u]) dfs(v), sz[u]+=sz[v];
}
bool cmp(const int &x,const int &y) {return dfn[x]<dfn[y];}
bool chk(int x) {
  //cout<<"chk "<<x<<" "<<L<<endl;
  for(int y:g[L]) {
    //cout<<"         "<<y<<" "<<reach(x,y)<<endl;
    if(dfn[y]<=dfn[x]&&dfn[x]<dfn[y]+sz[y]) continue;
    else if(dfn[x]<=dfn[y]&&dfn[y]<dfn[x]+sz[x]) continue;
    else if(reach(x,y)) return 0;
  } return 1;
}
void dfs2(int u,int faa,int tp=0) {
  //cout<<"DFSX "<<u<<" "<<faa<<endl;
  rep(i,0,K) f[u][i]=0; f[u][0]=1; int resu=(u==L?0:chk(u));
  if(!b[u]) {
    for(int v:g[u]) {
      dfs2(v,u,resu);
      static int h[10];
      rep(i,0,K) h[i]=0;
      rep(i,0,K) rep(j,1,K-i) h[i+j]+=f[u][i]*f[v][j];
      rep(i,0,K) f[u][i]=h[i];
    }
  }
  if(tp) {
    f[u][1]+=d[u]-d[faa];
  } else if(resu||u==L) {
    int x=u;
    per(h,18,0) if(d[fa[x][h]]>d[faa]) {
      if(chk(fa[x][h])) x=fa[x][h];
    }
    f[u][1]+=d[u]-d[x]+1;
  }
  //cout<<u<<" "<<f[u][0]<<" "<<f[u][1]<<" "<<f[u][2]<<endl;
}
int work() {
  int k=read(), m=read(); L=0; vi ykn,ako; K=k;
  rep(i,1,m) {int u=read(); L=lca(L,u); ykn.eb(u);}
  if(k==1) return d[L];
  for(int u:ykn) if(u==L) return 0;
  sort(ykn.begin(),ykn.end(),cmp);
  rep(i,0,m-2) ako.eb(lca(ykn[i],ykn[i+1]));
  rep(i,0,m-1) ako.eb(ykn[i]), b[ykn[i]]=1;
  sort(ako.begin(),ako.end(),cmp);
  ako.resize(m=unique(ako.begin(),ako.end())-ako.begin());
  for(int x:ako) g[x].clear();
  rep(i,1,m-1) g[lca(ako[i-1],ako[i])].eb(ako[i]);
  if(g[L].size()>k) return 0; dfs2(L,L);
  for(int x:ako) b[x]=0; return f[L][k];
}

signed main() {
  n=read(), m=read(), q=read();
  rep(i,1,m) {
    int u=read(), v=read();
    e[u].eb(v), r[v].eb(u);
    deg[v]++;
  }
  Reach::init();
  buildom(); dfs(1);
  rep(i,1,q) printf("%lld\n",work());
  return 0;
}

詳細信息

Test #1:

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

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: 0ms
memory: 18128kb

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: 22476kb

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: 2ms
memory: 20436kb

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: 4ms
memory: 22180kb

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: 5ms
memory: 22268kb

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: 24180kb

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: 3ms
memory: 22188kb

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: 0ms
memory: 18056kb

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: 3ms
memory: 20256kb

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: 2ms
memory: 24172kb

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: 24232kb

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: 3ms
memory: 18180kb

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: 20168kb

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: 18152kb

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: 29ms
memory: 22216kb

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: 24584kb

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: 4ms
memory: 22144kb

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: 5ms
memory: 22184kb

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: 5ms
memory: 20224kb

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: 139ms
memory: 54216kb

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: 141ms
memory: 54604kb

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: 136ms
memory: 55300kb

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: 141ms
memory: 54668kb

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: 128ms
memory: 57404kb

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: 150ms
memory: 54228kb

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: 204ms
memory: 53640kb

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: 166ms
memory: 52156kb

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: 155ms
memory: 52984kb

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: 162ms
memory: 54240kb

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: 162ms
memory: 52224kb

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: 90ms
memory: 49068kb

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: 99ms
memory: 57624kb

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: 124ms
memory: 57240kb

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: 112ms
memory: 59044kb

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: 117ms
memory: 58588kb

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: 69ms
memory: 57012kb

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: 125ms
memory: 56616kb

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: 182ms
memory: 55864kb

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: 159ms
memory: 57680kb

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: 160ms
memory: 57848kb

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: 92ms
memory: 56536kb

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: 181ms
memory: 54024kb

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: 256ms
memory: 55352kb

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: 266ms
memory: 55980kb

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: 244ms
memory: 56004kb

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: 241ms
memory: 56796kb

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: 217ms
memory: 56324kb

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: 53ms
memory: 43240kb

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: 61ms
memory: 48932kb

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: 84ms
memory: 48328kb

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: 110ms
memory: 48328kb

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: 99ms
memory: 49380kb

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: 115ms
memory: 49496kb

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: 68ms
memory: 50500kb

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: 44ms
memory: 45240kb

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: 60ms
memory: 47672kb

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: -100
Wrong Answer
time: 64ms
memory: 48540kb

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:

wrong answer 6783rd lines differ - expected: '4', found: '0'