QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#585652#9260. Raiffeisenbank Logisticsucup-team3474#TL 748ms117328kbC++202.5kb2024-09-23 21:40:242024-09-23 21:40:24

Judging History

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

  • [2024-09-23 21:40:24]
  • 评测
  • 测评结果:TL
  • 用时:748ms
  • 内存:117328kb
  • [2024-09-23 21:40:24]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=5e5+10,mod=998244353;
typedef long long ll;
typedef pair<ll,ll> PII;
ll n,m,k;
ll a[N],b[N];
char s[N];

typedef struct{
    int to,val,w,val2;
}Node;

vector<Node> e[N];
int q[N];

vector<int> ee[N];

vector<int> mp[N];
vector<int> tf[N];

void __(){
    cin>>n>>m;
    for(int i=1;i<=n;i++) e[i].clear(),mp[i].clear(),ee[i].clear(),tf[i].clear();
    // mp.clear();
    deque<array<int,3>> q;
    for(int i=1;i<=m;i++){
        int u,v,w;
        cin>>u>>v>>w;
        e[u].push_back({v,w,0});
        e[v].push_back({u,w,1});
        ee[u].push_back(w);
        ee[v].push_back(w);
    }
    ee[1].push_back(-1);
    for(int i=1;i<=n;i++){
        sort(ee[i].begin(),ee[i].end());
        ee[i].erase(unique(ee[i].begin(),ee[i].end()),ee[i].end());
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=e[i].size();j++) mp[i].push_back(1e9),tf[i].push_back(0);
    }
    for(int i=1;i<=n;i++){
        for(auto &[to,val,w,val2]:e[i])
        {
             int tts=lower_bound(ee[to].begin(),ee[to].end(),val)-
             ee[to].begin();
             val2=tts;   

        }
    }
    mp[1][0]=0;
    tf[1][0]=1;
    q.push_back({1,-1,0});
    while(q.size()){
        auto t=q.front();
        q.pop_front();
        int ts=lower_bound(ee[t[0]].begin(),ee[t[0]].end(),t[1])-ee[t[0]].begin();
        // cout<<t[0]<<" "<<t
        // cout<<t[0]<<" "<<t[1]<<" "<<t[2]<<endl;
        for(auto [to,val,w,val2]:e[t[0]]){
            if(val<=t[1]) continue;
            if(w==0){
               array<int,3> tt={to,val,w};
                int tts=val2;
                // if(mp.count(tt)) continue;
                if(mp[tt[0]][tts]>t[2]){
                mp[tt[0]][tts]=t[2];
                tf[tt[0]][tts]=1;
                tt[2]=t[2];
                q.push_front(tt);
                }
            }else{
               array<int,3> tt={to,val,w};
               int tts=val2;
                if(mp[tt[0]][tts]>t[2]+1){
                mp[tt[0]][tts]=t[2]+1;
                tf[tt[0]][tts]=1;
                tt[2]=t[2]+1;
                q.push_front(tt);
                }
            }
        }
    }
    int ans=1e9+8;
    for(auto v:mp[n]){
        ans=min(v,ans);
    }
    if(ans>1e8) cout<<-1<<"\n";
    else cout<<ans<<"\n";

}


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int _;
    cin>>_;
    while(_--){
        __();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 0
Accepted
time: 2ms
memory: 3548kb

input:

2
4 3
2 1 1
2 3 2
4 3 2
8 9
1 2 5
2 3 10
4 3 15
4 5 20
5 8 25
1 6 2
6 5 30
7 6 3
8 7 4

output:

-1
1

result:

ok 2 number(s): "-1 1"

Test #3:

score: 0
Accepted
time: 2ms
memory: 3576kb

input:

8
2 1
1 2 1
2 1
2 1 1
2 1
1 1 1
2 1
2 2 1
2 1
1 2 1000000000
2 1
2 1 1000000000
2 1
1 1 1000000000
2 1
2 2 1000000000

output:

0
1
-1
-1
0
1
-1
-1

result:

ok 8 numbers

Test #4:

score: 0
Accepted
time: 2ms
memory: 3808kb

input:

1
2 1
1 2 1

output:

0

result:

ok 1 number(s): "0"

Test #5:

score: 0
Accepted
time: 2ms
memory: 3568kb

input:

1000
10 10
1 2 1
2 4 1
6 1 1
3 8 1
7 2 1
3 2 1
1 4 1
2 6 1
9 4 1
10 7 1
10 10
4 7 1
10 2 1
8 2 1
9 1 1
1 9 1
4 4 1
10 2 1
4 7 1
8 2 1
9 9 1
10 10
7 5 1
2 2 1
8 7 1
10 9 1
2 7 1
4 6 1
4 1 1
1 2 1
3 8 1
2 1 1
10 10
6 10 1
4 7 1
10 9 1
4 8 1
1 1 1
1 1 1
1 7 1
2 1 1
6 9 1
3 10 1
10 10
6 1 1
9 8 1
8 8 1
...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
0
-1
-1
-1
1
-1
-1
-1
-1
-1
1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
0
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
0
-1
-1
-1
0
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
0
-1
-1
-1
-1
-1
-1
0
1
-1
-1
-1
-1
-1
-1
0
-1
-1
-1
-1
-1
1
-1
-1
0
-1
1
-1
-1
-...

result:

ok 1000 numbers

Test #6:

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

input:

1000
10 10
4 10 2
2 3 2
6 8 2
4 5 2
7 3 2
3 7 1
4 4 2
1 9 2
2 4 1
8 2 2
10 10
2 4 1
7 1 1
8 3 1
3 1 2
6 1 2
8 4 1
2 9 2
6 9 1
5 7 1
10 4 1
10 10
9 6 2
9 6 1
5 8 1
10 1 1
9 2 2
3 5 1
6 9 2
1 2 2
5 10 1
8 7 1
10 10
5 7 1
9 2 1
7 7 1
8 6 1
4 6 2
8 8 1
5 10 2
2 10 2
9 1 2
7 7 1
10 10
2 7 2
10 2 1
5 1 2
...

output:

-1
-1
1
-1
1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1
-1
1
-1
-1
-1
1
-1
0
0
-1
-1
-1
-1
1
1
-1
-1
-1
1
1
-1
-1
-1
-1
1
-1
1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1
-1
1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
0
-1
0
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
0
-1
-1
0
-1
-1
1
0
0
1
-1
-1
-1
-1
1
-1
-1
-1
-1
...

result:

ok 1000 numbers

Test #7:

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

input:

1000
10 10
7 10 3
5 5 1
4 9 2
3 4 2
1 4 3
9 6 3
10 1 2
5 10 1
10 8 1
1 7 1
10 10
10 1 1
4 7 3
10 7 2
10 10 2
3 10 1
5 10 2
6 2 3
2 1 3
5 1 1
1 6 2
10 10
6 2 2
7 3 3
5 5 3
5 6 2
6 5 1
7 10 3
9 9 1
5 6 3
4 9 3
4 1 1
10 10
6 4 1
9 7 1
6 7 3
7 10 3
8 8 2
3 1 1
6 7 1
10 3 2
1 2 1
8 1 1
10 10
2 9 2
8 3 3
...

output:

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

result:

ok 1000 numbers

Test #8:

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

input:

1000
10 10
1 7 1
9 7 4
10 8 4
8 1 10
7 8 6
1 6 8
10 9 10
4 4 8
3 6 8
1 2 10
10 10
5 9 5
3 7 7
4 6 3
1 7 4
2 7 10
6 4 2
7 6 4
8 3 3
2 10 1
7 8 2
10 10
7 8 3
7 8 5
4 9 7
4 2 6
5 10 4
4 6 3
4 1 4
4 10 4
2 7 4
9 2 1
10 10
4 6 8
8 10 2
5 6 8
5 7 9
5 10 6
6 7 5
7 9 2
8 7 10
10 10 5
10 9 10
10 10
9 9 10
1 ...

output:

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

result:

ok 1000 numbers

Test #9:

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

input:

1000
10 10
5 3 21
1 6 60
3 10 31
7 9 51
10 7 64
5 6 85
3 4 85
5 1 7
5 3 52
1 7 17
10 10
1 1 90
2 9 78
9 2 82
9 9 29
2 7 67
8 8 44
7 9 87
8 3 3
9 5 32
5 8 15
10 10
2 8 22
3 2 97
7 7 34
1 6 43
5 9 24
4 7 35
3 3 48
9 4 33
5 10 93
1 7 65
10 10
5 4 85
5 1 40
8 9 48
7 1 57
10 10 69
2 2 69
6 4 14
8 4 43
10...

output:

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

result:

ok 1000 numbers

Test #10:

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

input:

1000
10 10
10 10 268155137
5 10 540061009
1 10 110627680
1 4 533692575
3 5 10438095
6 7 730490278
6 2 985939776
8 10 500039201
1 9 185735931
4 2 729538420
10 10
8 1 326383784
5 3 726281100
4 6 279162422
4 4 243297959
1 2 984988531
3 10 856724546
2 4 627158366
4 5 880246199
9 1 675003875
7 7 76366643...

output:

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

result:

ok 1000 numbers

Test #11:

score: 0
Accepted
time: 5ms
memory: 3584kb

input:

1000
10 20
8 8 1
5 1 1
5 3 1
2 4 1
6 9 1
10 7 1
6 10 1
4 4 1
7 7 1
2 10 1
1 8 1
7 6 1
4 1 1
6 4 1
6 1 1
8 6 1
4 6 1
9 3 1
4 2 1
4 10 1
10 20
9 10 1
8 1 1
3 1 1
3 6 1
7 1 1
2 2 1
2 10 1
8 5 1
8 2 1
2 1 1
4 9 1
3 8 1
2 10 1
1 7 1
7 2 1
3 6 1
10 1 1
9 6 1
7 5 1
4 3 1
10 20
9 3 1
9 1 1
9 3 1
10 10 1
9 1...

output:

-1
1
-1
0
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1
0
-1
-1
-1
-1
-1
-1
0
1
-1
-1
-1
-1
-1
0
1
-1
0
-1
-1
-1
-1
0
0
1
1
-1
1
-1
-1
-1
0
-1
0
-1
-1
-1
1
-1
-1
1
-1
-1
1
0
-1
-1
0
0
-1
-1
-1
0
-1
-1
-1
-1
-1
1
-1
-1
-1
1
1
1
0
-1
-1
-1
-1
-1
1
1
-1
1
-1
-1
-1
0
1
1
0
-1
-1
-1
-1
-1
0
0
-1
-1
-1
-1
0
-1
0
...

result:

ok 1000 numbers

Test #12:

score: 0
Accepted
time: 5ms
memory: 3632kb

input:

1000
10 20
6 1 2
6 7 2
9 3 2
2 6 2
1 5 2
9 8 2
2 2 1
5 10 2
8 5 2
4 2 1
2 10 2
8 7 1
8 7 2
8 10 1
3 8 2
3 10 2
4 9 2
5 8 1
8 7 2
7 4 2
10 20
6 9 1
10 6 2
7 9 1
8 1 1
4 7 2
10 10 1
9 8 2
3 1 2
2 2 1
5 7 2
8 7 1
1 8 2
8 2 1
5 5 2
5 1 2
3 1 2
4 9 1
7 2 2
1 6 2
3 1 1
10 20
10 3 2
9 4 2
10 6 2
8 7 1
8 6 ...

output:

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

result:

ok 1000 numbers

Test #13:

score: 0
Accepted
time: 5ms
memory: 3648kb

input:

1000
10 20
8 3 1
7 8 3
8 5 3
3 10 3
4 10 2
3 3 3
7 4 1
8 5 1
4 8 3
6 9 3
2 3 1
10 8 1
5 9 3
4 4 3
9 8 2
8 3 1
6 4 1
10 8 1
10 3 1
1 7 2
10 20
1 10 3
9 3 3
1 7 1
2 2 2
8 6 2
9 6 2
3 8 3
8 1 2
7 4 1
7 9 3
10 1 3
9 6 2
6 3 2
6 8 2
8 3 1
2 4 2
5 4 1
3 10 1
5 3 1
2 3 3
10 20
7 6 2
2 2 2
9 6 1
3 8 2
5 7 1...

output:

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

result:

ok 1000 numbers

Test #14:

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

input:

1000
10 20
4 4 7
8 2 9
9 8 2
4 4 7
9 4 8
4 2 10
2 1 8
3 5 10
8 8 8
5 7 9
5 3 2
4 9 7
5 3 2
1 6 5
3 1 10
4 7 4
9 3 4
4 7 7
5 8 8
8 10 1
10 20
6 1 10
8 2 10
4 5 2
6 4 10
1 6 8
8 9 8
6 7 10
8 2 9
1 3 4
6 4 1
5 1 3
4 8 4
1 7 7
5 3 7
1 9 2
9 2 5
5 6 3
2 5 8
1 4 10
3 9 5
10 20
2 7 6
4 8 3
6 4 9
1 4 10
10 ...

output:

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

result:

ok 1000 numbers

Test #15:

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

input:

1000
10 20
2 4 98
7 8 21
7 1 36
6 1 61
4 2 77
1 3 60
5 4 6
6 6 9
4 4 7
7 10 76
4 6 49
6 3 44
3 10 23
9 4 12
7 5 15
2 1 7
3 3 83
4 7 79
8 1 93
10 6 96
10 20
5 5 31
3 8 37
8 8 59
1 8 33
1 9 94
7 7 73
1 9 24
10 3 97
9 5 36
3 1 73
6 3 46
4 2 83
4 4 98
7 7 96
5 10 60
5 2 76
5 2 61
6 4 29
1 10 99
6 3 92
1...

output:

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

result:

ok 1000 numbers

Test #16:

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

input:

1000
10 20
9 8 326353980
1 10 321178299
4 8 970616710
4 9 550923176
8 9 682488932
10 6 752852755
5 10 399703822
10 10 207683413
7 9 84451826
7 8 820433227
7 5 97884128
6 7 1405220
1 5 287655030
8 9 868446569
4 1 421832399
9 4 913601101
2 9 361785960
9 3 425625400
3 9 1891923
8 1 112588430
10 20
6 9 ...

output:

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

result:

ok 1000 numbers

Test #17:

score: 0
Accepted
time: 5ms
memory: 5676kb

input:

1000
10 50
10 1 1
1 5 1
4 1 1
2 7 1
8 4 1
2 10 1
1 4 1
1 10 1
9 6 1
10 6 1
7 7 1
1 6 1
4 3 1
1 5 1
5 4 1
9 10 1
9 4 1
2 6 1
10 10 1
2 10 1
8 1 1
4 6 1
4 4 1
3 6 1
6 1 1
6 5 1
2 7 1
9 6 1
7 3 1
5 4 1
3 10 1
3 1 1
7 7 1
1 5 1
5 7 1
4 8 1
1 6 1
4 3 1
2 10 1
6 3 1
2 1 1
2 6 1
2 3 1
3 4 1
4 1 1
9 6 1
7 1...

output:

0
0
-1
0
-1
0
1
0
-1
-1
0
0
1
0
-1
0
-1
-1
-1
-1
0
0
0
0
0
-1
1
0
1
0
0
1
-1
-1
0
0
1
-1
0
-1
0
0
0
0
0
-1
0
-1
-1
1
1
0
1
0
-1
1
0
0
1
1
0
0
-1
-1
0
1
0
0
0
-1
-1
0
0
1
0
-1
0
0
1
-1
0
-1
-1
-1
-1
1
1
1
-1
-1
1
-1
0
1
1
-1
-1
0
0
0
-1
0
1
0
0
1
1
-1
0
1
-1
0
-1
-1
1
0
1
-1
-1
1
0
-1
1
-1
-1
-1
1
-1...

result:

ok 1000 numbers

Test #18:

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

input:

1000
10 50
8 2 2
4 7 2
1 10 1
1 6 1
3 8 2
9 2 2
10 3 1
5 2 2
5 8 1
8 4 1
7 2 2
1 3 2
1 9 2
6 5 1
1 9 2
8 7 1
6 8 2
5 4 2
5 2 1
3 10 1
1 9 2
5 1 2
10 8 1
7 5 2
4 6 2
6 4 2
3 6 2
3 8 2
4 10 1
5 3 2
7 9 2
9 3 2
8 1 2
3 4 1
9 6 2
4 8 2
7 9 1
6 9 2
10 3 1
7 2 2
6 5 1
7 5 2
10 3 1
9 8 1
10 9 2
10 5 2
3 9 ...

output:

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

result:

ok 1000 numbers

Test #19:

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

input:

1000
10 50
6 6 3
10 3 3
1 3 1
7 10 2
10 8 1
8 4 3
8 4 2
9 4 1
1 5 3
3 3 2
7 3 1
8 4 2
1 3 3
5 9 3
2 7 1
9 4 2
4 6 1
8 9 1
7 10 3
2 8 1
1 5 3
3 8 2
4 4 3
7 3 2
2 4 2
6 1 2
1 7 1
9 1 1
1 5 3
10 1 3
7 10 2
2 10 3
6 4 2
8 1 3
4 2 2
3 5 3
9 3 1
9 8 1
3 8 3
5 2 2
7 10 1
6 4 3
10 3 2
1 4 1
7 8 2
8 4 2
9 8 ...

output:

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

result:

ok 1000 numbers

Test #20:

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

input:

1000
10 50
5 4 5
4 7 8
10 9 4
6 7 10
9 2 3
2 3 9
5 7 10
2 6 4
4 4 8
9 3 9
1 9 6
2 3 6
8 6 4
2 9 9
9 9 7
4 2 6
9 6 9
5 2 6
1 6 9
6 5 6
5 6 1
4 5 7
6 8 9
2 2 4
3 5 3
6 8 2
4 5 5
2 1 9
3 4 7
10 8 5
1 2 10
9 9 7
4 10 5
10 1 8
10 1 6
7 10 8
10 4 10
9 5 2
10 4 9
8 8 5
3 1 7
6 10 5
4 8 1
6 8 6
6 2 7
5 6 5
...

output:

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

result:

ok 1000 numbers

Test #21:

score: 0
Accepted
time: 17ms
memory: 3664kb

input:

1000
10 50
6 5 76
2 8 63
7 8 83
4 9 100
7 3 28
7 7 60
10 7 8
10 1 49
8 4 16
3 5 51
6 9 84
6 1 43
7 7 36
9 4 97
7 2 39
4 10 41
3 6 68
4 3 1
7 8 53
4 2 74
8 5 5
3 7 63
3 5 38
6 7 25
5 9 83
7 3 85
1 5 72
5 2 15
5 1 51
7 8 56
7 5 13
1 7 98
1 1 17
3 3 26
3 3 19
1 9 10
5 4 17
10 10 56
3 1 90
1 10 42
3 1 2...

output:

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

result:

ok 1000 numbers

Test #22:

score: 0
Accepted
time: 18ms
memory: 3652kb

input:

1000
10 50
2 2 954153759
1 3 283444488
8 10 897162377
6 2 701352810
5 8 872948443
6 10 320895294
10 9 697730752
5 4 375661090
3 4 673334850
6 9 215515206
10 7 977251708
6 1 888046403
5 2 292147356
9 9 840382008
3 10 430429980
6 8 921004331
4 10 298467905
7 1 160104863
10 3 444341972
10 4 653051505
9...

output:

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

result:

ok 1000 numbers

Test #23:

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

input:

1000
10 500
9 9 1
5 1 1
3 3 1
1 1 1
2 1 1
6 10 1
4 6 1
2 4 1
3 7 1
8 5 1
8 4 1
7 10 1
6 2 1
3 5 1
8 9 1
5 3 1
5 1 1
4 2 1
10 8 1
3 8 1
6 3 1
5 2 1
5 3 1
6 3 1
4 6 1
8 1 1
6 8 1
10 7 1
1 5 1
9 2 1
6 10 1
8 6 1
8 10 1
3 10 1
3 2 1
1 3 1
2 8 1
9 3 1
8 8 1
8 1 1
3 2 1
10 8 1
1 1 1
1 7 1
4 7 1
8 3 1
6 10...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
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 1000 numbers

Test #24:

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

input:

1000
10 500
5 7 1
6 2 1
7 3 1
4 7 1
5 9 1
7 4 1
7 6 2
4 10 2
7 4 1
9 3 2
9 5 1
1 9 1
9 4 2
6 7 1
2 3 2
7 7 2
2 4 2
8 8 2
10 8 2
9 7 2
8 10 2
4 4 2
2 7 2
8 7 2
4 6 2
7 9 2
6 8 1
4 3 2
6 1 2
6 2 2
3 5 2
3 10 2
8 2 2
5 9 2
3 6 1
9 10 2
3 5 2
10 1 2
4 10 2
8 8 2
10 4 1
4 5 1
4 9 1
6 1 1
1 7 2
7 1 2
9 5 ...

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 1000 numbers

Test #25:

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

input:

1000
10 500
5 8 1
5 9 1
10 1 2
5 3 3
1 10 3
10 2 3
4 7 3
4 5 2
2 6 3
6 5 2
8 1 2
3 6 3
7 6 3
2 1 2
1 1 2
9 3 3
10 1 2
2 4 2
6 5 1
10 6 3
5 10 3
2 9 2
2 5 2
7 10 2
1 10 1
8 9 3
9 8 3
2 5 3
7 5 1
1 7 3
4 10 3
9 6 1
5 9 1
8 7 2
9 4 1
10 9 2
2 10 3
3 9 2
4 1 1
9 8 2
10 9 1
4 3 1
8 9 3
2 10 1
5 9 1
6 5 3...

output:

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

result:

ok 1000 numbers

Test #26:

score: 0
Accepted
time: 153ms
memory: 3616kb

input:

1000
10 500
3 8 7
2 6 10
9 1 10
6 7 1
10 10 6
7 1 6
1 5 10
1 8 9
8 1 7
8 1 3
3 7 8
8 10 1
3 1 1
2 9 10
7 9 9
1 4 10
7 5 9
8 10 2
9 9 9
9 10 7
6 5 7
9 4 8
9 3 3
5 4 5
1 9 3
8 5 9
10 5 10
5 4 4
2 4 10
7 6 9
1 6 4
6 10 10
10 10 4
8 7 8
4 4 9
5 7 4
5 10 9
2 2 8
8 8 3
7 7 1
1 6 4
7 8 1
5 2 10
4 9 1
9 10 ...

output:

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

result:

ok 1000 numbers

Test #27:

score: 0
Accepted
time: 511ms
memory: 3700kb

input:

1000
10 500
4 6 30
2 6 44
4 4 52
5 3 43
7 4 18
1 9 46
3 7 9
3 6 83
9 6 58
3 6 58
9 8 100
10 7 62
3 5 64
5 5 53
6 8 95
1 6 12
1 1 72
10 9 93
4 2 82
8 8 73
4 8 32
9 3 92
5 2 75
4 1 92
10 2 83
10 3 57
9 10 13
3 7 37
6 1 100
9 3 12
7 3 67
6 6 14
4 8 86
8 2 4
4 3 8
7 6 15
10 8 56
6 8 98
4 5 30
7 7 36
1 6...

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 1000 numbers

Test #28:

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

input:

1000
10 500
8 9 67526824
5 4 559064935
10 5 4911091
10 1 665435421
10 9 676899734
7 1 937378183
8 5 573246092
4 7 989380774
4 6 200810178
7 1 416005093
8 8 742684190
1 10 268750539
2 5 718281171
1 8 934536165
1 5 814664163
2 7 237449715
2 1 203051765
6 7 306356562
10 3 428234841
3 1 760994730
10 2 7...

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 1000 numbers

Test #29:

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

input:

1000
500 500
363 349 1
362 206 1
163 390 1
137 172 1
302 114 1
71 291 1
174 386 1
290 118 1
455 251 1
221 39 1
349 64 1
496 62 1
385 170 1
391 24 1
266 372 1
86 223 1
3 209 1
336 410 1
408 288 1
19 470 1
110 356 1
66 95 1
156 271 1
220 405 1
348 367 1
188 485 1
1 499 1
148 160 1
273 394 1
227 401 1
...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-...

result:

ok 1000 numbers

Test #30:

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

input:

1000
500 500
268 243 2
164 390 1
155 185 1
45 113 1
214 25 1
469 95 2
263 38 1
59 179 2
353 494 2
203 171 1
240 167 2
135 496 1
252 77 2
35 403 1
86 257 1
38 370 1
341 328 1
226 268 1
284 321 1
143 8 1
317 179 2
120 124 1
265 78 2
447 80 2
336 14 1
154 249 1
227 90 2
137 390 1
227 186 1
345 108 1
26...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 1000 numbers

Test #31:

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

input:

1000
500 500
421 241 2
100 61 2
388 163 1
422 52 1
488 175 2
272 57 1
392 97 2
265 460 2
140 292 3
29 58 1
364 328 3
139 231 3
354 453 1
45 484 1
197 423 1
9 257 2
275 359 2
22 160 1
279 54 1
197 206 3
268 384 2
85 308 1
372 164 2
340 282 1
348 130 2
67 448 2
66 452 2
79 418 3
332 388 3
217 369 2
12...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 1000 numbers

Test #32:

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

input:

1000
500 500
143 491 2
362 354 3
485 14 4
325 343 1
209 342 1
192 472 3
295 6 1
178 387 4
246 328 1
131 314 1
81 453 2
405 283 3
351 348 1
178 256 4
463 405 4
181 32 2
408 249 3
488 292 4
4 288 1
48 206 2
215 17 1
14 464 3
463 135 4
10 40 4
78 357 4
234 367 4
467 455 4
357 355 2
424 214 2
88 353 2
3...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

result:

ok 1000 numbers

Test #33:

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

input:

1000
500 500
140 313 3
155 280 5
197 292 4
234 230 2
348 46 2
269 194 5
434 202 4
33 311 3
152 335 1
384 145 3
235 127 4
370 147 2
444 328 1
127 2 3
357 189 4
255 141 5
460 386 2
398 138 5
326 417 3
51 108 1
22 33 4
251 390 2
79 74 1
215 245 1
482 366 1
253 449 1
460 25 4
318 157 4
380 336 2
225 356...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
2
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

result:

ok 1000 numbers

Test #34:

score: 0
Accepted
time: 400ms
memory: 14964kb

input:

5
10000 100000
16 3559 468695643
7133 1854 827377604
2253 8986 212718926
3378 8735 205907497
3784 3272 98819139
5961 1839 898392689
4722 371 109250145
8884 4871 589883888
7498 9813 70864069
9475 6017 175126069
2932 4557 863780576
7285 6064 122334857
5448 5260 360605203
2995 6162 705458859
9806 2832 ...

output:

1
0
2
0
0

result:

ok 5 number(s): "1 0 2 0 0"

Test #35:

score: 0
Accepted
time: 378ms
memory: 14672kb

input:

5
10000 100000
400 1662 499032381
6939 2059 486853387
8062 4311 263485029
6906 9144 898349721
1374 9791 287537913
1401 2514 179426639
3206 356 654913984
955 4491 102066327
3824 2238 428099250
5030 4171 796495242
3176 8123 228296196
1660 5633 794625946
4996 4363 891788658
4221 4267 717537153
5092 647...

output:

1
0
2
1
1

result:

ok 5 number(s): "1 0 2 1 1"

Test #36:

score: 0
Accepted
time: 464ms
memory: 14968kb

input:

5
10000 100000
9526 8284 30390295
2776 8832 185094918
939 7505 922941741
5631 7025 869203187
8618 8178 304297509
4573 6637 697002478
7831 8738 160865264
8640 1154 975091136
3872 1182 637499754
9369 8403 47264467
6368 2555 483838225
7177 4894 244976652
9845 1265 564379654
2955 1436 118973925
3645 199...

output:

0
1
1
0
1

result:

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

Test #37:

score: 0
Accepted
time: 336ms
memory: 57256kb

input:

1
100000 500000
34635 46033 243840177
89991 69694 442882506
19968 21610 887963959
59100 4326 518891263
32030 66602 905457084
6365 4377 378500516
35716 52072 375354442
83763 63671 748057938
90167 71718 314322061
20985 57673 399305781
33422 9344 54429249
8621 10927 88073233
24414 18967 895092185
91512...

output:

-1

result:

ok 1 number(s): "-1"

Test #38:

score: 0
Accepted
time: 317ms
memory: 57428kb

input:

1
100000 500000
15188 94877 126956305
36064 18948 613736176
54124 38302 322768646
61948 64766 801195445
69649 93035 698032982
45412 52100 455948433
23657 16312 543752460
82338 71180 928014228
84388 81926 336635918
20855 4689 124954834
75713 19615 821948475
70517 69931 455049369
11652 49042 460926915...

output:

-1

result:

ok 1 number(s): "-1"

Test #39:

score: 0
Accepted
time: 353ms
memory: 57432kb

input:

1
100000 500000
52638 76426 305039729
14841 68201 344398357
20983 22290 197764822
54396 25205 378466923
96868 95277 340865776
25674 24014 678620542
87405 89065 712150478
24017 78689 548162006
45905 24838 63982479
20726 94809 705379695
85300 72989 734691893
73629 72040 116992802
66185 79117 26761645
...

output:

-1

result:

ok 1 number(s): "-1"

Test #40:

score: 0
Accepted
time: 432ms
memory: 117088kb

input:

1
500000 500000
59280 54906 439822256
429265 418258 621212182
218147 211795 205467984
164946 71245 957403153
481375 344334 382889209
206719 295309 525844696
195710 220464 534488515
49094 402808 390137503
110467 267533 689219374
466476 328515 301654731
60840 13684 148387915
395867 144861 350257604
45...

output:

-1

result:

ok 1 number(s): "-1"

Test #41:

score: 0
Accepted
time: 429ms
memory: 117316kb

input:

1
500000 500000
339833 103751 322938384
440746 267512 646841660
152303 395783 935239967
467793 107493 239707335
451698 413871 25722003
486981 299927 453549509
483651 484705 407919237
147669 10317 865061089
171984 353549 711533231
233642 318636 882079592
370427 491251 61131333
233571 414266 717233740...

output:

-1

result:

ok 1 number(s): "-1"

Test #42:

score: 0
Accepted
time: 434ms
memory: 117328kb

input:

1
500000 500000
344579 152595 795989104
419522 359869 522728034
86458 79771 810236143
27537 367932 522011518
146214 240305 963522093
426027 80354 530997427
80103 314354 281349959
22052 117827 190241570
266205 163757 438879792
33513 32948 312761349
488526 277329 533683263
360875 473271 379177172
1284...

output:

-1

result:

ok 1 number(s): "-1"

Test #43:

score: -100
Time Limit Exceeded

input:

1
40003 80000
35719 1310 38202
835 12806 47060
3603 7710 11806
14153 3125 43071
4939 15539 4841
33565 14175 16271
20550 10855 10018
32124 23731 12555
1753 13312 56596
25501 38087 44821
7833 1310 37857
29811 1310 31956
1310 26094 31445
1088 1310 31689
7975 26106 41605
3119 1310 33900
1310 30057 37747...

output:


result: