QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#748156#190. New HomePioneer57 2507ms187000kbC++204.6kb2024-11-14 19:30:462024-11-14 19:30:50

Judging History

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

  • [2024-11-14 19:30:50]
  • 评测
  • 测评结果:57
  • 用时:2507ms
  • 内存:187000kb
  • [2024-11-14 19:30:46]
  • 提交

answer

#include <bits/stdc++.h>
 
#pragma GCC optimize("Ofast")
 
#define ll long long
// #define int ll
#define all(v) v.begin(),v.end()
#define sz(s) ((int)s.size())
#define pb push_back
#define F first
#define S second
#define pii pair<int,int>
#define ppb pop_back
#define lb lower_bound
#define ub upper_bound
 
using namespace std;
 
const int inf=1e8;
const int MAX=3e5+10;
const int mod=1e9+7;
 
int binpow(int a,int n){
    if(!n)return 1;
    if(n%2==1)return a*binpow(a,n-1)%mod;
    int k=binpow(a,n/2);
    return k*k%mod;
}
 
int n,k,q,m;
int a[MAX],b[MAX],x[MAX],t[MAX];
int l[MAX],y[MAX];
vector<int> events[MAX+MAX+MAX],zap[MAX+MAX+MAX];
multiset<int> st[MAX];
vector<int> tim,pos;
 
struct segtree{
    multiset<int> t[2*2*MAX];
    int mx[2*2*MAX];
 
    segtree(){
        memset(mx,-1,sizeof(mx));
    }
 
    void add(int v,int tl,int tr,int pos,int x){
        pos+=m;
        t[pos].insert(x);
        mx[pos]=*t[pos].rbegin();
        while(pos>1){
            pos/=2;
            mx[pos]=max(mx[2*pos],mx[2*pos+1]);
        }
    }
 
    void del(int v,int tl,int tr,int pos,int x){
        pos+=m;
        t[pos].erase(t[pos].find(x));
        mx[pos]=(t[pos].empty()?-1:*t[pos].rbegin());
        while(pos>1){
            pos/=2;
            mx[pos]=max(mx[2*pos],mx[2*pos+1]);
        }
    }
 
    int get(int v,int tl,int tr,int l,int r){
        l+=m,r+=m+1;
        int res=0;
        while(l<r){
            if(l&1){
                res=max(res,mx[l++]);
            }
            if(r&1){
                res=max(res,mx[--r]);
            }
            l/=2,r/=2;
        }
        return res;
    }
}tree;
 
int cnt[MAX],col;
 
int getx(int x){
    return lb(all(pos),x)-pos.begin();
}
 
void add(int id){
    if(cnt[t[id]]==0)col++;
    cnt[t[id]]++;
    if(st[t[id]].count(x[id]))st[t[id]].insert(x[id]);
    else{
        auto l=--st[t[id]].lb(x[id]);
        auto r=st[t[id]].lb(x[id]);
        int LL=getx(*l+1);
        if(!(*l==-1&&*r==inf+1))tree.del(1,0,m-1,LL,*r-1);
        tree.add(1,0,m-1,LL,x[id]-1);
        tree.add(1,0,m-1,getx(x[id]+1),*r-1);
        st[t[id]].insert(x[id]);
    }
}
 
void del(int id){
    id=-id;
    cnt[t[id]]--;
    if(cnt[t[id]]==0)col--;
    st[t[id]].erase(st[t[id]].find(x[id]));
    if(!st[t[id]].count(x[id])){
        auto l=--st[t[id]].lb(x[id]);
        auto r=st[t[id]].lb(x[id]);
        int LL=getx(*l+1);
        tree.del(1,0,m-1,LL,x[id]-1);
        tree.del(1,0,m-1,getx(x[id]+1),*r-1);
        if(!(*l==-1&&*r==inf+1))tree.add(1,0,m-1,LL,*r-1);
    }
}
 
bool check(int l,int r){
    l=max(l,0);
    r=min(r,inf);
    l=ub(all(pos),l)-pos.begin()-1;
    // cout<<0<<" "<<l<<" "<<tree.get(1,0,m-1,0,l)<<"\n";
    if(tree.get(1,0,m-1,0,l)>=r)return 0;
    return 1;
}
 
int ans[MAX];
 
void solve(){
    cin>>n>>k>>q;
    pos.pb(0),pos.pb(inf);
    for(int i=1;i<=n;i++){
        cin>>x[i]>>t[i]>>a[i]>>b[i];
        tim.pb(a[i]);
        tim.pb(b[i]+1);
        pos.pb(x[i]+1);
        pos.pb(x[i]-1);
    }
    for(int i=1;i<=q;i++){
        cin>>l[i]>>y[i];
        tim.pb(y[i]);
    }
    sort(all(tim));
    tim.erase(unique(all(tim)),tim.end());
    sort(all(pos));
    pos.erase(unique(all(pos)),pos.end());
    for(int i=1;i<=n;i++){
        a[i]=lb(all(tim),a[i])-tim.begin();
        b[i]=lb(all(tim),b[i]+1)-tim.begin();
        events[a[i]].pb(i);
        events[b[i]].pb(-i);
    }
    for(int i=1;i<=q;i++){
        y[i]=lb(all(tim),y[i])-tim.begin();
        zap[y[i]].pb(i);
    }
    for(int i=1;i<=k;i++){
        st[i].insert(-1);
        st[i].insert(inf+1);
    }
    m=sz(pos);
    for(int i=0;i<sz(tim);i++){
        cerr<<i<<"\n";
        for(auto id:events[i]){
            if(id>0){
                add(id);
            }
            else{
                del(id);
            }
        }
        for(int id:zap[i]){
            if(col!=k){
                ans[id]=-1;
            }
            else{
                int L=0,R=inf,res=inf;
                while(L<=R){
                    int mid=(L+R)/2;
                    if(check(l[id]-mid,l[id]+mid)){
                        R=mid-1,res=mid;
                    }
                    else L=mid+1;
                }
                ans[id]=res;
            }
        }
    }
    for(int i=1;i<=q;i++)cout<<ans[i]<<"\n";
}
 
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    int init=clock();
    while(t--)solve();
    #ifdef LOCAL
        cout<<1.0*(clock()-init)/CLOCKS_PER_SEC<<"s\n";
    #endif
}

详细

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 3ms
memory: 87648kb

input:

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

output:

4
2
-1
-1

result:

ok 4 lines

Test #2:

score: 5
Accepted
time: 7ms
memory: 87640kb

input:

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

output:

0
0
-1

result:

ok 3 lines

Test #3:

score: 5
Accepted
time: 8ms
memory: 87736kb

input:

1 1 1
100000000 1 1 1
1 1

output:

99999999

result:

ok single line: '99999999'

Test #4:

score: 5
Accepted
time: 16ms
memory: 85664kb

input:

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

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 20 lines

Test #5:

score: 5
Accepted
time: 8ms
memory: 85668kb

input:

20 10 1
45 4 53 54
75 8 56 60
65 3 87 100
56 7 93 97
36 3 64 91
63 4 93 94
71 2 45 97
67 5 57 65
34 6 7 52
96 9 43 95
83 5 63 92
24 3 55 99
7 10 38 52
59 10 59 100
43 5 5 21
38 9 72 82
72 2 1 64
22 7 50 81
74 5 88 89
84 1 25 29
41 48

output:

-1

result:

ok single line: '-1'

Test #6:

score: 5
Accepted
time: 12ms
memory: 87636kb

input:

1 10 20
58 4 59 59
36 88
80 47
56 65
74 45
99 4
17 2
13 46
92 38
82 2
42 47
40 40
30 9
13 41
14 77
61 33
20 73
89 3
89 100
83 100
28 59

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1

result:

ok 20 lines

Test #7:

score: 5
Accepted
time: 7ms
memory: 89836kb

input:

20 4 20
61418457 4 33932551 98975124
50805588 3 56616927 66076460
44262243 1 58029464 59272268
34981593 4 10760710 89302332
58741675 3 60670049 77700264
33623668 3 63722438 67824726
62526450 2 43078579 75611393
4274055 2 14095759 73162733
87374777 4 83277088 91743411
94571186 3 89842706 99458411
124...

output:

10979904
42075856
54788268
-1
-1
42932550
-1
24180475
27529716
-1
-1
24630956
16686222
-1
35018819
52156445
41144455
35084106
64627631
26558377

result:

ok 20 lines

Test #8:

score: 5
Accepted
time: 10ms
memory: 87692kb

input:

400 6 400
13 6 1 2
6 2 1 5
1 6 10 11
14 6 9 12
3 1 10 15
10 1 10 13
12 4 7 15
3 5 7 7
11 2 15 15
9 4 2 10
9 2 2 2
3 2 11 13
2 5 4 4
15 1 6 14
9 6 13 15
2 3 14 15
10 3 9 11
3 2 12 13
6 5 13 14
13 5 13 15
5 6 1 4
8 4 6 15
7 2 6 12
7 2 11 12
2 6 9 15
13 1 6 11
4 1 8 13
12 2 2 10
6 2 4 6
3 1 11 11
10 6 ...

output:

0
1
1
1
1
0
1
1
1
1
2
0
0
1
4
1
1
0
3
1
0
0
1
1
11
0
1
5
2
0
0
8
2
2
4
1
1
1
0
1
2
0
2
1
1
1
1
1
0
1
0
1
6
1
4
0
0
1
0
0
1
1
1
4
0
2
5
2
1
1
0
1
1
3
1
1
0
0
1
9
2
1
1
1
1
2
2
1
1
1
1
1
1
8
1
1
1
1
1
3
1
1
1
1
0
3
2
0
7
3
1
2
1
0
1
3
0
1
2
2
0
0
1
0
1
1
1
3
2
3
3
1
2
1
1
1
1
2
1
2
1
1
5
0
1
5
3
2
1
1...

result:

ok 400 lines

Test #9:

score: 5
Accepted
time: 7ms
memory: 85760kb

input:

400 10 400
43340857 4 45698748 89832178
54619105 4 12139243 31375025
37861883 8 47732866 65672593
28228848 2 34377649 37188437
24894809 5 21779229 60269842
5631877 9 56806239 99891497
58348534 9 55212163 99535913
96241892 8 13013131 71454036
96553400 5 68855786 90287612
49896594 7 75131914 88890304
...

output:

61438693
10092902
17042653
-1
14307562
44443029
-1
12918912
18058222
21930309
8237607
16854750
21730597
12859269
16464543
5185522
11308124
17123350
33463533
39018069
7610293
25072752
-1
25395408
38817024
-1
-1
20033481
43512384
25208569
17827332
23318396
16702567
10179947
30415219
15582621
10432423
...

result:

ok 400 lines

Test #10:

score: 5
Accepted
time: 16ms
memory: 89896kb

input:

400 400 400
50895816 112 11074810 50852590
91036952 324 226350 42542861
93200007 152 88561471 97853611
58986775 6 42946440 47476776
29191962 123 42448629 81705957
85607864 215 29065353 76256459
63414892 222 13827288 67943972
74982535 186 36761229 88857832
62363052 134 7564006 70661082
17925970 164 9...

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 400 lines

Test #11:

score: 5
Accepted
time: 22ms
memory: 85796kb

input:

400 133 400
3672823 119 18980672 88133847
67471612 108 41504712 97890476
40231264 19 37977684 52706386
96965371 77 21512104 86735367
29768987 114 25023034 84911918
59319041 24 8655797 88359567
81666143 66 7551736 73528006
68054496 103 13398677 59490218
84578976 36 34975186 62284778
32378800 45 23893...

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
87968835
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-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 400 lines

Test #12:

score: 5
Accepted
time: 15ms
memory: 85924kb

input:

400 400 400
1581479 181 42400111 59732368
907309 87 5432725 51741834
25558404 52 27591603 55926047
73925801 89 12982129 72562916
93044109 8 22280490 87851712
4340628 199 21917419 59718121
29672983 78 47325176 83492730
37972962 29 7273544 67846186
33992886 275 8776836 87243343
19347144 392 15078284 7...

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 400 lines

Test #13:

score: 5
Accepted
time: 8ms
memory: 89820kb

input:

400 11 400
40710338 3 16766984 69515403
16397634 1 40616452 86952344
23986892 4 3711721 90215388
77091994 9 20674420 67833193
91288329 1 33738566 54779431
10971676 10 6962019 90743517
31716858 8 45519538 68166156
5219948 2 17257088 68841179
83743328 11 47480189 76282688
78162024 7 32457788 53262410
...

output:

4939905
23411162
7237354
7801322
18434376
3540541
5694122
5210393
4697783
10462459
29677624
48631432
5297965
4337578
4367168
20332085
5214702
5091001
3888050
-1
5363635
4067299
6861399
15591527
4964092
1992550
6176507
5922653
16627616
-1
4028480
3968144
5974366
5520655
11225360
7374306
9720663
15759...

result:

ok 400 lines

Test #14:

score: 5
Accepted
time: 9ms
memory: 87876kb

input:

400 20 400
10522853 16 3875473 15470596
10244202 4 8804037 17670418
18427843 8 2894806 13624813
9342852 8 14040683 15305924
18066564 13 4953771 17185081
3290462 9 10613188 16519838
4724465 11 6497896 17646746
11138017 1 1435979 8077032
13696787 12 18036390 19470914
3792181 4 16705463 18216042
320466...

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 400 lines

Test #15:

score: 5
Accepted
time: 7ms
memory: 87804kb

input:

400 3 400
7133454 1 5318840 16336998
14681771 3 14283494 19488133
3067337 2 15733173 18756469
19418351 2 195529 14731721
1990147 3 12317038 15097650
14347730 2 7126801 7455128
2501003 3 7366596 15539428
8853316 1 7516862 8151398
6938740 2 6852313 16787099
12511351 2 15104531 16729860
13626126 1 1382...

output:

3722216
1410158
2153626
823235
1917377
1202314
3296486
503311
-1
11340917
1082628
1614137
647038
711346
6169693
826067
1314916
8511450
2219292
-1
1148822
-1
1017529
1349749
1487025
5455581
2091924
1324126
1280399
1082465
1458499
1221119
452102
-1
3476390
1904784
839574
16318381
3437188
3442616
87847...

result:

ok 400 lines

Test #16:

score: 5
Accepted
time: 11ms
memory: 87732kb

input:

400 5 400
1338030 5 46136 1306367
516205 3 349494 674020
1457759 4 746415 1812760
41272 2 871535 1098966
1341950 5 1210712 1759003
1702670 2 432353 1906011
1675031 1 48529 1212647
100509 4 1542025 1626545
2622468 1 2140798 2675670
3910307 5 3717865 3981158
2007817 4 2984729 3555785
2944217 1 3461836...

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 400 lines

Test #17:

score: 5
Accepted
time: 11ms
memory: 85836kb

input:

390 3 390
1146372 1 1908187 2533863
2446740 3 3169712 3309037
2202363 1 2162162 3137371
3073428 2 966559 2635463
3060348 1 260960 486563
2506279 2 1985241 2640110
2937458 1 1277976 1812302
1350636 3 1269239 2234342
2068936 1 999429 1946001
1420761 3 3269927 3275363
2426388 3 387304 1265083
1849865 2...

output:

2559714
2933290
-1
-1
1843610
-1
517555
-1
-1
-1
-1
2611274
-1
-1
1632355
-1
350545
1770180
2338077
2874779
-1
-1
1435419
-1
1493771
-1
-1
1234422
-1
-1
-1
1246494
2143487
-1
-1
540459
1783699
-1
-1
1921725
2021526
-1
-1
1193702
-1
-1
-1
1723826
2426718
1140893
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1208901
...

result:

ok 390 lines

Test #18:

score: 5
Accepted
time: 7ms
memory: 85840kb

input:

389 149 400
36593831 1 3784273 96375485
57440282 2 958534 98542960
38126928 3 36034 95331355
65995762 4 3373043 94808111
65030237 5 1683594 96169742
45136127 6 3653996 96503703
45252615 7 1775667 98338135
43231951 8 2000685 98734395
52397663 9 3095884 94520660
49714105 10 3766068 95790579
58169746 1...

output:

87969247
72859305
68429822
43479966
67681502
41461135
-1
38705911
50920201
62354342
42817692
81347574
67782120
44084429
76912490
73173037
71906180
96490576
76300295
65820149
-1
-1
-1
50185691
44389446
91162883
55968963
48090511
-1
80243422
60098514
51422725
49394331
-1
94587322
71133032
73417555
514...

result:

ok 400 lines

Test #19:

score: 5
Accepted
time: 3ms
memory: 85796kb

input:

396 214 400
42515756 1 3535916 96655328
62797037 2 2166531 94172150
54706374 3 1673019 96908826
37187317 4 5509987 94559482
62877046 5 1536575 97664313
62983296 6 4035537 97218191
43302636 7 5146517 98805937
57309706 8 3399216 96886919
63256572 9 4926648 96596943
49677708 10 506253 96364987
65777237...

output:

-1
80008513
78843150
59666539
80122533
72078494
61089492
80862696
83795645
86778746
50300138
51832223
65358649
47009165
72324985
64088034
29646137
74622987
48723688
77298052
71177138
58490373
55898526
45671241
46521430
49333721
-1
79827583
76486609
70589261
56983351
42774125
51664780
58099775
330527...

result:

ok 400 lines

Test #20:

score: 5
Accepted
time: 4ms
memory: 85904kb

input:

400 60 400
65168552 1 197837 97436716
66046539 2 2134081 95527091
66571017 3 3559448 96613004
36988788 4 11000 99200331
54756442 5 1145407 98377638
41324404 6 1232549 99338549
56248628 7 2532157 99842825
48283742 8 2957722 96050598
58805713 9 4393295 95746782
52221940 10 4775438 96699019
44736110 11...

output:

82828320
43610946
70072097
-1
90431812
48735588
62380873
79599694
87284897
65914706
76156761
42193550
45940557
48735086
51087414
44759492
74544813
65748555
76115200
86176138
48380986
65448967
70454534
83370670
76652150
83001737
60636180
53112950
73421570
-1
88220587
45851734
27404047
37404723
745171...

result:

ok 400 lines

Test #21:

score: 5
Accepted
time: 11ms
memory: 85848kb

input:

400 156 400
35659043 1 732284 85371572
45924193 2 300458 96861163
51798218 3 9738240 81279603
48639012 4 1226735 83780005
39462195 5 14259398 94145546
63563965 6 19262677 95272800
46744742 7 11186812 89239479
62764248 8 3205351 84912684
55399381 9 6805424 91170796
66428174 10 6837155 82124706
666132...

output:

-1
-1
-1
-1
-1
57718465
59597605
-1
-1
76712633
-1
-1
46733455
48857358
45033779
70384412
-1
-1
78637763
56085255
53736848
-1
61285488
87213847
-1
-1
-1
-1
88887623
-1
77018654
-1
-1
58252836
53483510
55432344
70749579
77251386
-1
42475480
66290720
65882863
-1
-1
89115582
54632870
59687352
60510765
...

result:

ok 400 lines

Test #22:

score: 5
Accepted
time: 11ms
memory: 90028kb

input:

400 220 400
60010265 1 3506055 86504662
39242364 2 10118684 92677226
36800333 3 18464122 80675074
60560739 4 1830235 87394751
45634626 5 12535177 87516185
62076225 6 10626428 89113240
52804395 7 16021761 91866831
44587319 8 17539258 89117504
60068701 9 2538902 91720974
53107572 10 1453968 94357950
6...

output:

84128943
62779261
57986920
77069794
43009750
61970847
83751085
-1
64955848
82621676
29200170
68851882
68321556
70287403
-1
47762527
69161896
66810866
67525148
87431041
52847819
-1
90762425
-1
-1
52270616
60661847
-1
-1
91311424
-1
-1
36170220
67541926
-1
-1
79831892
53791087
47511890
-1
86146563
-1
...

result:

ok 400 lines

Test #23:

score: 5
Accepted
time: 7ms
memory: 89792kb

input:

400 67 400
50971008 1 17498802 98237405
51407088 2 1905731 87800053
43859608 3 5502162 95995264
55434904 4 3145908 86648306
58312055 5 6565727 93428077
45747874 6 8589669 96851899
65445952 7 4189389 91652438
42468020 8 16472444 81012485
49756570 9 2283378 86505353
34481412 10 17989125 93634060
33630...

output:

-1
-1
54670007
37497132
-1
69710453
-1
80607403
58549262
45194314
-1
-1
61850222
73113778
54785450
73680577
54503594
-1
54573549
42942792
55412688
88339613
-1
81422086
71743088
-1
-1
-1
61524433
67319990
89627240
36842748
60608110
-1
-1
42265173
38907568
70004148
55145544
-1
77038352
-1
75937776
-1
...

result:

ok 400 lines

Test #24:

score: 5
Accepted
time: 17ms
memory: 85756kb

input:

400 400 400
100000000 1 1 100000000
100000000 2 1 100000000
100000000 3 1 100000000
100000000 4 1 100000000
100000000 5 1 100000000
100000000 6 1 100000000
100000000 7 1 100000000
100000000 8 1 100000000
100000000 9 1 100000000
100000000 10 1 100000000
100000000 11 1 100000000
100000000 12 1 1000000...

output:

99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
999...

result:

ok 400 lines

Test #25:

score: 5
Accepted
time: 11ms
memory: 89916kb

input:

400 400 400
42800778 1 16708238 94002944
13609386 2 28182812 71544065
79832947 3 30921885 98635264
62399729 4 12564983 89835010
51775003 5 30035874 87064508
2061087 6 24395270 73376487
71261001 7 7503556 86723656
54959030 8 22211415 75859069
77785946 9 27158490 95058905
61567484 10 1293538 86938365
...

output:

-1
50800067
-1
-1
-1
49992900
-1
55521560
-1
-1
-1
-1
-1
-1
53256954
51497729
-1
-1
71307016
-1
-1
91689048
-1
-1
-1
-1
-1
-1
-1
-1
-1
95378179
72396658
-1
-1
-1
89726365
97884397
51137862
-1
86659312
-1
54934487
-1
-1
-1
54862867
63528429
-1
-1
-1
92417904
-1
59133946
-1
-1
-1
-1
-1
-1
67952954
-1
...

result:

ok 400 lines

Test #26:

score: 5
Accepted
time: 7ms
memory: 89888kb

input:

400 211 400
16349623 1 18670501 45718763
65134081 1 21253982 74076632
36007630 1 44580513 99460414
99368186 2 30068977 85427051
97159871 3 19511448 71140413
26069032 3 40490078 78656208
32840687 4 12485377 46718190
7825021 4 32727325 69341753
5683892 4 49429559 89043612
35280489 5 23054737 87387167
...

output:

63995317
70179831
54893043
-1
-1
-1
-1
-1
-1
-1
91360138
-1
-1
-1
78233321
-1
-1
-1
93895222
75137218
98817906
80975346
-1
-1
-1
88628991
-1
-1
-1
-1
-1
69610578
-1
-1
65743782
-1
62091674
-1
-1
-1
-1
-1
-1
-1
-1
-1
67938036
55935311
-1
88620728
-1
-1
-1
53173231
-1
51796073
86616415
78998362
-1
930...

result:

ok 400 lines

Test #27:

score: 5
Accepted
time: 11ms
memory: 87764kb

input:

400 134 400
84865763 1 1449762 51584911
95796263 1 33716370 66107739
75453703 1 42227669 85769765
20302341 2 6385782 55297433
5887904 2 21079050 79254029
75528010 2 53378619 80263375
13826063 3 2203433 34697852
91527815 3 26713672 54172170
54822186 3 47029672 78178094
94634415 3 56643018 93356838
87...

output:

73400983
-1
53020098
80363670
81130310
-1
-1
-1
73948425
79762681
51068556
-1
63703232
-1
-1
69966535
-1
60661669
63208336
-1
-1
-1
-1
-1
88833246
46100824
-1
-1
69765650
-1
89346236
79533532
79286511
-1
-1
-1
-1
-1
67614297
52315397
-1
93708987
73082447
83038217
-1
77811918
76049359
93229491
-1
-1
...

result:

ok 400 lines

Test #28:

score: 5
Accepted
time: 4ms
memory: 87808kb

input:

400 44 400
35710445 1 9007721 30409287
99830025 1 18556117 42738837
27742044 1 24711880 49116041
75561747 1 40255585 66442597
38838136 1 51202628 73522366
43391128 1 58006128 83308395
54391589 1 74052639 93292689
18813555 2 7143709 22979706
38137780 2 15294310 26845368
31578867 2 17340002 34862693
8...

output:

-1
-1
-1
69358418
47508193
57462448
91436740
43306499
-1
58625695
69002605
60169831
52469693
74406598
78419481
-1
-1
89661286
-1
-1
67126575
52018273
47955248
65619074
66787585
-1
49354404
90338810
82102061
48795239
72318628
58234587
73118905
85380974
57447730
53014458
-1
75817261
93998358
-1
-1
-1
...

result:

ok 400 lines

Test #29:

score: 5
Accepted
time: 3ms
memory: 85816kb

input:

400 4 400
99338201 1 166307 1517779
33122497 1 941823 2234415
26591611 1 1851389 3123709
85880965 1 2483664 3834948
21130586 1 3291700 4723269
38606139 1 3884897 5829967
1880626 1 5062762 6562574
48911187 1 5458475 6981242
70766404 1 6560529 8025738
34173440 1 6984644 8712958
39037143 1 7657953 8894...

output:

45871272
36412472
76488815
67691147
80486729
35337879
85347318
28505473
27830333
36916030
51357789
37228399
87185308
30412352
94227024
18308975
71974833
33661668
38413926
20519250
72901195
73330394
16371875
29164248
45174240
81776756
32548494
46086755
36162532
27021299
32636476
43387713
26079036
234...

result:

ok 400 lines

Test #30:

score: 5
Accepted
time: 12ms
memory: 85704kb

input:

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

output:

21
-1
35
-1
23
33
-1
-1
-1
-1
38
31
45
-1
38
34
39
38
33
41
42
-1
-1
-1
44
33
35
-1
24
34
44
23
31
30
-1
-1
38
45
30
-1
-1
48
-1
34
-1
43
40
36
23
39
-1
-1
43
-1
-1
-1
-1
-1
34
-1
-1
31
45
-1
30
41
43
-1
39
-1
-1
-1
-1
19
26
-1
33
36
22
37
-1
-1
-1
30
-1
41
-1
23
40
-1
30
-1
-1
47
41
39
-1
21
24
22
...

