QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#402026#5208. Jumbled TreesGraphcityAC ✓45ms8816kbC++202.8kb2024-04-29 19:25:352024-04-29 19:25:36

Judging History

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

  • [2024-04-29 19:25:36]
  • 评测
  • 测评结果:AC
  • 用时:45ms
  • 内存:8816kb
  • [2024-04-29 19:25:35]
  • 提交

answer

#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rof(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int Maxn=2e3;

struct Node{int frm,to,nxt,id;} Edge[Maxn*2+5];
int tot,Head[Maxn+5],h[Maxn+5];
inline void Addedge(int x,int y,int id)
{
    Edge[++tot]=(Node){x,y,Head[x],id},Head[x]=tot;
    Edge[++tot]=(Node){y,x,Head[y],id},Head[y]=tot;
}

int n,m,Mod,X[Maxn+5],Y[Maxn+5],anc[Maxn+5],fat[Maxn+5],sum,cnt,all=-1;
int fa[Maxn+5],dep[Maxn+5],chk[Maxn+5],vis[Maxn+5],deg[Maxn+5];
vector<int> v[Maxn+5]; set<int> st;
vector<pair<int,vector<int>>> ans;

inline int Pow(int x,int y)
{
    int res=1;
    while(y)
    {
        if(y&1) res=1ll*res*x%Mod;
        x=1ll*x*x%Mod,y>>=1;
    }
    return res;
}
inline void dfs(int x,int f)
{
    fat[x]=f,dep[x]=dep[f]+1;
    for(int i=Head[x];i;i=Edge[i].nxt)
    {
        int y=Edge[i].to; if(dep[y]) continue;
        fa[y]=Edge[i].id,chk[Edge[i].id]=1,dfs(y,x);
    }
}
inline void dfs1(int x)
{
    st.insert(X[x]),st.insert(Y[x]);
    vis[x]=1,sum=(sum+h[x])%Mod,cnt=(cnt+1)%Mod;
    for(auto y:v[x]) if(!vis[y]) anc[y]=x,deg[x]++,dfs1(y);
}
inline void Work(int id)
{
    st.clear(),sum=0,cnt=0,dfs1(id);
    cnt=st.size(); cnt=(cnt-1+Mod)%Mod;
    if(cnt==0 && sum!=0) {cout<<-1<<endl; exit(0);}
    if(cnt!=0)
    {
        int now=1ll*(Mod-sum)*Pow(cnt,Mod-2)%Mod;
        if(all!=-1 && all!=now) {cout<<-1<<endl; exit(0);} all=now;
    }
}

int main()
{
    // freopen("1.in","r",stdin);

    cin>>n>>m>>Mod;
    For(i,1,m)
    {
        int x,y; cin>>x>>y>>h[i]; X[i]=x,Y[i]=y;
        h[i]=(Mod-h[i])%Mod,Addedge(x,y,i);
    }
    dfs(1,0);
    For(i,1,m) if(!chk[i])
    {
        int x=X[i],y=Y[i]; if(dep[x]<dep[y]) swap(x,y);
        for(int j=x;j!=y;j=fat[j]) v[i].push_back(fa[j]),v[fa[j]].push_back(i);
    }
    For(i,1,m) if(!vis[i]) Work(i);
    if(all!=-1)
    {
        vector<int> w;
        For(i,1,m) if(chk[i]) w.push_back(i),h[i]=(h[i]+all)%Mod;
        ans.emplace_back(all,w);
    }
    // memset(vis,0,sizeof(vis));
    // For(i,1,m) if(!vis[i])
    // {
    //     sum=cnt=0; dfs1(i);
    //     assert(!sum);
    // }
    queue<int> q; For(i,1,m) if(!deg[i]) q.push(i);
    while(!q.empty())
    {
        int x=q.front(),y=anc[x]; q.pop();
        if(h[x])
        {
            vector<int> w1,w2;
            int k=(Mod-h[x])%Mod; h[x]=(h[x]+k)%Mod,h[y]=(h[y]-k+Mod)%Mod;
            For(i,1,m) if(i!=x && (chk[i] || i==y)) w2.push_back(i);
            For(i,1,m) if(i!=y && (chk[i] || i==x)) w1.push_back(i);
            ans.emplace_back(k,w1),ans.emplace_back((Mod-k)%Mod,w2);
        } if(y && --deg[y]==0) q.push(y);
    }
    cout<<ans.size()<<endl;
    for(auto [k,w]:ans) {cout<<k<<' '; for(auto i:w) cout<<i<<' '; cout<<endl;}
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3656kb

input:

3 3 101
1 2 30
2 3 40
3 1 50

output:

5
60 2 3 
81 2 3 
20 1 3 
91 2 3 
10 1 2 

result:

ok Participant found an answer (5 trees) and jury found an answer (5 trees)

Test #2:

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

input:

2 2 37
1 2 8
1 2 15

output:

3
23 2 
29 2 
8 1 

result:

ok Participant found an answer (3 trees) and jury found an answer (3 trees)

Test #3:

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

input:

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

output:

-1

result:

ok Both jury and participant did not find an answer

Test #4:

score: 0
Accepted
time: 1ms
memory: 3668kb

input:

10 15 997
4 3 459
9 7 94
9 8 767
10 2 877
5 8 258
3 4 166
8 5 621
8 10 619
9 1 316
10 5 516
3 10 125
1 7 961
3 6 500
4 10 976
3 4 842

output:

-1

result:

ok Both jury and participant did not find an answer

Test #5:

score: 0
Accepted
time: 1ms
memory: 3672kb

input:

20 30 9973
1 10 696
3 8 2905
12 7 6609
20 10 1962
11 9 8430
19 2 412
6 3 6936
19 7 9113
14 15 5635
15 7 1770
13 10 3182
3 16 2625
17 1 7387
11 5 3700
9 15 1048
2 3 7717
12 10 8625
7 13 8141
5 14 2245
6 4 2819
18 19 8709
18 5 6191
17 10 7606
9 20 8626
17 4 8848
4 13 1073
10 8 2277
14 2 7714
11 8 5318...

output:

59
9375 4 6 7 10 12 13 14 15 16 17 18 21 24 25 26 27 28 29 30 
7534 4 6 7 10 12 13 14 15 16 17 18 21 24 25 26 27 28 29 30 
2439 4 6 10 12 13 14 15 16 17 18 20 21 24 25 26 27 28 29 30 
7985 4 6 7 10 12 13 14 15 16 17 18 21 24 25 26 27 28 29 30 
1988 1 4 6 7 10 12 14 15 16 17 18 21 24 25 26 27 28 29 3...

result:

ok Participant found an answer (59 trees) and jury found an answer (59 trees)

Test #6:

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

input:

50 80 99991
6 5 67664
39 4 74944
11 9 13035
13 48 81979
40 20 57943
20 31 72081
1 6 39307
48 39 3550
28 48 41071
18 28 42935
37 32 7538
37 29 3815
50 37 88043
38 41 7283
40 26 66278
37 34 60696
47 19 80875
4 26 67
20 32 91858
39 24 83485
45 25 12241
48 46 61691
37 44 47541
39 40 70034
37 42 25006
27...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #7:

score: 0
Accepted
time: 1ms
memory: 3856kb

input:

100 150 999983
84 10 999545
69 48 930138
48 13 303468
36 6 668122
91 84 115623
62 71 59711
12 37 749281
86 49 281976
26 46 624831
91 8 450475
92 55 460900
50 63 513056
72 2 477622
26 96 11359
31 82 953946
6 71 406339
24 7 177090
70 4 67359
31 39 795565
47 32 407459
26 35 760698
22 37 508175
8 93 612...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #8:

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

input:

200 250 9999991
170 185 3242943
70 17 6083198
137 55 4000889
15 171 1113989
108 65 7988488
192 37 8812990
53 143 8707264
80 180 2504807
55 163 2706048
67 64 6210980
87 165 7693967
155 122 8550804
56 99 7228534
114 138 7047731
190 196 6684929
86 197 8866886
38 195 6717874
112 133 7257617
160 104 3210...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #9:

score: 0
Accepted
time: 1ms
memory: 3772kb

input:

500 600 99999989
265 416 47066772
354 266 16969437
195 415 7917612
354 136 43128175
163 191 58723996
144 84 65835385
157 45 94124747
232 441 17509499
70 397 64101208
223 387 7043647
320 47 84970673
100 2 87310855
87 131 75042257
101 391 27645446
79 26 68547739
390 185 92142961
257 15 80922292
276 48...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #10:

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

input:

500 700 99999989
250 2 71289880
454 447 70661327
328 253 57519343
11 201 67456781
294 99 23392419
215 322 61059212
411 389 69899684
488 429 89579827
437 79 60564061
413 380 34922641
477 372 14858185
156 44 3101349
88 8 52225146
115 26 8582010
171 237 33206748
237 495 31192017
146 32 62712576
209 352...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #11:

score: 0
Accepted
time: 1ms
memory: 4332kb

input:

500 800 99999989
258 304 1237432
159 152 6684056
8 47 64155938
436 265 83092505
204 302 3892712
142 302 77925167
37 15 20298972
202 395 35856655
284 260 96812598
365 172 48834835
196 101 64871741
174 45 37729972
302 206 90932677
305 275 27712443
443 157 81820535
16 248 22708463
461 479 64749118
105 ...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #12:

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

input:

500 900 99999989
122 188 44796717
73 121 56798468
334 358 95823235
485 453 96779071
209 391 45946094
332 168 91056077
481 483 81268636
148 393 25213027
107 214 99281713
493 46 61525618
472 355 74320568
258 482 99615552
159 393 20311839
411 121 5207095
20 131 65269699
45 339 51772607
195 292 64556504...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #13:

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

input:

500 1000 99999989
75 20 25003980
292 19 89418683
353 246 74910681
183 201 97535184
254 421 50614221
15 396 86624029
82 13 67776336
86 70 62843451
279 3 55801636
29 425 30024776
176 243 16631048
498 363 77415492
55 305 80862521
213 110 30693079
432 358 99667002
201 30 44433122
97 203 16284993
118 490...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #14:

score: 0
Accepted
time: 1ms
memory: 3768kb

input:

500 499 999999937
287 228 350409600
392 107 350409600
458 22 350409600
362 425 350409600
368 136 350409600
364 71 350409600
211 265 350409600
167 116 350409600
195 353 350409600
489 477 350409600
380 85 350409600
281 15 350409600
263 247 350409600
453 122 350409600
104 187 350409600
331 223 35040960...

output:

1
350409600 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 ...

result:

ok Participant found an answer (1 trees) and jury found an answer (1 trees)

Test #15:

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

input:

500 510 999999937
417 280 770450784
207 303 770450784
472 396 770450784
345 191 964169440
164 67 770450784
492 302 770450784
5 71 770450784
386 22 770450784
77 25 487491058
430 467 770450784
148 95 770450784
288 215 770450784
55 451 10190666
215 69 770450784
267 195 770450784
487 283 770450784
435 3...

output:

257
770450784 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...

result:

ok Participant found an answer (257 trees) and jury found an answer (257 trees)

Test #16:

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

input:

500 525 999999937
439 54 982774700
417 443 87702331
21 82 982774700
39 477 982774700
363 493 982774700
500 161 982774700
86 44 982774700
312 47 982774700
120 282 982774700
224 254 670954686
268 311 59221562
216 242 982774700
16 256 505585800
448 102 982774700
362 295 555877345
76 210 819076841
53 24...

output:

395
982774700 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 19 20 21 22 23 24 25 26 28 29 30 31 32 33 34 35 36 37 38 39 40 41 43 44 45 46 47 48 49 50 51 53 54 55 56 58 59 60 61 62 63 64 65 67 68 69 71 72 73 74 75 76 77 78 79 80 82 83 85 86 87 88 89 90 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 ...

result:

ok Participant found an answer (395 trees) and jury found an answer (395 trees)

Test #17:

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

input:

500 550 999999937
478 408 544946602
494 234 544946602
118 11 544946602
497 38 435997116
193 371 493919798
252 238 826125135
69 229 683109191
300 159 544946602
328 102 302951499
37 227 568031903
347 13 544946602
111 375 624947749
291 447 544946602
5 140 544946602
250 41 544946602
387 202 544946602
38...

output:

617
544946602 1 2 3 4 5 8 9 11 12 13 14 15 16 17 19 20 21 22 23 24 25 26 27 28 29 30 31 32 34 35 36 37 38 39 40 41 42 43 44 45 46 47 49 50 51 52 53 54 55 57 58 59 60 61 62 63 65 66 67 68 70 71 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 101 102 104 105 107 108 10...

result:

ok Participant found an answer (617 trees) and jury found an answer (617 trees)

Test #18:

score: 0
Accepted
time: 14ms
memory: 5432kb

input:

500 600 999999937
265 416 960325147
354 266 501849515
195 415 308033318
354 136 658703469
163 191 792878874
144 84 388345161
157 45 308033318
232 441 175503107
70 397 520297316
223 387 650583946
320 47 790017725
100 2 477058566
87 131 953737746
101 391 308033318
79 26 941025744
390 185 519333525
257...

output:

811
308033318 1 2 3 4 6 7 12 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 35 36 37 39 42 43 44 45 47 49 51 52 54 56 57 58 59 61 62 64 66 67 68 69 70 71 72 73 74 75 77 78 80 81 83 84 86 88 89 90 91 92 93 94 96 97 98 99 100 101 102 103 104 105 106 107 108 111 114 115 116 117 118 119 121 123 124 ...

result:

ok Participant found an answer (811 trees) and jury found an answer (811 trees)

Test #19:

score: 0
Accepted
time: 1ms
memory: 3820kb

input:

500 500 999999937
56 278 340955979
53 151 340955979
482 317 340955979
4 138 340955979
454 135 340955979
482 361 340955979
85 89 340955979
436 201 340955979
450 483 340955979
274 258 340955979
13 318 340955979
87 227 340955979
141 114 340955979
284 340 340955979
377 48 340955979
110 134 340955979
271...

output:

25
340955979 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99...

result:

ok Participant found an answer (25 trees) and jury found an answer (25 trees)

Test #20:

score: 0
Accepted
time: 27ms
memory: 6620kb

input:

500 700 999999937
250 2 231570738
454 447 348559779
328 253 557290971
11 201 742990307
294 99 355194759
215 322 346919021
411 389 223497390
488 429 924302863
437 79 634119443
413 380 194151871
477 372 634119443
156 44 723189726
88 8 656811915
115 26 494639245
171 237 579262439
237 495 225519328
146 ...

output:

1213
634119443 1 6 7 8 9 10 11 13 16 17 21 22 25 27 28 30 31 34 36 37 38 39 41 42 43 45 46 47 49 50 51 52 56 57 58 59 60 66 67 68 69 70 71 73 74 77 78 79 82 84 86 87 90 91 93 94 95 96 97 99 100 101 102 103 106 107 108 109 113 114 117 118 119 122 123 124 126 127 129 130 131 132 133 134 135 142 143 14...

result:

ok Participant found an answer (1213 trees) and jury found an answer (1213 trees)

Test #21:

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

input:

500 800 999999937
258 304 583150933
159 152 864655622
8 47 904254153
436 265 649209189
204 302 999927615
142 302 437142821
37 15 886997658
202 395 176364113
284 260 352132138
365 172 621577977
196 101 999803609
174 45 669960837
302 206 85008264
305 275 142531904
443 157 652057600
16 248 693746068
46...

output:

1441
649209189 2 3 4 7 8 15 16 18 22 23 24 26 27 31 32 36 39 40 45 47 48 51 52 53 54 55 56 58 59 60 65 66 67 71 72 75 78 83 85 90 93 96 97 99 102 103 105 106 107 109 110 112 113 115 116 117 118 119 120 124 127 128 130 131 132 136 138 140 142 143 147 150 151 153 156 157 160 162 163 164 166 170 171 17...

result:

ok Participant found an answer (1441 trees) and jury found an answer (1441 trees)

Test #22:

score: 0
Accepted
time: 29ms
memory: 7776kb

input:

500 900 999999937
122 188 437691348
73 121 296323029
334 358 25382116
485 453 71271129
209 391 955537437
332 168 58669489
481 483 584529141
148 393 88230539
107 214 706736962
493 46 995301637
472 355 754703158
258 482 416475555
159 393 775800573
411 121 458973126
20 131 939950122
45 339 247694299
19...

output:

1701
5612341 1 3 7 12 14 15 24 28 33 35 38 42 50 53 54 56 62 64 65 66 67 71 73 80 81 82 83 85 86 88 89 93 97 100 101 105 115 117 118 119 121 123 124 125 128 130 133 136 137 142 147 149 153 155 158 159 160 164 165 171 175 177 179 185 189 193 197 200 204 206 207 209 212 219 220 221 222 226 227 232 233...

result:

ok Participant found an answer (1701 trees) and jury found an answer (1701 trees)

Test #23:

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

input:

500 1000 999999937
75 20 857550680
292 19 110166270
353 246 190797204
183 201 150954990
254 421 374099649
15 396 837014574
82 13 802431102
86 70 422727121
279 3 985425226
29 425 742626961
176 243 571825134
498 363 619955816
55 305 797984505
213 110 284175102
432 358 702809990
201 30 28699854
97 203 ...

output:

1945
818970192 8 10 21 28 29 34 36 39 46 47 50 61 64 65 68 69 70 84 85 86 87 88 90 91 94 96 98 105 114 120 123 124 135 136 137 140 144 146 147 149 150 151 153 159 166 167 169 170 175 187 188 189 192 195 198 204 205 211 218 224 226 227 228 230 232 233 234 235 237 239 244 248 255 257 258 259 261 265 2...

result:

ok Participant found an answer (1945 trees) and jury found an answer (1945 trees)

Test #24:

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

input:

2 1000 999999937
1 2 411133720
1 2 776367809
1 2 801503481
2 1 289867740
2 1 639986495
2 1 555099841
2 1 689485994
1 2 108816472
2 1 877082404
1 2 123678957
2 1 880363745
1 2 770025482
1 2 593440355
2 1 899935259
1 2 157609551
2 1 373761515
2 1 2889558
2 1 629415436
1 2 684947844
1 2 485414377
2 1 4...

output:

1999
862815664 1000 
776367809 2 
223632128 1000 
801503481 3 
198496456 1000 
289867740 4 
710132197 1000 
639986495 5 
360013442 1000 
555099841 6 
444900096 1000 
689485994 7 
310513943 1000 
108816472 8 
891183465 1000 
877082404 9 
122917533 1000 
123678957 10 
876320980 1000 
880363745 11 
119...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #25:

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

input:

10 1000 999999937
3 6 178912852
10 3 875510731
6 7 212989905
7 5 974004463
1 10 620941502
7 5 600081434
9 1 394370115
1 3 776909504
5 1 370501286
6 8 726447186
10 5 267613208
2 9 467291795
9 2 938683115
5 4 729586694
2 7 214781199
6 5 414875992
9 6 60215552
3 6 901637793
7 9 907537612
7 8 42123063
1...

output:

1999
785709981 904 986 990 993 996 997 998 999 1000 
875510731 2 904 986 993 996 997 998 999 1000 
124489206 904 986 990 993 996 997 998 999 1000 
974004463 4 904 986 990 996 997 998 999 1000 
25995474 904 986 990 993 996 997 998 999 1000 
600081434 6 904 986 990 996 997 998 999 1000 
399918503 904 ...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #26:

score: 0
Accepted
time: 9ms
memory: 4912kb

input:

100 1000 999999937
27 22 577129898
47 76 383040531
44 49 252504590
66 46 764432363
75 76 827756718
80 35 275529478
95 9 886404040
55 97 184978304
11 72 641255171
65 95 394679645
37 8 171252921
35 39 277250820
62 10 745905336
97 76 208239094
16 34 460397322
74 28 465442229
89 95 979433574
70 86 67725...

output:

1999
127560596 18 143 181 189 217 303 480 502 505 614 645 676 682 687 689 693 698 703 716 742 763 778 784 789 806 808 811 814 818 820 824 830 846 849 852 854 856 857 858 859 865 868 872 878 889 890 898 899 906 912 913 917 920 927 928 930 931 935 937 943 944 946 947 955 956 957 958 959 960 961 962 96...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #27:

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

input:

498 1000 999999937
487 73 269543467
331 211 379519784
495 422 686973047
284 16 204129347
254 399 260794796
422 126 211993357
166 429 802536094
351 315 235479275
49 324 904476025
55 15 317387996
440 330 833475395
398 483 245510540
283 270 881075381
392 210 101464008
462 186 116907647
183 33 19696935
...

output:

1999
833785709 2 4 5 9 14 15 25 30 31 36 43 44 57 58 59 64 66 68 70 74 76 77 79 82 83 84 89 90 91 95 100 106 110 111 112 119 122 124 126 128 131 134 143 145 153 154 155 157 162 165 176 178 185 187 192 193 196 197 199 207 208 210 222 224 227 234 241 245 253 256 264 265 272 277 281 283 285 289 292 294...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #28:

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

input:

499 1000 999999937
144 284 46025639
242 260 240568220
449 203 912275568
260 4 382100531
96 298 24757210
255 315 720292625
111 97 124002714
227 444 550413391
331 282 363023595
201 44 757190858
498 460 378149715
387 63 989403521
195 296 477597041
210 146 858766928
499 87 408290897
313 395 347050751
14...

output:

1999
767509726 4 5 13 14 15 20 21 23 24 29 31 33 34 36 46 47 49 50 52 54 59 65 70 71 79 80 83 85 87 90 93 94 99 102 108 112 113 119 121 125 128 133 139 141 146 147 148 151 157 159 160 161 165 174 177 179 182 186 190 192 195 199 202 208 213 214 216 220 221 222 228 238 239 240 243 250 253 256 267 269 ...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #29:

score: 0
Accepted
time: 45ms
memory: 8612kb

input:

500 1000 999999937
114 191 548698698
257 259 174101411
166 144 307067234
5 65 315189831
130 144 764747698
191 263 657349687
435 125 520510567
72 457 869051725
31 434 652697712
451 437 241147129
140 367 568108671
423 368 152200500
258 291 922031445
489 5 313644610
407 393 435155235
96 135 53577132
26...

output:

1997
912213077 4 5 6 11 19 25 27 36 41 43 46 48 51 53 58 60 66 69 72 74 79 82 85 88 91 94 96 103 110 111 113 116 120 125 128 130 134 137 144 147 151 155 156 161 165 169 172 175 178 182 186 187 188 191 193 196 198 202 206 207 209 211 215 217 218 220 222 223 227 229 231 232 234 237 246 248 251 253 259...

result:

ok Participant found an answer (1997 trees) and jury found an answer (1997 trees)

Test #30:

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

input:

10 1000 999999937
1 6 169017311
6 4 813438192
7 10 658256408
3 10 356519068
5 8 105814076
10 9 432666653
2 10 924273201
4 2 438838176
6 10 23105379
9 3 61095925
4 6 492672241
8 1 350092485
1 3 849557758
9 8 527128919
5 10 399172798
2 4 637109541
9 7 862381710
8 4 821851347
9 1 517530356
10 7 7723516...

output:

1999
880696294 968 988 989 991 995 997 998 999 1000 
658256408 3 968 988 989 995 997 998 999 1000 
341743529 968 988 989 991 995 997 998 999 1000 
438838176 8 968 988 989 991 995 997 999 1000 
561161761 968 988 989 991 995 997 998 999 1000 
23105379 9 968 988 989 995 997 998 999 1000 
976894558 968 ...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #31:

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

input:

50 1000 999999937
47 31 338993180
1 40 981131058
16 14 475599962
29 44 218651110
13 5 295788288
8 46 379702422
16 8 788369898
12 21 193552464
42 4 516953820
17 46 395588075
26 32 801052259
22 6 252241088
25 47 415361628
36 14 665366957
24 5 332323875
45 22 667496708
30 48 315574397
42 5 265997928
16...

output:

1999
759603654 430 629 742 744 752 800 805 825 847 876 888 898 906 914 926 929 938 944 947 948 953 954 956 957 959 964 968 969 970 972 973 975 976 978 980 981 982 985 986 988 989 992 993 994 996 997 998 999 1000 
339185493 34 430 629 742 744 752 800 805 847 876 888 898 906 914 926 929 938 944 947 94...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #32:

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

input:

200 1000 999999937
155 193 467849083
56 59 535575167
97 22 494627324
200 72 960374690
51 200 104743381
129 37 403458202
99 138 318791385
164 7 513263543
116 185 858111714
169 165 864977405
87 135 479124746
164 37 463283980
98 150 827389077
111 2 519317068
8 84 554409749
51 11 688845859
164 39 370009...

output:

1999
433965560 5 57 75 88 98 101 102 103 114 127 142 149 158 168 196 202 227 233 250 253 296 322 333 335 339 343 357 365 370 393 399 421 440 450 456 472 490 495 508 518 520 526 529 530 535 540 543 544 545 568 571 572 584 585 595 612 619 626 627 655 656 665 669 672 675 689 694 698 700 703 704 712 722...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #33:

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

input:

499 1000 999999937
378 480 476231202
116 251 757524517
304 91 136773672
58 7 246393874
378 453 282946052
378 336 684803902
161 356 124374696
378 359 997729308
378 72 26684646
378 325 946203739
370 109 226216491
378 220 60777554
344 414 415380261
378 275 83199163
378 412 850660890
378 81 183620361
37...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #34:

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

input:

500 1000 999999937
430 117 111637665
85 228 267289407
478 304 819693771
477 99 161971830
69 242 172626708
397 448 755199536
397 165 556061372
397 309 705286456
397 71 441535487
397 242 463539465
451 64 63633665
397 333 435428974
441 202 512181674
397 217 566535010
397 241 556061372
390 384 444381502...

output:

1845
556061372 1 2 3 4 7 13 15 16 18 19 21 24 29 32 33 34 36 40 42 43 44 45 47 52 53 60 62 63 64 66 68 73 75 76 77 78 79 81 83 85 86 87 91 93 96 98 99 101 102 103 104 105 106 108 110 111 112 114 115 116 120 121 124 135 137 138 139 140 142 144 146 148 149 151 158 161 162 163 166 167 171 173 178 179 1...

result:

ok Participant found an answer (1845 trees) and jury found an answer (1845 trees)

Test #35:

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

input:

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

output:

979
0 915 934 951 967 973 977 979 981 982 986 988 990 993 994 996 997 998 999 1000 
1 12 915 934 951 967 973 977 979 981 982 986 988 993 994 996 997 998 999 1000 
1 915 934 951 967 973 977 979 981 982 986 988 990 993 994 996 997 998 999 1000 
1 16 915 934 951 967 973 977 979 981 982 986 988 990 993 ...

result:

ok Participant found an answer (979 trees) and jury found an answer (972 trees)

Test #36:

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

input:

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

output:

1337
0 379 711 804 862 913 924 939 945 950 962 970 978 980 983 984 985 986 987 988 989 990 993 994 995 996 997 998 999 1000 
2 16 379 711 804 862 913 924 939 945 950 962 970 978 980 983 984 985 986 987 988 989 990 993 994 995 996 997 998 1000 
1 379 711 804 862 913 924 939 945 950 962 970 978 980 98...

result:

ok Participant found an answer (1337 trees) and jury found an answer (1338 trees)

Test #37:

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

input:

40 1000 5
39 1 1
28 24 4
37 5 0
9 6 2
20 7 0
12 7 4
15 39 2
33 27 1
40 6 3
3 34 0
37 38 3
19 6 4
40 10 4
5 1 3
39 12 0
2 13 4
38 8 4
28 39 0
35 21 4
11 40 3
7 29 4
12 29 4
9 3 2
18 23 1
38 2 2
33 4 2
14 16 1
36 19 1
37 14 4
23 37 3
33 22 3
34 23 1
7 24 2
17 16 2
13 17 4
38 23 4
39 14 1
31 6 4
26 19 ...

output:

1585
3 257 381 725 807 839 849 887 900 919 925 927 940 942 946 948 951 960 966 970 971 972 973 976 977 978 980 981 982 983 986 987 991 993 995 996 997 998 999 1000 
1 27 381 725 807 839 849 887 900 919 925 927 940 942 946 948 951 960 966 970 971 972 973 976 977 978 980 981 982 983 986 987 991 993 99...

result:

ok Participant found an answer (1585 trees) and jury found an answer (1573 trees)

Test #38:

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

input:

44 1000 7
27 12 0
7 41 5
16 21 1
41 28 2
19 16 5
37 7 1
33 1 4
28 36 4
2 11 1
17 14 0
11 15 2
2 20 4
34 44 2
27 43 3
20 7 3
40 2 5
28 15 3
40 5 6
30 4 0
27 24 2
26 38 3
24 26 4
19 6 6
19 18 2
31 10 0
5 19 2
29 39 5
1 44 6
3 1 1
43 28 6
34 29 5
43 8 0
20 43 1
25 23 6
38 21 6
32 27 2
20 31 3
16 11 0
3...

output:

1699
4 138 427 683 704 717 835 842 877 882 894 914 929 932 934 947 953 956 958 963 965 966 971 973 974 975 976 978 979 980 986 987 988 989 990 991 992 993 994 996 997 998 999 1000 
5 31 138 427 683 704 835 842 877 882 894 914 929 932 934 947 953 956 958 963 965 966 971 973 974 975 976 978 979 980 98...

result:

ok Participant found an answer (1699 trees) and jury found an answer (1705 trees)

Test #39:

score: 0
Accepted
time: 8ms
memory: 4200kb

input:

44 1000 11
27 12 6
7 41 9
16 21 5
41 28 5
19 16 5
37 7 5
33 1 0
28 36 1
2 11 10
17 14 4
11 15 3
2 20 6
34 44 9
27 43 6
20 7 1
40 2 8
28 15 8
40 5 5
30 4 1
27 24 6
26 38 6
24 26 5
19 6 4
19 18 1
31 10 8
5 19 0
29 39 7
1 44 6
3 1 4
43 28 6
34 29 6
43 8 1
20 43 8
25 23 8
38 21 9
32 27 4
20 31 1
16 11 3...

output:

1793
8 138 427 683 704 717 835 842 877 882 894 914 929 932 934 947 953 956 958 963 965 966 971 973 974 975 976 978 979 980 986 987 988 989 990 991 992 993 994 996 997 998 999 1000 
6 31 138 427 683 704 835 842 877 882 894 914 929 932 934 947 953 956 958 963 965 966 971 973 974 975 976 978 979 980 98...

result:

ok Participant found an answer (1793 trees) and jury found an answer (1797 trees)

Test #40:

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

input:

45 1000 2
42 1 1
13 16 1
22 25 1
20 1 1
18 11 1
42 12 1
40 7 1
33 6 1
13 18 1
39 2 1
19 30 1
10 4 1
1 45 1
16 18 1
17 41 1
21 11 1
1 7 1
1 7 1
43 22 1
45 22 1
5 18 1
30 25 1
3 16 1
37 13 1
35 39 1
6 31 1
12 22 1
28 27 1
4 29 1
45 14 1
31 26 1
39 43 1
29 10 1
42 28 1
26 16 1
6 27 1
33 22 1
8 41 1
17 ...

output:

1888
1 4 130 239 733 771 782 848 851 889 892 916 921 927 928 932 933 935 937 951 952 954 955 962 964 965 968 970 973 974 979 980 983 986 987 988 991 993 994 995 996 997 998 999 1000 
1 130 239 733 771 782 848 851 889 892 916 921 927 928 932 933 935 937 951 952 954 955 962 964 965 968 970 973 974 979...

result:

ok Participant found an answer (1888 trees) and jury found an answer (1934 trees)

Test #41:

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

input:

45 1000 3
42 1 1
13 16 2
22 25 2
20 1 0
18 11 2
42 12 2
40 7 2
33 6 1
13 18 2
39 2 1
19 30 1
10 4 2
1 45 2
16 18 1
17 41 1
21 11 2
1 7 1
1 7 1
43 22 1
45 22 2
5 18 1
30 25 1
3 16 1
37 13 1
35 39 2
6 31 1
12 22 2
28 27 2
4 29 2
45 14 1
31 26 2
39 43 2
29 10 2
42 28 1
26 16 1
6 27 1
33 22 1
8 41 2
17 ...

output:

1905
0 130 239 733 771 782 848 851 889 892 916 921 927 928 932 933 935 937 951 952 954 955 962 964 965 968 970 973 974 979 980 982 983 986 987 988 991 993 994 995 996 997 998 999 1000 
1 19 130 239 733 771 782 848 851 889 892 916 921 928 932 933 935 937 951 952 954 955 962 964 965 968 970 973 974 97...

result:

ok Participant found an answer (1905 trees) and jury found an answer (1932 trees)

Test #42:

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

input:

45 1000 5
42 1 2
13 16 3
22 25 1
20 1 3
18 11 3
42 12 3
40 7 3
33 6 4
13 18 4
39 2 3
19 30 4
10 4 3
1 45 2
16 18 4
17 41 3
21 11 3
1 7 4
1 7 0
43 22 2
45 22 4
5 18 0
30 25 3
3 16 3
37 13 3
35 39 3
6 31 4
12 22 3
28 27 2
4 29 2
45 14 1
31 26 2
39 43 1
29 10 3
42 28 2
26 16 2
6 27 2
33 22 4
8 41 3
17 ...

output:

1943
2 130 239 733 771 782 848 851 889 892 916 921 927 928 932 933 935 937 951 952 954 955 962 964 965 968 970 973 974 979 980 982 983 986 987 988 991 993 994 995 996 997 998 999 1000 
3 4 130 239 733 771 782 848 851 889 892 916 921 927 928 932 933 935 937 951 952 954 955 962 964 965 968 970 973 974...

result:

ok Participant found an answer (1943 trees) and jury found an answer (1951 trees)

Test #43:

score: 0
Accepted
time: 8ms
memory: 4332kb

input:

45 1000 7
42 1 2
13 16 3
22 25 3
20 1 2
18 11 1
42 12 1
40 7 5
33 6 2
13 18 5
39 2 3
19 30 3
10 4 4
1 45 2
16 18 1
17 41 1
21 11 1
1 7 2
1 7 1
43 22 1
45 22 3
5 18 3
30 25 2
3 16 5
37 13 1
35 39 4
6 31 6
12 22 4
28 27 5
4 29 4
45 14 2
31 26 3
39 43 6
29 10 2
42 28 4
26 16 5
6 27 3
33 22 4
8 41 1
17 ...

output:

1961
1 130 239 733 771 782 848 851 889 892 916 921 927 928 932 933 935 937 951 952 954 955 962 964 965 968 970 973 974 979 980 982 983 986 987 988 991 993 994 995 996 997 998 999 1000 
2 4 130 239 733 771 782 848 851 889 892 916 921 927 928 932 933 935 937 951 952 954 955 962 964 965 968 970 973 974...

result:

ok Participant found an answer (1961 trees) and jury found an answer (1973 trees)

Test #44:

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

input:

45 1000 11
42 1 3
13 16 7
22 25 6
20 1 9
18 11 7
42 12 6
40 7 4
33 6 2
13 18 9
39 2 2
19 30 7
10 4 6
1 45 7
16 18 4
17 41 6
21 11 2
1 7 7
1 7 9
43 22 5
45 22 5
5 18 8
30 25 4
3 16 4
37 13 10
35 39 1
6 31 6
12 22 2
28 27 2
4 29 2
45 14 8
31 26 5
39 43 9
29 10 3
42 28 4
26 16 6
6 27 1
33 22 5
8 41 9
1...

output:

1976
9 4 130 239 733 771 782 848 851 889 892 916 921 927 928 932 933 935 937 951 952 954 955 962 964 965 968 970 973 974 979 980 983 986 987 988 991 993 994 995 996 997 998 999 1000 
2 130 239 733 771 782 848 851 889 892 916 921 927 928 932 933 935 937 951 952 954 955 962 964 965 968 970 973 974 979...

result:

ok Participant found an answer (1976 trees) and jury found an answer (1988 trees)

Test #45:

score: 0
Accepted
time: 21ms
memory: 7004kb

input:

300 1000 579907477
85 20 501369811
170 209 398163019
213 60 24791654
230 141 419019038
262 23 307332223
76 171 6647363
82 256 472269037
83 216 98974104
212 171 206720550
270 276 515676983
204 176 51907464
144 112 422022914
118 82 330909459
205 132 575785329
169 140 55357686
40 286 145577484
126 212 ...

output:

1999
110715191 2 9 18 24 29 48 75 91 106 109 110 115 121 135 136 148 150 153 156 157 166 167 174 189 197 200 215 216 221 230 234 237 244 260 270 285 293 302 304 307 308 309 311 319 323 324 331 338 346 349 351 360 371 380 398 400 402 419 434 445 448 451 452 459 468 470 476 477 494 511 512 519 527 532...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #46:

score: 0
Accepted
time: 20ms
memory: 7456kb

input:

350 1000 994747931
95 304 672543274
30 294 551111098
27 157 153882783
116 157 512439805
203 153 527241207
111 105 470017102
282 4 195745674
175 189 61279030
344 65 6080303
281 134 896176207
11 182 876685758
157 196 599267556
77 207 337469051
143 130 692521419
123 120 187503868
51 289 102179308
21 29...

output:

1999
863207455 8 19 34 39 41 59 74 77 81 82 95 111 112 114 137 138 141 142 150 153 174 185 212 218 224 225 245 253 258 265 266 274 278 281 285 290 292 295 297 298 312 320 339 343 344 346 349 353 356 359 360 373 376 377 384 390 394 405 418 425 428 434 436 442 444 446 448 451 453 455 457 459 465 466 4...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #47:

score: 0
Accepted
time: 37ms
memory: 7912kb

input:

400 1000 967527623
227 62 593968166
174 386 319015265
11 386 37103681
254 362 439221071
301 329 441776182
166 272 228510487
215 140 164578119
281 268 87582058
356 247 835697768
66 197 929873194
333 289 477978462
156 48 669732140
300 106 567689265
229 125 128833926
380 331 286498390
357 58 4652963
17...

output:

1999
525945103 3 16 18 20 25 31 39 42 49 54 63 74 75 77 79 80 88 93 94 98 100 106 109 110 117 119 120 146 147 151 152 154 156 162 164 169 171 172 179 191 215 228 229 234 236 246 248 250 253 262 271 281 287 288 289 296 300 302 308 316 319 328 331 332 335 344 347 348 353 359 361 365 366 368 369 370 37...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #48:

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

input:

450 1000 955153609
290 219 65970737
334 77 21598136
198 332 90012774
363 300 235053495
73 132 615775924
295 155 562343519
445 436 152605289
399 252 933967514
262 423 376322373
230 294 265251767
89 32 847945694
61 94 770914730
56 305 374807056
137 64 69327712
323 107 782667
209 274 944022728
23 21 23...

output:

1999
925119728 7 15 18 21 32 33 40 42 48 50 52 55 56 65 67 70 73 89 91 96 101 110 120 121 129 138 139 142 145 149 151 152 154 162 174 175 177 183 186 192 194 203 210 212 213 214 217 218 219 226 227 228 229 230 232 239 240 244 247 253 261 274 276 277 278 279 290 291 294 295 299 302 304 308 313 314 31...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #49:

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

input:

499 1000 830842109
454 357 281331744
288 10 603468239
151 105 612741336
176 23 696034831
478 38 86151600
96 1 205849625
428 233 227676259
116 344 432314466
181 263 725179555
154 330 276902007
387 454 212244033
434 297 150051447
73 473 657304392
434 484 467362896
31 317 540666741
83 2 818695382
74 55...

output:

1999
829731142 1 14 23 25 26 31 32 37 38 39 41 42 44 45 47 52 54 61 62 65 66 67 68 70 75 76 79 85 94 95 96 97 99 102 104 106 110 115 117 120 121 123 133 137 148 149 150 152 155 164 169 178 181 183 184 195 201 204 209 212 214 217 220 221 224 225 229 230 231 232 240 245 247 249 254 255 257 262 267 268...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #50:

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

input:

497 497 2
138 127 1
224 181 1
445 401 0
162 242 0
410 15 1
496 295 0
318 352 1
195 403 1
478 148 0
394 47 0
229 151 0
270 123 0
234 395 0
319 133 1
258 332 1
118 384 0
78 419 1
467 456 0
277 279 0
46 78 0
193 89 0
487 128 1
249 376 0
121 115 1
421 477 1
317 240 0
474 339 1
127 428 0
221 289 1
248 36...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #51:

score: 0
Accepted
time: 1ms
memory: 3872kb

input:

497 497 2
472 43 1
217 85 1
366 196 0
223 301 0
68 25 1
72 115 1
286 74 0
175 122 1
487 129 0
46 54 0
477 24 1
6 134 0
312 456 1
402 364 1
465 98 1
264 44 0
49 4 0
257 22 0
397 285 1
430 388 0
259 342 1
354 300 1
448 96 1
290 228 0
31 272 0
332 130 0
348 160 1
198 366 1
18 467 0
474 308 1
374 101 1
...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #52:

score: 0
Accepted
time: 1ms
memory: 3604kb

input:

497 497 2
81 446 1
484 359 0
417 249 1
113 74 1
27 14 0
51 380 1
207 148 0
422 334 0
386 419 1
369 46 1
338 136 1
211 62 1
264 125 0
426 90 0
404 211 1
339 66 0
468 21 1
394 177 1
127 442 1
262 190 0
172 415 0
29 10 1
189 484 0
379 60 1
102 84 0
118 163 0
236 76 1
33 422 0
384 328 1
9 448 0
425 120 ...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #53:

score: 0
Accepted
time: 1ms
memory: 3708kb

input:

499 499 2
282 20 1
276 126 0
353 375 1
62 89 1
461 127 0
18 159 0
197 310 1
393 418 1
38 246 1
363 84 1
312 314 1
473 370 1
456 22 0
17 111 1
450 417 1
114 413 0
238 449 0
260 454 1
210 86 0
349 468 0
465 477 0
376 362 0
287 87 1
494 44 1
334 349 0
183 77 0
10 154 1
54 433 1
286 325 1
224 140 0
156 ...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #54:

score: 0
Accepted
time: 1ms
memory: 3948kb

input:

499 499 3
28 294 2
84 43 1
224 290 2
302 18 2
443 410 0
320 370 2
425 42 2
82 235 1
396 76 0
412 270 0
387 360 2
195 84 0
409 416 2
339 390 1
365 342 1
187 223 0
442 142 1
299 320 1
32 321 1
79 56 0
485 437 1
76 272 2
379 93 1
410 169 0
413 16 1
50 347 1
378 101 1
30 384 2
332 348 0
26 395 1
92 40 2...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #55:

score: 0
Accepted
time: 1ms
memory: 3636kb

input:

499 499 89
443 214 36
365 483 68
177 343 67
419 112 70
294 104 37
271 77 50
397 115 52
473 141 34
282 318 5
343 467 67
320 157 87
68 486 51
69 466 65
35 484 35
248 91 73
101 13 57
278 67 0
78 172 71
322 74 68
482 370 65
459 295 32
207 39 16
361 321 9
441 431 36
147 363 6
93 390 59
90 128 44
339 178 ...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #56:

score: 0
Accepted
time: 1ms
memory: 3932kb

input:

500 500 499
349 244 372
211 55 184
392 217 54
343 125 381
169 265 319
184 382 159
329 187 268
341 248 273
240 360 62
35 438 70
27 408 479
130 35 319
313 57 223
376 245 135
219 170 59
469 425 277
140 398 302
275 41 337
377 148 171
307 64 256
446 484 361
124 137 369
62 216 297
466 343 71
26 462 451
41...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #57:

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

input:

500 500 900557569
354 397 69211892
20 455 69211892
86 85 769147441
130 5 69211892
182 74 863979609
30 33 69211892
81 23 69211892
309 171 69211892
52 439 619200238
381 215 69211892
107 65 418363826
373 429 597847779
361 484 69211892
406 421 69211892
105 445 69211892
469 226 366814872
353 389 69211892...

output:

413
69211892 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10...

result:

ok Participant found an answer (413 trees) and jury found an answer (413 trees)

Test #58:

score: 0
Accepted
time: 26ms
memory: 6488kb

input:

500 600 757689509
446 285 573639950
270 388 122483021
381 1 522425165
288 476 614875119
283 52 398486338
443 366 113128200
243 327 222283575
11 158 248607065
482 243 150554599
195 12 735418857
78 371 429919406
120 275 30816927
460 364 469329384
108 256 518286993
477 72 118822969
249 185 303993365
36...

output:

1185
168150466 2 4 9 11 13 14 15 18 19 20 21 23 25 26 27 28 29 30 31 33 34 36 38 39 41 42 43 44 45 47 48 52 55 56 60 61 62 63 65 66 67 68 70 72 74 76 78 79 80 82 85 86 87 88 89 91 92 94 95 96 97 98 99 100 102 103 104 105 106 108 109 110 112 113 115 116 118 119 120 121 122 124 125 127 128 129 130 131...

result:

ok Participant found an answer (1185 trees) and jury found an answer (1185 trees)

Test #59:

score: 0
Accepted
time: 29ms
memory: 6836kb

input:

500 700 828905719
480 5 739672643
201 112 370733333
235 26 16345049
409 234 173409653
486 456 631007778
120 1 538740285
58 458 522613047
107 314 58436706
400 89 287382978
206 304 118447652
248 438 738474281
138 437 424258467
358 245 311144163
446 239 676021307
489 362 475425446
68 19 412038991
452 2...

output:

1385
225419949 2 3 5 7 8 10 11 12 13 14 15 17 22 24 25 26 27 28 29 32 37 38 39 40 42 43 47 52 56 57 58 61 62 64 65 68 69 70 71 72 77 82 84 85 86 91 93 95 96 97 100 101 102 105 106 107 108 109 112 116 117 119 120 121 122 124 126 127 128 131 136 137 138 140 142 143 144 145 147 148 149 153 155 156 157 ...

result:

ok Participant found an answer (1385 trees) and jury found an answer (1385 trees)

Test #60:

score: 0
Accepted
time: 31ms
memory: 7420kb

input:

500 800 742108217
240 437 223580374
386 260 450278481
408 194 272294044
55 440 411878160
466 274 698768664
374 195 103845986
347 474 601813702
298 276 229739628
58 332 403349699
407 175 540597854
114 256 39078041
395 467 643278059
250 234 83749897
26 159 422456771
272 101 476764351
410 86 521528751
...

output:

1599
485105386 7 8 9 12 13 17 18 19 21 27 35 37 39 40 47 50 51 53 61 64 70 79 81 83 84 86 90 93 94 99 102 104 105 109 112 114 121 124 126 127 128 129 130 131 133 134 135 136 137 143 144 146 148 152 156 157 158 159 160 161 164 165 167 170 175 176 178 179 181 183 187 188 191 192 193 195 196 199 203 20...

result:

ok Participant found an answer (1599 trees) and jury found an answer (1599 trees)

Test #61:

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

input:

500 900 734453983
97 159 647125233
12 291 575754497
338 202 4000585
185 448 531153789
420 221 670359551
156 233 277582474
279 371 585124518
139 272 669984536
368 39 404059164
268 353 422914933
482 180 633326141
285 69 106394126
1 441 389880720
46 293 550622480
1 464 703029276
136 194 398527669
403 1...

output:

1799
425697662 1 2 4 5 6 7 9 11 12 20 34 43 48 49 54 58 59 68 69 71 76 78 87 91 93 94 96 103 104 107 112 123 124 128 130 132 134 136 138 144 148 149 152 153 158 165 175 176 177 180 181 182 187 189 192 193 195 197 203 204 206 210 211 213 218 221 222 223 225 227 232 236 242 244 250 251 255 258 260 262...

result:

ok Participant found an answer (1799 trees) and jury found an answer (1799 trees)

Test #62:

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

input:

500 999 710309027
418 335 337061089
237 197 426428799
93 439 166667582
83 277 8712657
128 401 231709955
39 147 548228697
169 128 490677625
421 321 605233428
188 59 627898332
329 28 521677427
383 381 25277585
431 369 47133664
36 258 136480797
81 166 178582419
325 338 108644840
56 362 524348240
335 14...

output:

1995
469192202 2 3 10 11 20 23 33 35 38 49 53 54 55 57 60 62 65 68 72 73 74 79 80 81 84 89 93 95 96 99 102 104 106 107 110 112 113 115 116 118 120 121 124 126 135 142 143 147 148 149 155 159 167 169 175 188 189 190 194 195 196 197 200 203 207 208 211 219 222 224 225 232 233 236 243 245 248 250 252 2...

result:

ok Participant found an answer (1995 trees) and jury found an answer (1995 trees)

Test #63:

score: 0
Accepted
time: 45ms
memory: 8632kb

input:

500 1000 671240159
112 82 417448095
230 361 64083244
212 281 465849701
227 24 427651359
466 280 57293642
422 272 572834299
26 185 528167062
43 164 561914685
390 346 68777697
467 77 139659139
6 93 623796002
20 445 60076185
265 466 534177282
202 339 50852556
126 245 54588949
409 50 658668954
63 389 74...

output:

1999
477526700 1 7 8 9 11 12 13 19 23 24 25 28 38 49 55 59 61 65 70 73 77 79 91 105 106 109 110 111 114 120 121 131 132 133 134 135 139 141 142 147 148 151 154 157 159 161 170 172 173 178 179 180 182 185 187 188 189 190 196 202 203 211 215 219 221 224 226 229 230 232 235 239 257 258 259 260 265 267 ...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #64:

score: 0
Accepted
time: 11ms
memory: 4916kb

input:

500 1000 2
33 43 0
50 112 0
444 334 1
384 349 0
331 147 0
476 51 0
50 14 0
468 180 1
114 449 1
495 60 0
269 313 0
341 435 0
297 230 1
355 365 1
234 448 1
422 371 1
207 286 1
373 469 1
179 354 1
148 288 0
106 464 1
488 330 0
5 483 1
303 456 0
385 225 1
307 180 0
232 230 0
478 106 1
415 157 1
180 468 ...

output:

443
1 30 37 45 90 110 112 120 155 156 168 172 173 182 186 190 192 196 201 206 212 213 218 220 223 232 234 235 245 246 248 254 266 270 271 274 276 282 283 288 291 297 310 313 315 317 325 327 328 337 339 340 343 344 345 346 348 351 353 359 362 371 374 376 378 379 380 383 384 387 388 389 391 393 394 39...

result:

ok Participant found an answer (443 trees) and jury found an answer (569 trees)

Test #65:

score: 0
Accepted
time: 19ms
memory: 6728kb

input:

500 1000 449601599
100 222 30037220
147 470 249365875
276 477 154411298
118 484 169381615
326 359 72638440
120 49 11887570
172 17 29333979
267 318 165923299
423 133 34647814
43 476 94909028
370 346 9506795
234 438 79196751
313 419 212431557
74 276 388811517
434 333 381427530
318 68 174003055
275 56 ...

output:

1343
197745351 1 13 14 15 18 33 38 43 45 46 53 58 67 69 77 79 84 94 102 106 119 133 134 135 136 137 139 140 144 145 148 149 150 154 157 162 165 170 176 177 180 188 199 201 211 212 218 221 225 226 231 232 235 243 247 248 251 253 259 271 273 277 281 282 284 308 309 310 312 313 314 325 326 330 331 332 ...

result:

ok Participant found an answer (1343 trees) and jury found an answer (1343 trees)

Test #66:

score: 0
Accepted
time: 33ms
memory: 6812kb

input:

500 1000 377264473
175 38 136228469
128 185 129185920
439 476 58945960
345 171 15536581
269 259 31215767
278 394 252159963
254 395 351469865
47 161 180813824
258 82 291987616
371 125 324790445
82 258 183455625
205 12 19394719
417 395 209733633
205 12 306682523
395 72 301637606
112 399 189192744
429 ...

output:

1501
220501433 4 5 6 8 10 18 29 33 37 53 55 59 67 70 73 77 82 84 85 87 92 96 97 99 100 102 103 109 111 113 115 117 118 120 121 126 127 128 138 144 146 148 149 160 169 170 172 173 176 180 186 188 190 193 195 196 198 201 205 219 224 225 227 231 238 241 242 244 249 250 251 253 254 257 262 270 275 282 2...

result:

ok Participant found an answer (1501 trees) and jury found an answer (1501 trees)

Test #67:

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

input:

500 1000 2
175 38 0
128 185 0
439 476 1
345 171 0
269 259 0
278 394 1
254 395 1
47 161 1
258 82 1
371 125 1
82 258 1
205 12 1
417 395 0
205 12 1
395 72 1
112 399 0
429 430 1
113 136 1
258 337 0
467 89 1
435 299 1
355 369 1
368 406 1
328 483 1
259 406 1
487 112 1
455 356 1
293 387 1
195 205 1
51 319 ...

output:

999
0 4 5 6 8 10 18 29 33 37 53 55 59 67 70 73 77 82 84 85 87 92 96 97 99 100 102 103 109 111 113 115 117 118 120 121 126 127 128 138 144 146 148 149 160 169 170 172 173 176 180 186 188 190 193 195 196 198 201 205 219 224 225 227 231 238 241 242 244 249 250 251 253 254 257 262 270 275 282 287 290 29...

result:

ok Participant found an answer (999 trees) and jury found an answer (1144 trees)

Test #68:

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

input:

500 1000 2
112 139 1
447 169 1
475 125 1
448 102 1
291 390 1
78 53 1
46 167 1
304 400 1
282 420 1
162 152 0
167 46 1
425 405 1
63 160 1
476 200 1
288 460 0
496 20 0
131 290 1
181 376 1
420 188 0
231 356 0
55 399 0
319 180 0
167 46 0
325 14 0
206 283 1
473 45 1
37 103 0
302 115 1
70 63 1
115 345 1
35...

output:

1043
0 4 10 23 27 31 40 42 43 46 47 56 61 66 76 78 79 80 82 86 87 93 106 107 112 115 123 125 127 131 147 148 153 157 158 161 168 172 174 176 178 179 181 186 192 194 199 201 203 205 206 207 211 222 223 226 228 236 238 241 250 251 252 264 266 270 272 274 276 277 278 283 285 288 294 296 302 303 306 308...

result:

ok Participant found an answer (1043 trees) and jury found an answer (1160 trees)

Test #69:

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

input:

500 1000 2
365 287 1
402 330 1
416 83 1
186 498 1
377 248 0
5 295 1
472 152 0
475 368 1
80 40 0
447 462 1
359 316 0
279 256 1
179 469 1
237 221 0
408 148 0
474 462 0
141 230 1
230 141 0
350 159 0
280 230 1
435 247 1
308 387 0
213 422 0
469 467 0
84 434 0
93 113 0
245 389 1
377 82 0
492 80 0
409 440 ...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #70:

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

input:

500 1000 2
149 464 0
471 295 0
385 355 0
195 142 0
267 385 1
312 467 0
269 83 1
397 238 0
483 21 0
335 23 0
288 359 0
494 455 0
459 217 0
278 68 0
101 105 0
291 184 1
277 382 0
411 264 1
125 1 1
3 346 0
300 98 0
488 419 1
401 316 0
314 281 0
376 230 0
324 425 1
431 275 0
431 253 1
188 344 0
232 380 ...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #71:

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

input:

500 1000 3
369 288 2
52 203 2
241 486 1
47 26 0
408 336 2
338 230 0
478 197 2
483 212 1
283 205 1
337 444 0
260 65 2
313 459 0
156 362 0
405 492 0
294 353 2
202 37 0
498 3 1
193 260 0
230 416 1
459 173 0
416 216 2
202 220 1
280 448 2
237 111 0
353 16 1
207 336 1
480 116 2
230 239 1
418 482 0
46 98 2...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #72:

score: 0
Accepted
time: 1ms
memory: 3820kb

input:

500 1000 3
186 357 2
211 226 1
183 462 2
217 14 2
101 160 2
184 366 1
231 98 1
311 128 0
307 364 0
453 405 1
321 335 1
19 446 1
403 177 2
157 377 2
435 55 1
263 37 0
89 426 2
28 470 1
213 394 0
447 419 2
34 454 2
155 100 2
277 211 2
146 46 1
374 438 0
475 245 0
254 276 2
409 176 0
197 166 2
424 83 2...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #73:

score: 0
Accepted
time: 31ms
memory: 6876kb

input:

500 1000 5
52 403 3
490 11 3
4 70 2
200 337 2
163 77 3
294 450 0
230 338 2
420 275 3
132 456 4
298 357 4
181 287 1
122 482 0
439 383 3
462 164 1
448 475 4
235 251 1
251 232 1
287 170 1
172 62 4
215 18 0
353 306 3
105 390 2
462 89 2
346 267 3
385 2 1
178 197 1
408 302 1
145 300 1
484 143 0
229 321 2
...

output:

1423
4 1 6 8 9 12 15 17 18 28 33 34 39 42 44 45 51 56 60 62 64 65 69 73 75 79 83 84 86 87 88 92 93 95 99 103 104 108 112 114 115 117 121 122 123 125 136 139 141 148 149 154 159 160 161 162 172 177 179 184 185 190 191 192 193 194 205 210 214 218 223 226 229 230 231 234 237 238 239 249 252 258 265 267...

result:

ok Participant found an answer (1423 trees) and jury found an answer (1463 trees)

Test #74:

score: 0
Accepted
time: 25ms
memory: 6444kb

input:

500 1000 3
78 271 2
31 98 0
47 118 2
382 140 0
80 75 1
81 214 1
311 31 2
123 247 1
498 396 0
31 82 2
328 265 1
79 457 1
242 403 1
212 472 1
464 376 2
93 232 1
14 316 2
227 307 1
15 283 1
16 24 0
253 216 1
328 89 1
381 274 2
139 170 2
213 394 2
417 375 1
18 283 1
25 240 1
311 27 2
158 355 1
108 382 0...

output:

1317
1 16 20 21 22 26 28 29 31 35 38 43 49 56 58 63 64 71 74 75 77 81 82 87 90 91 95 96 102 105 110 112 122 126 127 132 134 135 136 139 140 142 144 147 149 157 159 161 166 167 169 172 177 180 189 192 193 197 198 199 201 204 206 208 214 216 219 221 233 238 239 246 247 248 253 257 270 272 273 275 278 ...

result:

ok Participant found an answer (1317 trees) and jury found an answer (1393 trees)

Test #75:

score: 0
Accepted
time: 30ms
memory: 7196kb

input:

500 1000 7
406 164 5
491 92 6
448 25 2
311 446 1
383 105 4
223 493 1
253 499 6
491 374 1
428 148 1
452 197 2
249 150 6
23 256 4
52 378 4
154 336 1
263 285 1
209 341 1
322 16 4
138 63 5
179 45 3
483 346 2
451 462 0
426 20 3
13 393 4
371 397 3
286 394 6
459 492 4
168 191 2
280 84 3
58 450 1
488 337 6
...

output:

1723
0 6 8 10 11 15 23 26 28 35 41 48 50 60 65 67 68 70 73 82 90 91 92 98 104 108 110 111 119 120 123 129 132 134 135 136 140 141 142 144 156 157 158 161 162 169 171 173 179 183 188 189 196 197 198 199 202 203 206 207 210 218 220 226 230 231 232 233 235 240 241 249 254 255 256 258 263 269 282 283 28...

result:

ok Participant found an answer (1723 trees) and jury found an answer (1776 trees)

Test #76:

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

input:

500 1000 13
86 306 9
335 193 4
326 457 2
299 144 9
115 123 1
132 187 7
427 94 7
301 21 6
412 382 0
323 3 12
184 5 11
63 206 11
253 13 8
217 58 7
376 447 11
96 367 1
115 496 1
289 423 9
27 426 10
85 43 9
352 334 11
9 24 12
139 58 7
252 391 9
431 27 11
318 144 8
120 174 9
457 164 4
361 136 11
256 270 ...

output:

1817
4 2 3 7 10 11 14 15 28 33 35 36 39 42 45 49 50 51 52 55 57 58 65 69 74 77 78 80 81 88 89 93 94 97 99 100 105 110 116 121 125 128 129 136 143 149 150 157 161 167 168 169 179 189 193 194 195 196 202 203 205 211 214 219 220 224 226 228 229 230 231 232 237 247 251 252 255 260 262 263 281 282 285 28...

result:

ok Participant found an answer (1817 trees) and jury found an answer (1849 trees)

Test #77:

score: 0
Accepted
time: 31ms
memory: 7356kb

input:

500 1000 11
116 379 1
307 30 4
313 452 4
308 15 1
51 376 6
321 431 1
257 491 2
138 212 2
109 360 8
462 301 7
147 280 10
479 115 6
283 53 2
60 363 9
339 331 9
214 423 5
469 389 2
291 452 1
126 230 4
407 34 5
188 149 0
392 338 6
221 353 7
250 352 4
469 110 5
490 484 7
392 495 6
396 216 0
91 238 9
142 ...

output:

1785
9 1 6 10 18 23 25 26 27 29 33 34 36 39 41 44 49 52 53 58 60 66 67 68 69 70 75 78 81 87 97 99 100 106 108 109 111 117 122 137 139 142 160 161 162 170 171 172 173 176 182 189 192 194 197 200 202 203 208 211 212 214 217 218 219 225 227 231 232 233 234 235 237 238 240 241 248 250 257 261 274 280 28...

result:

ok Participant found an answer (1785 trees) and jury found an answer (1827 trees)

Test #78:

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

input:

500 1000 13
406 164 4
491 92 7
448 25 0
311 446 3
383 105 5
223 493 11
253 499 4
491 374 8
428 148 1
452 197 2
249 150 12
23 256 5
52 378 0
154 336 5
263 285 11
209 341 7
322 16 4
138 63 10
179 45 8
483 346 0
451 462 3
426 20 9
13 393 2
371 397 11
286 394 3
459 492 5
168 191 9
280 84 9
58 450 1
488 ...

output:

1811
10 6 8 10 11 15 23 26 28 35 41 48 50 60 65 67 68 70 73 82 90 91 92 98 104 108 110 111 119 120 123 129 132 134 135 136 140 141 142 144 156 157 158 161 162 169 171 173 179 183 188 189 196 197 198 199 202 203 206 207 210 218 220 226 230 231 232 233 235 240 241 249 254 255 256 258 263 269 282 283 2...

result:

ok Participant found an answer (1811 trees) and jury found an answer (1815 trees)

Test #79:

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

input:

500 1000 19
86 306 12
335 193 17
326 457 4
299 144 2
115 123 5
132 187 4
427 94 18
301 21 1
412 382 7
323 3 12
184 5 4
63 206 16
253 13 11
217 58 11
376 447 12
96 367 14
115 496 11
289 423 4
27 426 13
85 43 10
352 334 10
9 24 8
139 58 15
252 391 17
431 27 15
318 144 13
120 174 5
457 164 0
361 136 17...

output:

1853
4 2 3 7 10 11 14 15 28 33 35 36 39 42 45 49 50 51 52 55 57 58 65 69 74 77 78 80 81 88 89 93 94 97 99 100 105 110 116 121 125 128 129 136 143 149 150 157 161 167 168 169 179 189 193 194 195 196 202 203 205 211 214 219 220 224 226 228 229 230 231 232 237 247 251 252 255 260 262 263 281 282 285 28...

result:

ok Participant found an answer (1853 trees) and jury found an answer (1867 trees)

Test #80:

score: 0
Accepted
time: 33ms
memory: 7476kb

input:

500 1000 17
445 244 2
466 33 11
364 329 2
149 178 14
58 462 7
229 292 7
246 137 15
230 323 0
214 26 8
500 282 16
368 127 16
104 109 15
466 297 6
220 390 0
8 298 11
176 371 7
421 52 8
104 314 4
321 162 14
490 152 12
20 58 8
424 407 3
129 383 1
149 245 13
253 313 15
268 440 3
115 99 10
144 272 3
420 9...

output:

1871
14 7 10 13 17 20 27 28 31 34 35 39 42 50 54 55 56 58 59 60 61 63 65 66 67 75 78 82 85 87 92 96 99 101 104 105 106 108 109 111 113 115 124 125 126 129 132 133 134 139 140 142 144 149 150 165 173 177 181 184 185 190 191 192 193 198 204 205 209 212 220 223 229 234 235 236 238 242 247 250 263 266 2...

result:

ok Participant found an answer (1871 trees) and jury found an answer (1891 trees)

Test #81:

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

input:

500 1000 37
295 448 25
8 60 16
172 113 16
267 265 28
190 466 28
455 167 30
445 191 32
221 238 13
337 94 21
480 485 16
355 385 10
310 45 5
282 459 23
75 399 31
431 102 1
106 436 5
273 86 29
434 478 15
256 112 31
366 142 32
166 24 31
378 263 9
480 473 34
378 123 9
44 107 8
437 320 7
326 301 36
371 286...

output:

1931
1 1 11 12 13 16 19 21 22 27 31 33 37 38 39 40 43 51 56 61 62 63 72 81 84 88 89 90 100 102 104 106 108 119 135 136 138 141 147 150 151 152 159 163 164 168 171 172 173 174 182 183 186 187 191 194 195 197 202 208 210 212 215 216 218 222 224 226 227 228 229 231 234 238 240 241 246 250 254 262 266 2...

result:

ok Participant found an answer (1931 trees) and jury found an answer (1949 trees)

Test #82:

score: 0
Accepted
time: 23ms
memory: 5804kb

input:

500 1000 2
153 397 0
310 193 1
485 63 1
399 31 0
24 425 1
294 217 1
467 407 1
185 137 1
116 157 1
27 435 0
466 492 1
406 142 1
115 194 1
347 174 0
355 4 0
461 300 1
300 311 0
62 211 0
273 276 1
128 49 1
479 357 1
140 447 1
157 11 0
299 306 1
195 33 1
364 361 1
101 481 0
428 281 0
472 172 1
111 146 1...

output:

977
1 3 8 17 20 22 23 24 25 30 35 42 45 46 47 51 52 64 68 69 70 75 78 85 90 95 98 99 103 109 110 112 121 124 125 126 128 131 132 134 135 137 138 140 142 143 144 154 155 161 174 177 180 185 190 192 195 196 198 204 205 209 210 213 218 222 223 236 242 248 256 257 259 268 272 274 275 279 280 285 286 298...

result:

ok Participant found an answer (977 trees) and jury found an answer (1095 trees)

Test #83:

score: 0
Accepted
time: 25ms
memory: 6500kb

input:

500 1000 3
387 185 2
476 228 0
338 471 0
82 320 2
209 124 2
84 114 1
310 229 1
247 245 2
483 53 2
346 476 2
390 496 2
480 479 1
477 130 0
116 221 1
431 134 0
409 243 2
434 250 1
316 474 1
439 36 1
413 387 2
98 465 2
470 94 2
307 308 2
25 472 1
253 368 1
388 386 0
29 105 1
399 37 0
128 363 2
496 390 ...

output:

1345
0 1 4 5 6 9 10 13 16 20 21 24 30 32 33 37 39 44 45 52 54 55 61 62 63 70 74 75 76 79 80 82 83 84 89 98 101 104 111 112 117 118 120 124 126 128 129 130 132 136 137 138 142 145 148 149 160 167 169 170 174 176 177 179 181 191 192 193 201 204 208 214 215 218 219 220 222 223 232 235 243 247 251 259 2...

result:

ok Participant found an answer (1345 trees) and jury found an answer (1558 trees)

Test #84:

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

input:

500 1000 5
393 71 4
100 478 4
188 300 1
208 401 0
277 448 3
2 113 2
174 147 1
243 326 3
208 401 2
210 366 2
232 222 2
46 213 1
11 461 3
323 303 3
90 264 0
159 236 4
115 353 3
259 119 3
484 349 4
366 458 4
132 431 2
364 194 4
279 195 2
56 332 1
467 95 3
38 475 1
237 161 4
327 394 0
5 453 2
226 170 4
...

output:

1633
4 3 5 17 21 22 23 25 26 30 31 32 42 43 45 46 47 51 56 59 63 64 65 66 68 70 72 75 91 94 96 98 99 100 103 104 105 107 110 115 124 135 136 138 143 145 149 159 162 165 166 172 173 176 178 179 183 185 187 197 200 202 203 206 208 209 211 214 217 220 226 228 231 232 241 242 243 244 246 249 253 254 258...

result:

ok Participant found an answer (1633 trees) and jury found an answer (1649 trees)

Test #85:

score: 0
Accepted
time: 30ms
memory: 7432kb

input:

500 1000 7
354 312 4
42 187 3
394 234 1
10 28 0
487 177 5
447 76 5
156 262 4
66 127 2
224 9 5
256 497 2
306 25 2
155 12 0
283 149 3
96 272 5
471 112 4
70 87 5
48 269 2
27 463 2
285 397 6
157 56 5
196 30 4
272 250 2
62 471 2
491 361 5
177 301 6
239 361 5
347 365 6
161 332 3
378 160 2
339 303 2
438 23...

output:

1703
3 6 23 30 33 36 43 47 48 56 68 69 71 72 73 75 86 91 95 96 98 109 112 116 118 124 128 132 133 138 139 141 148 150 151 154 159 160 165 166 173 174 175 180 187 193 195 196 199 203 204 209 217 219 223 228 235 239 243 244 247 252 257 258 259 260 267 268 273 276 277 280 282 283 284 289 292 294 295 29...

result:

ok Participant found an answer (1703 trees) and jury found an answer (1759 trees)

Test #86:

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

input:

500 1000 11
40 259 0
476 339 2
48 359 8
288 117 10
137 152 9
220 295 4
497 493 3
70 88 8
239 155 8
177 401 2
423 227 2
484 208 1
51 283 9
74 65 8
233 394 8
351 17 5
350 241 8
230 451 8
301 360 4
73 185 9
445 258 6
77 132 8
473 206 9
28 86 9
112 387 4
259 60 1
13 312 9
211 180 10
472 280 2
88 191 6
4...

output:

1801
0 1 3 10 21 23 29 30 39 44 48 49 51 54 55 58 61 62 65 67 70 71 75 79 80 82 87 92 96 98 102 104 110 111 113 115 116 121 123 126 130 135 136 137 142 143 144 150 156 160 161 163 165 169 170 173 175 181 183 189 191 195 200 202 205 208 210 214 217 220 225 228 229 231 243 245 251 255 257 261 275 277 ...

result:

ok Participant found an answer (1801 trees) and jury found an answer (1860 trees)

Test #87:

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

input:

500 1000 13
250 384 4
61 59 9
336 83 12
393 321 5
259 168 9
321 464 7
92 435 11
177 29 8
476 29 2
281 241 2
114 18 12
454 169 12
89 422 8
227 333 2
445 118 1
463 311 6
376 54 9
335 93 10
133 220 4
270 471 9
232 260 0
293 491 3
418 396 11
161 487 2
461 86 11
337 292 2
94 85 4
463 277 8
257 158 0
304 ...

output:

1827
1 5 7 9 11 14 21 22 27 38 39 41 43 47 48 50 51 55 56 58 67 72 84 95 96 97 101 105 107 117 121 122 124 129 131 132 133 134 137 142 147 160 162 163 166 177 178 184 193 198 199 206 207 214 219 220 222 223 224 229 233 234 243 245 247 252 253 256 257 258 263 265 266 268 269 271 275 276 277 279 281 2...

result:

ok Participant found an answer (1827 trees) and jury found an answer (1847 trees)

Test #88:

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

input:

500 1000 499
157 84 490
264 381 235
155 322 77
498 427 140
24 231 194
191 307 195
207 196 269
343 73 130
44 193 73
103 263 64
301 225 296
114 257 86
206 398 257
477 244 135
406 337 427
381 423 67
468 215 400
1 428 163
199 64 199
74 413 40
404 299 334
481 422 430
38 50 323
415 176 386
476 223 389
414...

output:

1967
169 6 14 17 21 25 26 30 33 34 37 41 42 44 46 51 52 56 58 62 67 73 78 92 98 100 101 102 108 109 113 118 119 120 123 124 126 130 131 132 133 137 141 142 147 150 152 153 156 157 162 163 169 171 172 174 175 179 182 201 202 204 208 212 215 217 218 224 228 231 235 236 238 240 244 245 247 252 253 257 ...

result:

ok Participant found an answer (1967 trees) and jury found an answer (1967 trees)

Test #89:

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

input:

498 1000 71
391 67 7
174 52 21
414 34 31
314 442 64
321 64 28
340 70 41
265 366 45
365 460 30
106 13 8
420 32 17
291 313 27
328 186 57
97 28 20
193 454 48
281 263 2
10 380 32
362 345 21
203 217 52
143 440 11
146 189 7
68 457 32
199 42 55
156 191 37
220 488 26
57 314 47
233 145 37
232 30 66
377 447 6...

output:

1905
54 3 5 7 8 13 18 20 26 27 28 30 32 36 47 49 60 62 66 67 69 76 77 84 86 88 91 94 97 102 121 128 132 140 142 143 145 147 150 159 160 163 164 165 168 170 175 176 177 184 185 186 190 191 192 193 195 199 203 209 212 217 234 235 237 244 247 248 249 252 255 259 262 270 272 274 278 287 288 290 293 294 ...

result:

ok Participant found an answer (1905 trees) and jury found an answer (1915 trees)

Test #90:

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

input:

499 1000 89
195 395 79
43 323 64
251 316 55
220 379 87
121 463 84
160 82 11
224 372 71
245 122 52
8 496 21
484 321 36
27 355 84
232 435 77
257 461 64
423 160 5
325 286 36
159 398 66
202 496 63
296 392 50
203 80 25
326 184 57
159 108 82
139 75 2
315 22 10
459 256 36
85 271 10
398 88 47
477 370 23
463...

output:

1907
52 2 3 13 19 22 33 38 46 48 51 57 58 61 63 66 70 73 74 77 87 91 92 94 95 109 110 113 115 119 123 124 127 128 129 133 136 148 159 164 167 168 173 175 196 197 207 209 210 211 212 213 215 221 226 230 233 235 240 244 246 247 255 256 261 262 263 266 271 278 282 286 289 292 293 296 297 300 301 302 30...

result:

ok Participant found an answer (1907 trees) and jury found an answer (1911 trees)

Test #91:

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

input:

492 1000 491
334 391 303
446 29 310
309 237 454
388 378 442
238 86 331
115 120 284
90 144 134
353 474 105
175 187 332
229 290 63
158 66 56
484 36 24
448 3 244
196 127 324
15 384 120
11 215 44
158 262 362
208 130 337
454 67 333
458 38 165
294 451 464
488 85 486
197 237 100
106 97 288
391 244 297
385 ...

output:

1921
38 13 15 16 22 25 33 37 39 45 48 56 61 66 68 70 72 82 83 84 87 91 92 93 94 99 100 105 110 113 114 115 116 119 123 124 128 131 132 137 138 140 146 151 153 154 155 158 160 162 165 167 176 178 179 184 185 187 192 196 197 200 203 208 210 223 224 230 231 239 243 250 252 254 260 265 268 271 274 275 2...

result:

ok Participant found an answer (1921 trees) and jury found an answer (1923 trees)

Test #92:

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

input:

500 1000 2
167 184 0
67 339 0
11 476 0
75 13 1
340 2 0
347 270 0
74 164 1
111 337 1
469 357 1
18 464 0
263 454 0
158 477 1
63 141 1
128 39 1
255 37 1
324 131 1
1 396 0
186 493 1
50 108 0
81 425 0
207 413 1
29 153 0
18 300 0
174 445 0
123 86 0
359 203 0
415 351 1
216 121 0
307 19 1
416 210 1
236 166 ...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #93:

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

input:

500 1000 3
176 110 0
298 72 2
499 92 1
376 346 2
293 60 2
299 266 2
274 269 1
486 147 2
62 245 1
377 166 1
337 99 2
6 431 1
282 62 1
328 260 1
165 276 1
335 174 1
250 241 1
90 481 1
244 207 2
452 401 2
337 233 1
130 230 1
273 443 0
57 331 2
241 56 0
27 108 1
331 57 1
171 402 1
474 31 0
300 322 0
416...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #94:

score: 0
Accepted
time: 1ms
memory: 3820kb

input:

500 1000 5
469 352 4
51 298 0
215 35 1
363 445 0
342 157 4
371 97 1
197 462 2
238 271 0
277 44 3
438 422 3
489 85 3
175 104 0
119 449 0
335 500 1
396 424 2
30 347 3
286 331 2
378 298 4
7 265 3
58 138 1
206 260 0
179 72 3
261 360 1
141 335 1
155 112 4
434 290 2
1 393 0
167 63 2
269 344 4
279 357 4
44...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #95:

score: 0
Accepted
time: 1ms
memory: 3824kb

input:

500 1000 7
375 65 5
452 326 1
15 398 2
495 414 4
172 437 4
324 182 1
486 381 3
50 490 0
259 132 0
219 34 1
325 428 6
48 207 1
425 166 4
23 355 6
276 226 0
495 323 0
163 187 2
288 107 2
295 216 4
424 403 2
163 465 6
244 385 3
165 398 4
42 73 2
285 291 0
190 423 1
1 266 3
181 14 0
376 495 5
34 437 4
4...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #96:

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

input:

500 1000 11
280 239 3
332 180 10
390 46 1
128 380 10
472 302 1
68 276 1
152 129 4
220 381 1
436 270 6
326 54 1
243 457 4
271 401 2
471 53 8
438 417 10
487 183 3
139 243 6
58 41 1
494 142 7
325 381 2
21 358 9
305 438 5
469 322 0
202 491 1
344 162 7
419 166 6
302 486 6
449 271 7
350 196 5
93 82 1
115 ...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #97:

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

input:

500 1000 13
30 138 7
175 493 6
246 480 0
18 330 0
59 241 11
476 357 7
28 389 3
418 188 0
245 466 12
408 482 8
2 409 7
133 101 3
198 182 8
369 212 9
217 457 12
78 65 11
406 293 5
166 241 11
203 334 1
121 237 1
471 25 2
494 139 11
46 223 1
177 427 5
60 75 8
84 77 10
18 182 6
107 160 4
144 122 9
336 43...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #98:

score: 0
Accepted
time: 1ms
memory: 3776kb

input:

500 1000 499
20 85 183
336 241 220
55 123 149
305 231 19
332 442 3
496 315 342
27 277 95
489 24 141
354 53 90
301 402 382
302 230 483
374 166 403
423 491 86
74 497 337
70 205 392
201 337 176
477 224 310
62 147 371
222 10 367
195 292 227
26 359 46
443 117 440
261 459 490
332 361 46
366 333 127
25 171...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #99:

score: 0
Accepted
time: 1ms
memory: 3740kb

input:

498 1000 71
405 411 41
190 233 44
116 319 8
54 104 14
286 484 42
137 59 35
90 421 23
486 39 57
16 154 36
432 258 37
133 265 68
447 297 35
145 357 17
73 64 27
411 15 35
455 408 67
418 403 17
351 334 36
409 237 0
237 454 2
492 111 70
187 422 47
469 294 33
67 23 16
157 55 14
5 205 9
10 178 64
13 449 6
...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #100:

score: 0
Accepted
time: 1ms
memory: 3736kb

input:

499 1000 89
254 50 28
173 495 56
45 194 55
259 87 41
327 488 81
493 311 13
349 393 42
134 176 70
240 287 27
254 49 80
297 319 38
353 288 29
434 151 76
288 48 63
428 118 2
228 150 69
482 399 48
128 7 61
46 13 63
168 486 40
86 201 20
325 186 74
22 115 65
107 271 77
489 162 52
313 254 8
40 87 71
169 15...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #101:

score: 0
Accepted
time: 1ms
memory: 4044kb

input:

492 1000 491
70 485 328
34 461 437
336 214 374
91 305 488
209 453 139
483 40 27
71 155 64
101 315 175
246 71 471
481 121 269
334 350 353
321 152 439
210 311 266
444 422 234
114 88 253
465 334 60
48 99 145
168 282 469
131 145 385
195 32 384
31 198 468
361 437 77
84 214 52
485 191 119
116 173 179
250 ...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #102:

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

input:

2 1 444183629
1 2 0

output:

1
0 1 

result:

ok Participant found an answer (1 trees) and jury found an answer (0 trees)

Test #103:

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

input:

2 1 919788329
1 2 403732454

output:

1
403732454 1 

result:

ok Participant found an answer (1 trees) and jury found an answer (1 trees)

Test #104:

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

input:

3 2 200906261
1 2 112248798
2 3 112248798

output:

1
112248798 1 2 

result:

ok Participant found an answer (1 trees) and jury found an answer (1 trees)

Test #105:

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

input:

3 2 900818773
1 2 754296841
2 3 349736761

output:

-1

result:

ok Both jury and participant did not find an answer

Test #106:

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

input:

3 3 69154747
1 3 4122830
3 2 63246634
2 1 8302210

output:

5
37835837 2 3 
25410797 2 3 
43743950 1 3 
39621120 2 3 
29533627 1 2 

result:

ok Participant found an answer (5 trees) and jury found an answer (5 trees)

Test #107:

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

input:

3 1000 375844523
2 3 357734409
1 2 293999630
2 3 148711458
2 1 149360409
3 2 80457083
3 2 115553726
1 3 87700041
3 2 3416162
3 1 72485540
1 3 230247854
1 3 15648116
1 2 290466330
1 3 42966262
3 2 312704702
2 1 235345284
1 3 94491902
1 3 147921760
1 3 158695285
1 2 31505046
1 3 57480958
1 3 199210559...

output:

1999
38191886 999 1000 
148711458 3 1000 
227133065 999 1000 
149360409 4 999 
226484114 999 1000 
80457083 5 1000 
295387440 999 1000 
115553726 6 1000 
260290797 999 1000 
87700041 7 999 
288144482 999 1000 
3416162 8 1000 
372428361 999 1000 
72485540 9 999 
303358983 999 1000 
230247854 10 999 
...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #108:

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

input:

4 4 913419097
2 4 56474239
4 1 414954899
1 3 863875007
3 2 686255943

output:

7
64907298 1 3 4 
798967709 1 3 4 
114451388 1 2 4 
621348645 1 3 4 
292070452 1 2 3 
8433059 2 3 4 
904986038 1 3 4 

result:

ok Participant found an answer (7 trees) and jury found an answer (7 trees)

Test #109:

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

input:

4 4 703050533
2 4 578979740
4 1 254368534
1 3 20893612
3 2 324618559

output:

7
158603304 1 3 4 
565340841 1 3 4 
137709692 1 2 4 
166015255 1 3 4 
537035278 1 2 3 
282674097 2 3 4 
420376436 1 3 4 

result:

ok Participant found an answer (7 trees) and jury found an answer (7 trees)

Test #110:

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

input:

5 5 505808197
1 5 117356375
5 4 465876185
4 2 280342071
2 3 350456051
3 1 265857945

output:

9
496424206 2 3 4 5 
475260176 2 3 4 5 
30548021 1 3 4 5 
289726062 2 3 4 5 
216082135 1 2 4 5 
359840042 2 3 4 5 
145968155 1 2 3 5 
275241936 2 3 4 5 
230566261 1 2 3 4 

result:

ok Participant found an answer (9 trees) and jury found an answer (9 trees)

Test #111:

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

input:

5 5 890255869
1 5 636575718
5 4 706954798
4 2 661487719
2 3 694779897
3 1 146319932

output:

9
711529516 2 3 4 5 
885681151 2 3 4 5 
4574718 1 3 4 5 
840214072 2 3 4 5 
50041797 1 2 4 5 
873506250 2 3 4 5 
16749619 1 2 3 5 
325046285 2 3 4 5 
565209584 1 2 3 4 

result:

ok Participant found an answer (9 trees) and jury found an answer (9 trees)