QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#431413#6452. Ski ResortbdzzjWA 1841ms42264kbC++146.4kb2024-06-05 15:10:532024-06-05 15:10:53

Judging History

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

  • [2024-06-05 15:10:53]
  • 评测
  • 测评结果:WA
  • 用时:1841ms
  • 内存:42264kb
  • [2024-06-05 15:10:53]
  • 提交

answer

#include<bits/stdc++.h>
#define N 100005
#define ll long long
using namespace std;
int n,m,Q,len,d[N],dep[N],fa[N][20],siz[N],dfn[N],rk[N],son[N],top[N],cnt,st[N],b[N],dis[200][200],lc[200][200];
ll dp[N][5],to[200];
vector<int> g0[N],g[N],gx[N];
queue<int> q;
vector<pair<int,int>> e;
inline int lca(int u,int v){
    if(dep[u]<dep[v]) swap(u,v);
    for(int i=19;i>=0;i--){
        if(dep[fa[u][i]]>=dep[v]){
            u=fa[u][i];
        }
    }
    if(u==v) return u;
    for(int i=19;i>=0;i--){
        if(fa[u][i]!=fa[v][i]){
            u=fa[u][i];
            v=fa[v][i];
        }
    }
    return fa[u][0];
}
void dfs1(int x){
    siz[x]=1;
    for(int v:g[x]){
        dfs1(v);
        siz[x]+=siz[v];
        if(siz[v]>siz[son[x]]) son[x]=v;
    }
    return;
}
void dfs2(int x,int tops){
    top[x]=tops;
    rk[dfn[x]=++cnt]=x;
    if(son[x]) dfs2(son[x],tops);
    for(int v:g[x]){
        if(v==son[x]) continue;
        dfs2(v,v);
    }
    return;
}
namespace tree{
    int tree[N<<2],tag[N<<2];
    inline void pushup(int rt){
        tree[rt]=tree[rt<<1]+tree[rt<<1|1];
        return;
    }
    inline void upd(int rt,int l,int r,int t){
        tree[rt]=(r-l+1)*t;
        tag[rt]=t;
        return;
    }
    inline void pushdown(int rt,int l,int r){
        if(tag[rt]!=-1){
            int mid=(l+r)>>1;
            upd(rt<<1,l,mid,tag[rt]);
            upd(rt<<1|1,mid+1,r,tag[rt]);
            tag[rt]=-1;
        }
        return;
    }
    void updata(int rt,int l,int r,int L,int R,int t){
        if(L<=l&&r<=R){
            upd(rt,l,r,t);
            return;
        }
        pushdown(rt,l,r);
        int mid=(l+r)>>1;
        if(L<=mid) updata(rt<<1,l,mid,L,R,t);
        if(R>=mid+1) updata(rt<<1|1,mid+1,r,L,R,t);
        pushup(rt);
        return;
    }
    int query(int rt,int l,int r,int L,int R){
        if(L<=l&&r<=R) return tree[rt];
        pushdown(rt,l,r);
        int mid=(l+r)>>1,ans=0;
        if(L<=mid) ans+=query(rt<<1,l,mid,L,R);
        if(R>=mid+1) ans+=query(rt<<1|1,mid+1,r,L,R);
        return ans;
    }
}
inline void updata(int u,int v){
    while(dep[top[u]]>dep[v]){
        tree::updata(1,1,n,dfn[top[u]],dfn[u],0);
        u=fa[top[u]][0];
    }
    if(u!=v) tree::updata(1,1,n,dfn[v]+1,dfn[u],0);
    return;
}
inline int query(int u,int v){
    int ans=0;
    while(dep[top[u]]>dep[v]){
        ans+=tree::query(1,1,n,dfn[top[u]],dfn[u]);
        u=fa[top[u]][0];
    }
    if(u!=v) ans+=tree::query(1,1,n,dfn[v]+1,dfn[u]);
    return ans;
}
namespace tree2{
    int c[N];
    inline void add(int x,int val){
        for(int i=x;i<=n;i+=i&-i) c[i]+=val;
        return;
    }
    inline int ask(int l,int r){
        int ans=0;
        for(int i=r;i;i-=i&-i) ans+=c[i];
        for(int i=l-1;i;i-=i&-i) ans-=c[i];
        return ans;
    }
}
inline bool cmp(int a,int b){return dfn[a]<dfn[b];}
void dfs3(int x,int fa){
    for(int i=0;i<=4;i++) dp[x][i]=0;
    if(!b[x]){
        dp[x][0]=1;
        for(int v:gx[x]){
            dfs3(v,x);
            ll dp0[5]={0,0,0,0,0};
            for(int i=0;i<=4;i++){
                for(int j=0;j+i<=4;j++){
                    dp0[j+i]+=dp[x][i]*dp[v][j];
                }
            }
            for(int i=0;i<=4;i++) dp[x][i]=dp0[i];
        }
    }
    dp[x][1]+=query(x,fa);
    return;
}
void clears(int x){
    for(int v:gx[x]) clears(v);
    gx[x].clear();
    return;
}
int main(){
//    freopen("lodge.in","r",stdin);
//    freopen("lodge.out","w",stdout);
    scanf("%d%d%d",&n,&m,&Q);
    for(int i=1;i<=m;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        g0[u].push_back(v);
        d[v]++;
    }
    q.push(1);
    while(!q.empty()){
        int x=q.front();
        q.pop();
        dep[x]=dep[fa[x][0]]+1;
        for(int i=1;i<20;i++) fa[x][i]=fa[fa[x][i-1]][i-1];
        for(int v:g0[x]){
            if(fa[v][0]) fa[v][0]=lca(x,fa[v][0]);
            else fa[v][0]=x;
            if(!(--d[v])) q.push(v);
        }
    }
    for(int i=1;i<=n;i++) if(fa[i][0]) g[fa[i][0]].push_back(i);
    dfs1(1);
    dfs2(1,1);
    for(int u=1;u<=n;u++){
        for(int v:g0[u]){
            if(lca(u,v)!=u){
                e.push_back(make_pair(u,v));
            }
        }
    }
    int len=e.size();
    for(int i=0;i<len;i++){
        for(int j=0;j<len;j++){
            int u=e[i].second,v=e[j].first;
            if(i==j||(dfn[u]<=dfn[v]&&dfn[v]<=dfn[u]+siz[u]-1)){
                dis[i][j]=1;
            }
        }
    }
    for(int k=0;k<len;k++){
        for(int i=0;i<len;i++){
            for(int j=0;j<len;j++){
                dis[i][j]|=dis[i][k]&dis[k][j];
            }
        }
    }
    for(int i=0;i<len;i++){
        for(int j=0;j<len;j++){
            if(dis[i][j]) to[i]|=1LL<<j;
            lc[i][j]=lca(e[i].first,e[j].second);
        }
    }
    for(int T=1;T<=Q;T++){
        int k,m;
        scanf("%d%d",&k,&m);
        vector<int> v={};
        for(int i=1;i<=m;i++){
            int x;
            scanf("%d",&x);
            v.push_back(x);
        }
        sort(v.begin(),v.end(),cmp);
        for(int i:v) tree2::add(dfn[i],1);
        tree::updata(1,1,n,1,n,1);
        ll sta=0;
        for(int i=0;i<len;i++){
            int u=e[i].second;
            if(tree2::ask(dfn[u],dfn[u]+siz[u]-1)){
                sta|=1LL<<i;
            }
        }
        for(int i=0;i<len;i++){
            int f=0;
            for(int j=0;j<len;j++){
                if((sta&to[i])>>j&1){
                    if(!f) f=lc[i][j];
                    else if(dep[lc[i][j]]<f) f=lc[i][j];
                }
            }
            if(f) updata(e[i].first,f);
        }
        for(int i:v) tree2::add(dfn[i],-1);
        int top=0;
        st[++top]=1;
        for(int i:v){
            if(i==1) continue;
            while(top>=2&&dep[lca(i,st[top])]<=dep[st[top-1]]){
                gx[st[top-1]].push_back(st[top]);
                top--;
            }
            int l=lca(i,st[top]);
            if(l!=st[top]){
                gx[l].push_back(st[top]);
                top--;
                st[++top]=l;
            }
            st[++top]=i;
        }
        for(int i=1;i<top;i++) gx[st[i]].push_back(st[i+1]);
        for(int i:v) b[i]=1;
        dfs3(1,0);
        printf("%lld\n",dp[1][k]);
        clears(1);
        for(int i:v) b[i]=0;
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 4ms
memory: 18228kb

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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: 22ms
memory: 14360kb

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

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

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

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

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: 127ms
memory: 38120kb

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: 122ms
memory: 39024kb

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: 94ms
memory: 38180kb

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: 89ms
memory: 38900kb

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: 67ms
memory: 39660kb

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: 133ms
memory: 38240kb

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: 132ms
memory: 36416kb

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: 134ms
memory: 35432kb

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: 131ms
memory: 36928kb

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: 119ms
memory: 36768kb

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: 98ms
memory: 38268kb

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: 65ms
memory: 38648kb

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: 144ms
memory: 38288kb

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: 118ms
memory: 38172kb

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: 93ms
memory: 38268kb

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: 81ms
memory: 39540kb

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: 57ms
memory: 37976kb

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: 129ms
memory: 38124kb

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: 135ms
memory: 37732kb

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: 407ms
memory: 38120kb

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: 396ms
memory: 37960kb

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: 156ms
memory: 42264kb

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

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
1428
1287
8514
9442
556
8514
8514
4752
15871
8514
12411
9102
11851
8514
8514
8514
8514
8979
9141
8514
8709
8514
1567
1428
8514
1703
9053
3296
10196
1428
11607
8514
19339
211
8514
1428
10571
8514
8514
8514
8514
8514
8514
8514
8514
1864
8514
10394
8514
5294
18336
3504
8514
12816
9326
1474
1890
9...

result:

wrong answer 2nd lines differ - expected: '9429', found: '1428'