result:

ok 400 lines

Test #31:

score: 5
Accepted
time: 11ms
memory: 85740kb

input:

384 10 400
5035229 1 991655 5533662
3603482 1 2507601 7562718
5564194 2 764732 3227992
2466016 2 2495702 4550403
6766088 2 3142475 5911283
2726868 2 4510137 7355752
9404587 2 5109287 8165169
2169510 2 7000147 9851527
3629740 3 398130 3003575
6971019 3 2216012 3940047
628399 3 3532328 6065713
2944502...

output:

6065596
4511772
4004006
4007738
-1
4579455
6123769
-1
-1
-1
8864479
6635331
9234073
8728976
4349712
-1
8551795
5250940
8317155
-1
5070960
6239584
5712384
7831379
5747330
6977275
7371654
-1
5955290
6550596
-1
3910169
-1
-1
-1
4515762
-1
8211029
5174090
7301418
7836710
6516404
-1
-1
-1
7244133
-1
-1
2...

result:

ok 400 lines

Test #32:

score: 5
Accepted
time: 11ms
memory: 85768kb

input:

386 5 400
3010571 1 265473 1846840
2931577 1 1009009 2278090
4163727 1 1660173 2587461
2092776 1 2015508 3242745
279381 1 3058966 4314701
4905437 1 3572796 4734963
4329741 2 854858 2943240
73617 2 1885920 3917828
1622531 2 2976368 4562943
4125968 3 440520 2111757
1631785 3 1352001 2688897
3406030 3 ...

output:

3568000
3571983
-1
3233575
2869780
-1
-1
2585663
2857727
-1
-1
3295297
2968050
3907981
-1
3748559
2835948
-1
2891425
-1
3070756
-1
1834919
-1
-1
2300471
1661432
1456564
3670895
1153404
-1
-1
-1
1773890
-1
-1
-1
3618682
2877529
2668980
-1
-1
-1
536976
2237487
-1
4335810
-1
1572944
3014847
1728098
271...

result:

ok 400 lines

Test #33:

score: 5
Accepted
time: 16ms
memory: 85732kb

input:

316 2 400
825956 1 100175 903953
426154 1 462872 1088377
897101 2 84589 1210058
1487006 1 1372976 1883084
2385585 1 1662844 2102052
1714347 1 1755052 2442517
1453071 2 1418917 2388314
2672491 1 2743402 3245198
3705056 1 2916952 3350163
2988636 1 3127404 3532645
3396694 2 2784626 3321007
3573433 2 28...

output:

408731
-1
567142
-1
-1
502240
-1
686438
874926
-1
813343
441601
798727
827209
-1
244251
558194
388456
306390
-1
-1
-1
628285
514421
661655
140600
685138
-1
251463
339872
316658
760875
224380
128970
-1
302566
317573
216406
256466
335239
299944
510629
-1
-1
1091691
571134
-1
590537
201583
152020
58079...

result:

ok 400 lines

Subtask #2:

score: 7
Accepted

Test #34:

score: 7
Accepted
time: 502ms
memory: 107776kb

input:

60000 400 60000
36444793 284 3080519 96564525
76562130 166 22994125 59743695
76399902 168 29694545 59255380
66355790 132 10949454 89347938
40903435 35 29985718 66394219
83300910 368 17240174 54080010
85941830 363 31462093 87304647
73742613 40 29005856 54988711
27852051 29 6132393 88092297
52011498 2...

output:

4187955
12063529
12900463
3226307
10559309
3630811
3464102
2349487
10593270
4352751
12206074
3330919
9918520
2273900
2815160
3343146
4784218
4029015
3675912
3097583
3111953
3134642
2032575
7047105
2656134
3152545
4173492
4454062
10276964
8571917
2565070
2916843
3188475
2240657
2534321
4044412
133767...

result:

ok 60000 lines

Test #35:

score: 7
Accepted
time: 255ms
memory: 90768kb

input:

60000 6 60000
12 3 7 15
10 1 6 8
2 1 12 12
3 6 10 13
13 4 10 12
7 4 11 15
2 2 11 12
11 2 1 1
2 4 15 15
12 2 7 13
7 4 1 10
10 3 4 8
9 6 12 13
12 6 6 15
9 1 13 13
1 5 7 15
7 2 6 8
8 3 15 15
8 6 9 12
11 6 10 12
6 4 2 12
6 3 8 11
6 1 9 10
1 3 8 12
6 1 9 9
1 4 13 14
6 2 13 13
15 3 9 9
8 4 8 15
10 2 12 13...

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 60000 lines

Test #36:

score: 7
Accepted
time: 492ms
memory: 105172kb

input:

60000 10 60000
97676569 2 76743953 88685974
95105143 4 43932988 73376067
76288333 6 92617916 98270964
90342208 3 40402911 69639648
33843177 10 26986536 90194147
6267732 5 63608012 88523254
7434115 6 32023864 61989797
11761897 6 21980809 94495856
66188528 1 73264146 82110042
59171955 3 14277338 57524...

output:

50934
77902
89165
70557
268052
116409
122462
34028
87774
446481
473777
43573
80880
71259
189355
220880
97525
233847
48942
76322
115779
86109
56783
97528
179902
64312
209077
130350
64127
304725
133009
34783
37976
73757
147651
110108
795553
38989
182712
57437
50691
37940
48662
526097
42900
75153
11829...

result:

ok 60000 lines

Test #37:

score: 7
Accepted
time: 444ms
memory: 105732kb

input:

60000 400 60000
35357917 106 38293412 94684300
83145885 104 8061264 45893965
34223214 63 89162022 92650692
17695158 303 7424324 16020399
80070382 360 36955678 84009798
92884003 244 82495997 98341121
35439223 250 58780027 74572027
65965217 348 62649096 64088389
81335145 154 16142185 56577974
61230381...

output:

4170388
10792534
4724031
9387143
-1
6113543
8419841
23129757
6935973
29089230
7150447
5429311
8848619
14220725
20216868
23459463
5977906
15120565
41700105
6291030
4346034
5828001
45713909
6915393
6394853
21183057
11929675
5675125
11188911
14125526
5203543
8659023
6877604
6884320
6842338
7762496
1908...

result:

ok 60000 lines

Test #38:

score: 7
Accepted
time: 477ms
memory: 106016kb

input:

60000 133 60000
20561991 86 25005935 61459650
26163084 90 46712018 76015341
35834416 95 29938241 83277292
91275144 36 3356508 79165872
45288993 129 33990712 50967656
23921464 4 2998749 83297148
90941504 98 41664456 94454241
35313504 42 21268586 90068636
33306098 121 27129638 83989086
59369734 133 24...

output:

4597679
1257253
1314315
1373379
746395
537598
1613056
1637922
1780770
2843637
1991792
2064448
724258
1046206
1003720
2065020
591046
728719
1765032
1529035
13009813
1213686
1242642
931843
1378061
1157507
616607
1812210
1742210
2435659
638669
1548908
1256669
746799
1916543
8344670
686201
2404961
14118...

result:

ok 60000 lines

Test #39:

score: 7
Accepted
time: 418ms
memory: 108944kb

input:

60000 11 60000
95017156 10 22055983 90540383
7214864 7 14505589 66729981
65618447 6 48075996 53916145
123143 10 4760078 75371216
63341349 7 44971994 83435307
65310969 7 28239153 64911494
38123767 11 3377065 60114696
58277623 8 32084862 53967693
96681909 7 33233164 99855578
19666257 9 5627734 6290910...

output:

336705
104860
94205
82790
43288
40651
54832
28163
26506
30596
18983
3739744
20887
31829
24015
41604
153894
41350
81612
57862
15729
86895
1025322
85802
221405
64158
87330
25630
29428
154778
77426
51096
24605
36197
50346
31159
33378
281265
53463
46743
39470
72112
21370
114028
51358
44094
24340
416178
...

result:

ok 60000 lines

Test #40:

score: 7
Accepted
time: 389ms
memory: 103116kb

input:

60000 20 60000
3425512 19 16018000 16549195
10119402 11 8238845 16194063
10268408 11 15839413 17100868
4399617 5 3259484 4732648
199676 11 16086296 18995937
1727842 8 7277268 16676508
6474927 13 3162304 7105628
5016549 5 5938383 19855399
5926152 13 4855095 17355188
3087266 8 918517 7822928
16432449 ...

output:

253004
164343
232146
348438
360215
141068
145249
260283
149276
224327
147694
259280
162914
254661
1130872
136138
2375633
153368
185090
175856
1274299
113654
143624
295611
244227
806555
200464
155743
162868
290566
166144
71081
221297
8732626
139680
140421
659251
484516
74592
1250711
143657
173489
143...

result:

ok 60000 lines

Test #41:

score: 7
Accepted
time: 415ms
memory: 103176kb

input:

60000 3 60000
18673433 3 5585202 14635377
783826 3 11774363 16770680
19553752 3 10057954 17405901
4686021 1 4633378 18808990
18193494 2 15475163 18023941
15045870 3 12037490 19440676
11189780 3 1998254 15563641
3689200 3 699453 762315
7205586 3 17614893 19586647
16220843 1 18388083 19723996
1728659 ...

output:

3099
6500
24888
159696
60871
7776
174516
17016
8163
99508
4769
17386
24043
11185
9724
707674
29885
13169
6701
9941
13405
7064
7448
26080
11853
58158
11457
48607
16725
10039
36762
11451
4153
168849
27848
11330
5740
42907
7483
28817
6565
3626
5997
15279
21600
32873
187015
9779
6529
9374
67572
13026
26...

result:

ok 60000 lines

Test #42:

score: 7
Accepted
time: 347ms
memory: 100464kb

input:

60000 5 60000
688239 1 1054551 1343759
180973 3 497075 543586
337167 3 853273 1769056
60342 3 262629 1916130
1563480 4 1419078 1530443
84479 1 1303616 1532279
514760 3 1511339 1772340
1583589 2 1633329 1783278
661787 5 736596 838091
1897157 2 1257190 1706268
1811663 1 100494 1797523
1622587 3 597834...

output:

12775
30199
38298
11590
55744
46051
47873
205893
90941
11330
8429
155284
84714
22339
18291
22005
36006
107643
110640
6161
25783
8564
31237
43086
27217
11362
16355
19282
16106
22465
40238
15981
17089
178549
36923
36752
53890
29567
21658
69362
48443
42018
22113
15784
78102
80409
61986
29617
8337
50702...

result:

ok 60000 lines

Test #43:

score: 7
Accepted
time: 367ms
memory: 100648kb

input:

60000 3 60000
2425933 1 1811168 2386010
1213569 1 1889604 2840745
1478278 1 874669 1590117
2807897 1 877927 2372459
1930604 3 662123 2545391
876201 3 317724 826102
1449373 2 1675828 2380928
562301 2 1338095 2549254
1023244 2 1785507 2886222
1848152 1 1753661 1999058
395709 2 1003035 3199243
1119344 ...

output:

6038
16852
6587
14319
4389
23142
110231
47901
26822
8757
169894
12226
22788
8932
21262
22982
46761
43432
7783
36162
28620
40483
17611
15331
98527
29128
18100
13254
51380
5983
32995
31639
3990
9003
27542
37097
17525
41749
8985
14129
5500
3854
79098
31518
10564
14931
11144
13924
50621
18356
20261
6961...

result:

ok 60000 lines

Test #44:

score: 7
Accepted
time: 319ms
memory: 100908kb

input:

59781 246 60000
37315959 1 60993 99801213
76422704 2 88569 948439
14046020 2 543599 1279657
8374607 2 1004457 1945741
40067097 2 1338158 2303255
21899560 2 1746120 2825984
31273845 2 2132469 2850232
26597475 2 2503612 3492829
43356396 2 2943290 3988444
11289373 2 3344028 4106971
45437891 2 3774846 4...

output:

74578823
76622648
73013434
90108506
51063886
73484565
48933151
72717340
-1
68961157
79954801
59001008
90732554
59750192
79321767
71427344
80948126
61836047
89246282
51759106
74064984
70128274
74145048
69402100
94406801
72222897
72756632
77956608
85049892
77741101
72834534
74127885
90290101
83721623
...

result:

ok 60000 lines

Test #45:

score: 7
Accepted
time: 284ms
memory: 103072kb

input:

60000 347 60000
66470962 1 12826942 88787444
86900368 2 26159482 73535463
71831560 3 6947936 58675484
78456057 3 32109463 90799791
99998804 4 15159826 59583172
37152313 4 31304630 68812769
5921233 4 40345601 93379104
12728410 5 4699578 44749006
69362307 5 32236449 64778266
97857017 5 35540293 809808...

output:

-1
64729533
-1
91994238
-1
65471365
69300455
79080511
93176276
-1
73186318
-1
-1
-1
-1
95110018
87449029
-1
-1
-1
-1
-1
-1
87751972
-1
91552158
71282793
-1
95490060
86455367
72476616
-1
-1
-1
49358706
63150818
-1
59953591
53296970
62747579
-1
-1
87304894
74845329
-1
-1
-1
-1
67781505
-1
-1
85598754
...

result:

ok 60000 lines

Test #46:

score: 7
Accepted
time: 168ms
memory: 94444kb

input:

60000 400 60000
100000000 1 1 100000000
100000000 2 1 100000000
100000000 3 1 100000000
100000000 4 1 100000000
100000000 5 1 100000000
100000000 6 1 100000000
100000000 7 1 100000000
100000000 8 1 100000000
100000000 9 1 100000000
100000000 10 1 100000000
100000000 11 1 100000000
100000000 12 1 100...

output:

99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
999...

result:

ok 60000 lines

Test #47:

score: 7
Accepted
time: 272ms
memory: 103072kb

input:

60000 198 60000
9095432 1 243193 771137
80236303 1 520439 874178
52146000 1 783121 1218256
35112073 1 949649 1545731
82268717 1 1149632 1668684
94054028 1 1520430 1939451
81189681 1 1885284 2286648
38906762 1 2151861 2696551
67991246 1 2455831 2981421
5951258 1 2544989 3313394
40346333 1 2957553 350...

output:

63321871
50195826
63147933
97291569
48592665
68629670
66739076
62707302
55018992
56455530
63519133
69857648
50938615
57769659
67061065
76767092
50053030
94433064
-1
52324182
66082894
60515406
-1
62168993
90238451
76826044
94434260
49303319
70985440
70265477
66336267
79427614
62986133
60065241
592082...

result:

ok 60000 lines

Test #48:

score: 7
Accepted
time: 319ms
memory: 100768kb

input:

60000 60 60000
98321395 1 8927 214763
68612679 1 123603 354938
35190718 1 210529 417336
61078644 1 329607 536731
53207463 1 373484 599622
48877415 1 537000 687679
31041929 1 614795 823539
49692897 1 734670 913854
59218351 1 754962 933816
65359961 1 893012 1075686
87351898 1 935909 1125846
48806010 1...

output:

45705196
52195993
95575646
53143537
78885385
45399284
80017113
54140330
87569701
39897014
75127428
74984434
79967311
68464764
48954190
69104414
60255318
76963073
83862626
80543415
73451548
89921740
51899795
95716878
55554915
76799026
75176115
66076680
57679193
76102903
77824168
79060140
71112800
692...

result:

ok 60000 lines

Test #49:

score: 7
Accepted
time: 373ms
memory: 103356kb

input:

60000 7 60000
40841429 1 1012 24513
68294018 1 11502 34849
81622562 1 33076 46768
22649411 1 33743 64990
37642709 1 53197 75824
12118727 1 56118 85129
38708722 1 70155 100781
27594550 1 81745 111481
62690 1 97653 122234
24384345 1 105288 129466
1328113 1 114498 142953
10830110 1 132461 152267
314372...

output:

66869082
61724092
65491542
44706122
35990332
77575183
52585229
32426183
48786578
30655237
62526724
52139867
46136859
41361333
29622578
58939948
28765458
53336522
74371698
85494901
28234193
69848438
30928704
37790814
22809402
56440597
27088725
42806668
74285070
38343485
18856777
15620780
40346452
407...

result:

ok 60000 lines

Test #50:

score: 7
Accepted
time: 219ms
memory: 100464kb

input:

57343 10 60000
18818 1 6425 26332
94952 1 14701 39520
4737 1 23921 54364
55499 1 42222 59730
16452 1 47605 74897
15088 1 57708 85132
96250 1 74157 96442
46432 2 774 28649
50622 2 18597 30787
42239 2 23538 49282
30883 2 35977 51551
89244 2 42001 67859
76185 2 55577 79336
5414 2 63617 87452
48371 2 79...

output:

39965
63837
55886
66807
39596
63967
79010
-1
48179
47580
-1
43070
-1
32096
-1
41924
52198
31438
-1
30946
-1
-1
-1
36227
54041
53833
-1
56476
59800
67516
-1
-1
67449
-1
80230
-1
-1
-1
58401
44913
48300
-1
39813
-1
-1
49904
-1
32342
80990
93929
49115
-1
-1
48891
74039
60027
57794
52127
-1
74178
-1
-1
...

result:

ok 60000 lines

Test #51:

score: 7
Accepted
time: 252ms
memory: 101960kb

input:

56600 5 60000
65920 1 5980 18734
5761 1 7167 22737
55716 1 16279 25828
2919 1 21166 35716
46655 1 29979 41388
98441 1 36931 44263
43391 1 42223 55259
92877 1 44038 59423
83779 1 54848 64556
18508 1 56992 72667
52190 1 68248 76115
85779 1 73934 86788
50232 1 78351 92741
40549 1 85228 97793
52115 2 44...

output:

27283
59033
-1
-1
31997
26260
37170
49830
36974
63752
27771
35169
50860
37462
56254
38832
19761
50142
34944
43468
-1
39958
44914
63654
-1
14281
84546
57939
68663
-1
37038
39397
-1
33155
-1
70049
25879
45707
52142
83501
49303
57787
64583
12836
20946
30246
36347
58667
78187
79150
36651
50623
30268
208...

result:

ok 60000 lines

Test #52:

score: 7
Accepted
time: 260ms
memory: 100296kb

input:

58144 20 60000
688620 1 21557 49553
947126 1 34398 73528
653491 1 57311 91664
841951 1 74082 134953
115951 1 96961 144546
759921 1 124937 178368
908401 1 143934 197373
396191 1 175446 218185
488430 1 197390 244525
634238 1 211085 270897
162428 1 229098 283496
182601 1 260626 296706
303257 1 294617 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
...

result:

ok 60000 lines

Test #53:

score: 7
Accepted
time: 279ms
memory: 103628kb

input:

59464 200 60000
2352378 1 108912 535536
2878912 1 291617 657900
2005814 1 418310 833378
2638419 1 612534 1048686
1916673 1 839703 1194535
1024871 1 1102969 1416313
1802959 1 1244102 1704391
487562 1 1496813 1872417
2523590 1 1729293 2072949
2532229 1 1777304 2299568
1468307 1 2012813 2475395
1535590...

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 60000 lines

Test #54:

score: 7
Accepted
time: 324ms
memory: 102320kb

input:

57706 10 60000
493336 1 19737 85323
328969 1 53060 115770
2011146 1 82661 130140
42028 1 102428 160444
2270581 1 131762 206271
898573 1 163482 208451
3148819 1 195115 247064
2787613 1 212612 290923
705223 1 246364 298546
1156550 1 275641 350520
1469854 1 303755 358967
222303 1 326827 402431
2503196 ...

output:

2933594
1451023
1431485
2343312
1312240
791238
2013472
1466295
1012478
2487842
1368806
1768772
2938981
1390999
2426851
2014093
2006880
800391
2382933
1785060
1030365
1363946
952305
1976991
1209162
1584907
2522414
1438505
1522775
2011021
2372154
1238304
2016718
1398714
1781171
-1
1358780
777118
20115...

result:

ok 60000 lines

Subtask #3:

score: 10
Accepted

Test #55:

score: 10
Accepted
time: 1554ms
memory: 151272kb

input:

300000 60000 300000
52373645 39403 1 100000000
43175904 13875 1 100000000
55098270 40348 1 100000000
69248668 7569 1 100000000
69220659 14654 1 100000000
92585410 38487 1 100000000
41202983 28786 1 100000000
47874378 18728 1 100000000
7254419 14009 1 100000000
94592111 3845 1 100000000
19140558 2773...

output:

92572089
63051875
55804501
78575450
50003943
64449610
77271421
79106905
88880648
66025353
53245307
51023237
86239431
91432097
87018571
92214104
69302202
54090222
65223782
68084182
58672001
90191125
85664165
63548306
82947149
55401007
64762457
63374228
94614576
87656737
56978090
65217216
84550646
907...

result:

ok 300000 lines

Test #56:

score: 10
Accepted
time: 2449ms
memory: 144200kb

input:

300000 10 300000
93040678 2 1 100000000
59271814 5 1 100000000
37316939 8 1 100000000
7478119 1 1 100000000
1695217 7 1 100000000
57516451 5 1 100000000
6907995 5 1 100000000
60245146 4 1 100000000
82808072 3 1 100000000
9265646 1 1 100000000
7368378 6 1 100000000
31872639 3 1 100000000
99601010 4 1...

output:

5522
7334
5517
2562
2839
6098
2327
6405
2457
3772
2634
1727
4941
4466
5574
5731
5793
2915
2027
4940
2202
2505
6708
6735
2732
4969
5347
3220
6029
3392
3863
5132
3226
6882
7947
3618
1768
3015
9197
2585
3661
4680
3135
6374
9735
3804
12169
4088
2912
10938
1852
5842
3159
4684
4750
6077
3217
3744
2394
871...

result:

ok 300000 lines

Test #57:

score: 10
Accepted
time: 1333ms
memory: 187000kb

input:

300000 300000 300000
62727489 164656 1 100000000
56688078 181426 1 100000000
87141202 280365 1 100000000
11940497 141243 1 100000000
8793046 30906 1 100000000
66192492 103691 1 100000000
31724326 163318 1 100000000
23002584 222628 1 100000000
89415131 247427 1 100000000
35793293 211558 1 100000000
3...

output:

83436767
75334936
90660033
93135398
53429084
63545636
54790247
77936981
74925509
59663525
80162740
94200111
70138738
50803680
54765524
82855965
62057278
71446316
97905809
98702385
55324128
58922728
97145730
69786508
70039441
70155139
94518126
53350617
64444219
53404884
65490783
65833435
87799151
539...

result:

ok 300000 lines

Test #58:

score: 10
Accepted
time: 1511ms
memory: 157640kb

input:

300000 100000 300000
86166636 69539 1 100000000
17336389 10063 1 100000000
37480784 94541 1 100000000
14768768 41502 1 100000000
65398063 11337 1 100000000
84266136 19350 1 100000000
64067932 51281 1 100000000
41653502 43565 1 100000000
57066599 66302 1 100000000
27290210 38110 1 100000000
63284257 ...

output:

81900509
64888498
61040421
55451433
75576041
78273439
83697069
57387003
69218685
99039588
67133217
52606265
96344642
66926298
79096296
61111960
82210973
92972383
87870482
95248534
93326517
92431469
55383263
73378065
72330099
87228664
77974854
81356924
89024375
85274195
63788288
58628265
56764216
880...

result:

ok 300000 lines

Test #59:

score: 10
Accepted
time: 2379ms
memory: 143144kb

input:

300000 1 300000
17930182 1 1 100000000
20590273 1 1 100000000
39597199 1 1 100000000
20392086 1 1 100000000
78804082 1 1 100000000
52441457 1 1 100000000
55261461 1 1 100000000
12414102 1 1 100000000
77727582 1 1 100000000
8239755 1 1 100000000
32698480 1 1 100000000
42674452 1 1 100000000
63968433 ...

output:

342
31
213
38
189
117
285
83
6
92
78
641
117
367
38
422
176
221
33
41
198
29
207
245
94
448
164
50
191
109
392
278
300
72
101
266
35
88
155
514
152
205
364
291
482
7
94
48
23
53
13
334
333
65
340
115
105
44
178
11
137
27
83
206
46
41
88
79
258
218
65
112
21
437
92
64
37
79
44
30
54
294
5
25
298
254
...

result:

ok 300000 lines

Test #60:

score: 10
Accepted
time: 2480ms
memory: 143764kb

input:

300000 5 300000
27129595 4 1 100000000
56190752 2 1 100000000
95058256 5 1 100000000
41889597 4 1 100000000
54780172 3 1 100000000
43678932 2 1 100000000
75144995 2 1 100000000
18485880 4 1 100000000
69020362 5 1 100000000
44398591 5 1 100000000
71893878 3 1 100000000
58265982 4 1 100000000
56498652...

output:

2103
1321
1163
1011
2007
1052
600
3080
1553
2864
2132
809
3934
1502
4273
1311
1125
1220
1695
1903
1881
2115
1613
1593
827
575
1194
1595
2034
2063
1431
2289
933
2894
2896
1000
2478
3621
934
1524
1036
959
2247
2988
1324
1389
1597
1319
1402
3806
822
1696
1309
2219
1140
1943
1651
2239
2471
1460
1493
414...

result:

ok 300000 lines

Test #61:

score: 10
Accepted
time: 1284ms
memory: 184888kb

input:

300000 300000 300000
94528071 1 1 100000000
39684883 2 1 100000000
90568273 3 1 100000000
6631012 4 1 100000000
23285495 5 1 100000000
46426324 6 1 100000000
71957355 7 1 100000000
88230489 8 1 100000000
12303444 9 1 100000000
49280890 10 1 100000000
11151843 11 1 100000000
83445104 12 1 100000000
4...

output:

78260396
68271786
62691214
70632402
72254983
81306489
78988742
85032041
77786482
65329883
58428265
77900210
85198342
53710904
55385193
82894070
77807178
86604124
52221042
70340048
53901373
70607364
97817787
52807002
52209599
57077276
82147725
92635695
52081762
90178910
90489279
57461149
82718476
761...

result:

ok 300000 lines

Test #62:

score: 10
Accepted
time: 1197ms
memory: 156320kb

input:

300000 100166 300000
59136436 1 1 100000000
51190433 1 1 100000000
17606146 1 1 100000000
60969159 2 1 100000000
48459752 2 1 100000000
74247907 2 1 100000000
92319606 2 1 100000000
72885303 3 1 100000000
98569041 3 1 100000000
84356906 3 1 100000000
53724960 3 1 100000000
44400800 4 1 100000000
366...

output:

84337365
58453069
71484240
94965177
51883089
80689854
66923402
89101954
71169601
53325319
92119752
96009119
70608673
92605810
53729373
80378875
78458856
64416267
72615534
79143621
91907813
87906166
55382327
62742829
95717778
65081688
75336018
49627395
94780175
95522149
98797677
95795044
55365227
638...

result:

ok 300000 lines

Test #63:

score: 10
Accepted
time: 1375ms
memory: 146872kb

input:

300000 30048 300000
74582749 1 1 100000000
5799290 1 1 100000000
31752670 1 1 100000000
17258583 1 1 100000000
56845218 1 1 100000000
51635817 1 1 100000000
900108 1 1 100000000
27225561 2 1 100000000
64124035 2 1 100000000
26291772 2 1 100000000
58001042 2 1 100000000
60526138 2 1 100000000
4795228...

output:

87564347
69327130
55966183
56692477
51733435
49220473
44282280
75996025
54351711
58891035
73131189
49662728
61544976
44404010
50957395
61173489
41971057
52510826
51260853
49122854
71245841
81860613
45874211
80976620
60405648
75597172
42648646
44437987
39772800
43121836
42669491
74393629
54936563
868...

result:

ok 300000 lines

Test #64:

score: 10
Accepted
time: 2040ms
memory: 143000kb

input:

300000 300 300000
93263765 1 1 100000000
45659360 1 1 100000000
66203805 1 1 100000000
32816640 1 1 100000000
40871405 1 1 100000000
22078617 1 1 100000000
21634161 1 1 100000000
88990266 1 1 100000000
28294009 1 1 100000000
3429140 1 1 100000000
20512056 1 1 100000000
94632829 1 1 100000000
7519341...

output:

235516
430655
422071
410869
400614
535448
369737
427713
494220
283088
469413
301013
337455
329289
498479
265910
394924
417055
414432
338721
482400
394817
325734
392365
288711
356803
405046
478179
293479
452759
566123
464585
520264
576216
317142
365983
414882
528215
447370
277049
417175
510030
452771...

result:

ok 300000 lines

Test #65:

score: 10
Accepted
time: 1478ms
memory: 141224kb

input:

293048 20 300000
962119 1 1 100000000
660053 1 1 100000000
574253 1 1 100000000
372305 1 1 100000000
730726 1 1 100000000
12422 1 1 100000000
368149 1 1 100000000
850258 1 1 100000000
292975 1 1 100000000
26018 1 1 100000000
820861 1 1 100000000
565116 1 1 100000000
350173 1 1 100000000
245878 1 1 1...

output:

17121
5836
12871
9940
11985
14183
21999
8917
9675
12908
16908
14036
15582
8131
11560
8704
5543
22998
16684
16084
11100
9247
11591
26398
27174
11740
10442
8358
14601
20759
18400
12711
19791
16213
11654
8612
13616
9866
10350
7736
9495
17020
16238
7346
8582
9768
10809
23529
11352
13230
11722
6890
22118...

result:

ok 300000 lines

Test #66:

score: 10
Accepted
time: 1455ms
memory: 141976kb

input:

297536 200 300000
1684415 1 1 100000000
2305984 1 1 100000000
938268 1 1 100000000
2799998 1 1 100000000
959483 1 1 100000000
1398011 1 1 100000000
2830108 1 1 100000000
997092 1 1 100000000
2432090 1 1 100000000
1352434 1 1 100000000
1943658 1 1 100000000
333717 1 1 100000000
674221 1 1 100000000
1...

output:

443207
222389
562825
216063
205431
486170
248462
338123
236755
243774
314118
321314
238900
302075
192079
212241
221647
269420
223211
294712
205589
222994
249490
218854
208134
244280
255397
233024
253749
314528
265161
246021
247637
488121
464774
263539
225610
296143
315572
246673
242142
171734
460900...

result:

ok 300000 lines

Subtask #4:

score: 0
Time Limit Exceeded

Dependency #3:

100%
Accepted

Test #67:

score: 23
Accepted
time: 2507ms
memory: 171116kb

input:

300000 6000 300000
18484573 1397 1 37221951
93018724 2863 1 21523237
20760115 1902 1 73572020
47861657 131 1 58366032
16672997 2854 1 70126530
51503726 1792 1 33692342
90778637 2112 1 52570427
19558814 1079 1 1196615
98646915 5883 1 88295729
5460512 2856 1 12409909
31020896 3642 1 33770228
36220207 ...

output:

9937102
14961480
41348977
20178508
27586139
21978693
-1
34525473
11749060
13910506
71983396
56004648
27255252
21440632
49786216
37475360
11801255
-1
25089693
-1
14613134
9509342
14050298
14147766
75991309
60676642
10842631
75290155
-1
11197340
18486285
14513136
10874212
14619610
14914187
13728378
95...

result:

ok 300000 lines

Test #68:

score: 0
Time Limit Exceeded

input:

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

output:


result:


Subtask #5:

score: 35
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Test #84:

score: 35
Accepted
time: 284ms
memory: 117044kb

input:

60000 60000 60000
83448872 10404 45205919 50339735
36708841 21497 4902082 97712964
34097261 45398 38638183 51297139
10793824 31369 13841638 75803309
51204707 14772 21499849 55137158
82219659 2795 119886 66450614
14512608 10489 32690793 59504916
7128543 8635 32417983 76142161
26155257 31971 17794475 ...

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 60000 lines

Test #85:

score: 35
Accepted
time: 255ms
memory: 112304kb

input:

60000 60000 60000
26989146 13025 40176777 71274092
7743106 53247 23734982 74432610
30238327 36264 31943653 65556194
75722089 29859 78315121 85479538
89149404 25999 93541000 95260000
42357544 56124 30335578 77825467
97660152 9389 32820141 34987282
43766731 31356 64794972 80116226
86359670 45654 78878...

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 60000 lines

Test #86:

score: 35
Accepted
time: 268ms
memory: 111284kb

input:

60000 20000 60000
21887169 9757 44980014 88617023
15799348 14449 42417300 93492725
65903613 280 8541578 96714036
65634926 12308 48355949 66308493
91616141 13693 40188429 97568271
11805078 12288 3578160 62604949
37963126 8636 19073933 93731416
87645266 17252 1663826 89311418
92833534 2976 30732447 83...

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 60000 lines

Test #87:

score: 35
Accepted
time: 299ms
memory: 105440kb

input:

60000 20200 60000
54192085 1 290940 99868075
35950014 2 137511 99768592
47766665 3 236543 99698160
56083303 4 446966 99705427
39348317 5 53683 99745028
49979073 6 372754 99802886
54584535 7 134943 99599799
65085698 8 397064 99534885
52233279 9 390020 99744164
52782808 10 346588 99883898
66503247 11 ...

output:

73871197
74373736
53839505
53029280
71399327
93576974
96107766
51705925
91303398
93752491
64751633
53786316
66176419
52425843
70528639
94507029
66671237
74503800
61726946
70077467
66241361
71743285
83199713
57818452
56901469
87094125
60059572
88134671
71363063
85435975
90387382
93694299
52548784
563...

result:

ok 60000 lines

Test #88:

score: 35
Accepted
time: 371ms
memory: 108824kb

input:

59929 30173 60000
64110568 1 213141 99926158
41434177 2 200079 99540962
47826435 3 292 99474845
48660536 4 284117 99879520
36699562 5 110601 99954778
36421422 6 424857 99457340
50987418 7 396422 99918556
59673912 8 46361 99487481
35366242 9 357149 99971334
33637989 10 329517 99499849
50719105 11 544...

output:

46357729
82864222
54943664
91583526
59551332
77333866
48492803
94942774
77752465
92169702
85195226
60315562
80866639
58324038
78259223
73338018
74616374
54509462
70654558
70914727
78846423
96944791
88966974
59708957
70141532
-1
72648365
98229606
78318238
81126713
62572765
64638573
72701481
61553218
...

result:

ok 60000 lines

Test #89:

score: 35
Accepted
time: 284ms
memory: 104952kb

input:

59824 6232 60000
55256092 1 161472 99625320
35331829 2 112788 99669382
38080628 3 97183 99824466
46320708 4 75885 99785855
55938095 5 285904 99805339
53821260 6 255661 99835264
51688882 7 276129 99582067
51584453 8 13444 99927494
40098775 9 110942 99642754
52593558 10 221099 99843849
39771648 11 177...

output:

65445691
56513948
86625192
86072853
54118391
49487408
84921718
61934332
58310068
95575057
51321104
65809650
74576549
51974220
45384258
69478076
76621993
88984964
83477324
46544450
54048974
64307136
51416697
-1
53391567
91200503
68569367
81143004
70629330
89233328
65621154
66948899
92614091
69757351
...

result:

ok 60000 lines

Test #90:

score: 35
Accepted
time: 330ms
memory: 108088kb

input:

60000 20283 60000
44332374 1 8805560 84151994
42640311 2 16708787 87174972
40358149 3 1990151 96793337
63028923 4 5783502 95423596
61353536 5 8944226 92579861
65122909 6 11059607 87266873
36908657 7 5408757 93010554
55630318 8 7160124 83960192
63547966 9 17526732 97980070
36516867 10 3903943 9056879...

output:

92191999
-1
72643913
-1
-1
55815473
98469421
-1
77229479
-1
-1
61602285
85201886
-1
-1
-1
60353778
-1
63956580
68008694
90056653
89992194
67260799
86460366
-1
51826870
-1
-1
-1
-1
78417781
62193258
68395618
-1
96582135
-1
-1
51685844
-1
-1
73947714
54370604
72962145
-1
-1
80535533
62600745
73094731
...

result:

ok 60000 lines

Test #91:

score: 35
Accepted
time: 284ms
memory: 110408kb

input:

60000 30245 60000
56586759 1 70656 90725255
63653216 2 12721119 95074262
63511027 3 9870766 85826227
62820395 4 4448570 99563341
44950010 5 1060738 96445163
65922518 6 2393163 93847061
55954225 7 17011212 80903879
66634594 8 6447235 92428471
45206104 9 17649557 84615256
52164344 10 5997635 84946783
...

output:

87187134
-1
-1
-1
58268459
92219910
51513742
-1
49034897
83153637
75817159
91996038
-1
-1
-1
-1
92727685
-1
62422043
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
83253213
62115189
82612630
-1
51355946
-1
-1
79888005
-1
-1
87987665
67102091
90784217
86077779
91503480
-1
67815314
-1
-1
66782288
81195103
-1
764585...

result:

ok 60000 lines

Test #92:

score: 35
Accepted
time: 288ms
memory: 102368kb

input:

60000 6329 60000
34498149 1 14974904 83685300
37496455 2 11686690 85640667
65750949 3 10443887 94429579
62026638 4 14942837 97478275
35814731 5 10722264 97199152
38613944 6 7511738 89702382
45293992 7 9877993 98461712
58551288 8 13539231 84423655
37829839 9 4581944 85022210
52387956 10 7469405 91145...

output:

68913951
-1
80224236
67033071
75180367
86773851
-1
-1
-1
58977296
50511499
-1
-1
75877069
69034280
78103276
-1
-1
88030690
76637348
-1
-1
-1
-1
89521368
67786858
49424016
-1
-1
80065107
77176521
88026358
67961905
54600350
-1
-1
-1
-1
98263414
-1
-1
60634981
-1
65847737
85763865
68492884
-1
94298217
...

result:

ok 60000 lines

Test #93:

score: 35
Accepted
time: 58ms
memory: 105772kb

input:

60000 60000 60000
100000000 1 1 100000000
100000000 2 1 100000000
100000000 3 1 100000000
100000000 4 1 100000000
100000000 5 1 100000000
100000000 6 1 100000000
100000000 7 1 100000000
100000000 8 1 100000000
100000000 9 1 100000000
100000000 10 1 100000000
100000000 11 1 100000000
100000000 12 1 1...

output:

99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
99999999
999...

result:

ok 60000 lines

Test #94:

score: 35
Accepted
time: 281ms
memory: 116840kb

input:

60000 60000 60000
16339245 1 2218138 77791950
47248877 2 18813525 90071122
2654615 3 12259018 95574172
69984277 4 15161524 82900076
99851796 5 15758755 77921090
70271618 6 6324312 67399339
4577070 7 8309705 80123332
71277394 8 18729993 81890129
71343340 9 6583393 99431819
11320368 10 11085365 694986...

output:

-1
-1
-1
-1
-1
95270274
-1
-1
-1
-1
94373844
-1
-1
67745083
-1
-1
-1
-1
56903073
-1
-1
-1
76322217
83646981
90739863
-1
-1
68469133
-1
80833421
-1
91659503
-1
89209594
-1
-1
-1
82192307
-1
74569307
-1
-1
52425375
80045773
-1
-1
55246473
-1
88268482
-1
99099616
-1
-1
-1
-1
-1
63184598
-1
-1
-1
-1
-1
...

result:

ok 60000 lines

Test #95:

score: 35
Accepted
time: 329ms
memory: 110620kb

input:

60000 30074 60000
89888090 1 4180397 49507769
20333619 1 34892071 63427705
17502748 1 44045027 88682201
1698279 2 29087134 86152459
91720076 3 26244615 85650552
67073044 4 8767602 54174880
3776236 4 48054218 76508224
3649823 5 1814572 68775379
83368360 5 41896456 96524612
51226727 6 12329678 4559298...

output:

-1
-1
97030854
-1
80101408
-1
-1
-1
-1
-1
69737525
-1
-1
53245530
-1
50889530
56101558
-1
-1
64842625
-1
60134092
88841267
82127034
-1
-1
-1
65933370
-1
-1
-1
-1
-1
-1
-1
-1
95345904
-1
-1
56007127
-1
-1
57892729
-1
99340639
-1
-1
-1
74004519
73230282
-1
-1
-1
-1
-1
-1
-1
99194792
-1
-1
70323372
-1
...

result:

ok 60000 lines

Test #96:

score: 35
Accepted
time: 288ms
memory: 107140kb

input:

60000 19995 60000
63436934 1 6959658 55373917
50995801 1 27354459 75458812
7205716 1 49175831 82475200
22632434 2 21369093 68047582
73280964 2 32008927 78985766
4280471 3 5096275 48922580
45174572 3 38284414 65249708
62183941 3 57816618 83845014
81108713 4 11010190 52868597
1492412 4 20745689 754387...

output:

51936906
52300668
63899210
-1
-1
-1
93403461
58615560
57338264
-1
-1
-1
75436567
56335080
51050541
-1
-1
-1
63703132
74853247
95815864
85135658
-1
-1
83840928
-1
86595657
-1
96488233
-1
-1
-1
87048930
-1
84874624
-1
-1
-1
56033563
-1
-1
-1
61475028
-1
81997339
83943157
76320633
74364577
83950269
745...

result:

ok 60000 lines

Test #97:

score: 35
Accepted
time: 336ms
memory: 102936kb

input:

60000 6662 60000
54473104 1 4041439 31658630
253754 1 15051368 56216917
54461353 1 37509729 62782282
93350711 1 53203386 79254522
15135489 1 62892001 98696213
36952068 2 179348 31051959
51505177 2 23258340 47451637
37280982 2 39622108 59859676
93533881 2 50715903 83839638
13748100 2 62929693 8716606...

output:

93294480
54447835
67467489
91277049
80857851
-1
-1
85077237
53708010
94959951
54394501
-1
70091637
59034079
72271314
-1
-1
57403838
63781970
80277715
91714490
59539431
88874138
-1
74134708
-1
98321315
-1
86510418
64126282
60920452
89742753
68288559
94318271
64493170
89458391
-1
-1
71341139
63340682
...

result:

ok 60000 lines

Test #98:

score: 35
Accepted
time: 326ms
memory: 100796kb

input:

60000 600 60000
66244725 1 511151 3615528
66761988 1 2302777 6138666
42345137 1 4370239 6979741
88211058 1 5863140 9374220
28715134 1 6806270 11762992
13421143 1 9108644 11899132
92024843 1 10261440 14448004
22154421 1 12512135 16182172
31195210 1 15242785 17883268
61566865 1 16830977 19336547
50322...

output:

54598297
58665123
77476958
53404671
73385013
92157577
69712546
76297101
92733790
73326269
71060930
71326833
84745568
97378844
55276251
76294702
71676212
78850981
75236072
50766440
77626037
72354648
97226126
93934633
71255063
91256199
-1
60017604
67454004
66907429
79775158
90753688
67057495
70895326
...

result:

ok 60000 lines

Test #99:

score: 35
Accepted
time: 101ms
memory: 91964kb

input:

60000 6007 60000
47 1 2 10
32 1 7 15
39 1 11 19
2 1 13 22
1 1 17 25
33 1 21 30
13 1 26 35
27 1 32 39
39 1 33 42
34 2 4 9
31 2 5 16
23 2 9 17
43 2 16 22
40 2 20 27
28 2 22 29
42 2 26 33
48 2 32 39
1 2 34 44
26 3 2 11
14 3 8 16
12 3 10 20
36 3 13 24
13 3 18 27
1 3 23 29
48 3 25 33
40 3 30 37
26 3 33 4...

output:

26
39
33
28
38
31
40
-1
-1
-1
-1
40
38
32
-1
47
-1
-1
-1
34
28
48
-1
44
-1
-1
-1
-1
-1
-1
30
29
-1
-1
-1
35
-1
-1
38
45
-1
-1
-1
-1
29
45
-1
-1
47
26
34
-1
48
27
-1
30
-1
35
41
-1
-1
41
-1
-1
-1
-1
28
28
47
-1
-1
-1
-1
36
-1
49
42
-1
36
38
-1
32
-1
-1
48
-1
-1
33
-1
32
29
-1
44
-1
46
43
39
-1
26
-1
...

result:

ok 60000 lines

Subtask #6:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

0%