QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#654142#8938. Crawling on a Tree11d10xyAC ✓805ms11624kbC++141.8kb2024-10-18 21:09:062024-10-18 21:09:15

Judging History

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

  • [2024-10-18 21:09:15]
  • 评测
  • 测评结果:AC
  • 用时:805ms
  • 内存:11624kb
  • [2024-10-18 21:09:06]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using i64=long long;
int n,m,c[10010];
struct N_{
   int L,R;
   vector<i64>a;
   void reserve(int l1,int r1){
      int l=max(l1,L),r=min(r1,R);
      if(l>r)a={};
      else{
         a.erase(begin(a),begin(a)+l-L);
         a.erase(end(a)-(R-r),end(a));
         L=l,R=r;
      }
   }
   void extend(int r,i64 v){
      r=max(r,R);
      a.insert(end(a),r-R,v),R=r;
   }
};
N_ mul(N_ x,N_ y){
   if(x.a.empty()||y.a.empty())return{};
   vector<i64>d;
   for(int i=1;i<x.a.size();i++)d.push_back(x.a[i]-x.a[i-1]);
   int N=d.size();
   for(int i=1;i<y.a.size();i++)d.push_back(y.a[i]-y.a[i-1]);
   inplace_merge(begin(d),begin(d)+N,end(d));
   d.insert(begin(d),x.a[0]+y.a[0]);
   for(int i=1;i<d.size();i++)d[i]+=d[i-1];
   return{x.L+y.L,x.R+y.R,d};
}
struct E_{int k,l,v;};
vector<E_>G[10010];
N_ dfs(int u,int fa,int k,int l){
   N_ prod{0,0,{0}};
   for(E_ e:G[u])if(e.v!=fa){
      prod=mul(prod,dfs(e.v,u,e.k,e.l));
      prod.reserve(0,m);
      c[u]=max(c[u],c[e.v]);
   }
   if(prod.a.empty())return prod;
   prod.extend(m,1e18);
   for(int i=1;i<prod.a.size();i++)prod.a[i]=min(prod.a[i],prod.a[i-1]);
   if(u>1){
      prod.reserve(c[u]*2-k,k);
      for(int i=prod.L;i<=prod.R;i++){
         prod.a[i-prod.L]+=(max(c[u],i)*2-i)*1ll*l;
      }
   }else prod.reserve(c[u],m);
   return prod;
}
int main(){
   scanf("%d%d",&n,&m);
   for(int i=1,u,v,k,l;i<n;i++){
      scanf("%d%d%d%d",&u,&v,&l,&k);
      G[u].push_back({k,l,v});
      G[v].push_back({k,l,u});
   }
   for(int i=2;i<=n;i++){
      scanf("%d",&c[i]);
   }
   N_ res=dfs(1,0,0,0);
   vector<i64>ans(m+1,-1);
   if(!res.a.empty()){
      for(int i=res.L;i<=res.R;i++)ans[i]=res.a[i-res.L];
   }
   for(int i=1;i<=m;i++)printf("%lld\n",ans[i]);
   return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

-1
13

result:

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

Test #2:

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

input:

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

output:

-1
-1

result:

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

Test #3:

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

input:

2 1
2 1 1 1
1

output:

1

result:

ok 1 number(s): "1"

Test #4:

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

input:

2 50
2 1 1 1
50

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

result:

ok 50 numbers

Test #5:

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

input:

2 50
2 1 1 50
50

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
50

result:

ok 50 numbers

Test #6:

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

input:

2 50
1 2 1 100000
50

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
50

result:

ok 50 numbers

Test #7:

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

input:

50 1
1 2 85524 58896
2 3 9137 9819
3 4 3036 88987
4 5 78909 15766
5 6 76067 34996
6 7 64247 63701
7 8 14 9384
8 9 37698 35418
9 10 51427 91691
10 11 39818 89351
11 12 47887 64083
12 13 43836 44135
13 14 22561 83803
14 15 52617 97413
15 16 41869 83810
16 17 35783 18642
17 18 5514 34601
18 19 50448 49...

output:

3202064

result:

ok 1 number(s): "3202064"

Test #8:

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

input:

50 5
1 2 48897 1
2 3 59967 3
3 4 61806 2
4 5 48519 4
5 6 77213 5
6 7 32384 1
7 8 59009 2
8 9 98263 1
9 10 42945 6
10 11 5549 6
11 12 51097 6
12 13 88536 4
13 14 44215 2
14 15 56896 2
15 16 19263 5
16 17 30787 5
17 18 20135 3
18 19 75922 4
19 20 35387 5
20 21 84081 4
21 22 54235 5
22 23 44411 3
23 24...

output:

-1
-1
-1
-1
-1

result:

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

Test #9:

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

input:

50 10
1 2 44914 14
2 3 84737 11
3 4 76461 7
4 5 36207 14
5 6 48479 10
6 7 88167 14
7 8 71415 7
8 9 95290 10
9 10 12553 7
10 11 2718 7
11 12 89004 12
12 13 86605 10
13 14 76252 14
14 15 75076 10
15 16 52024 14
16 17 23365 15
17 18 93829 13
18 19 3765 10
19 20 72010 9
20 21 17119 7
21 22 83633 14
22 2...

output:

-1
-1
9947212
9947212
9947212
9947212
9947212
9947212
9947212
9947212

result:

ok 10 numbers

Test #10:

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

input:

50 20
1 2 84157 10
2 3 20072 5
3 4 36547 8
4 5 46072 11
5 6 64560 10
6 7 51220 8
7 8 6257 14
8 9 85793 7
9 10 67400 7
10 11 37948 14
11 12 64361 12
12 13 15316 14
13 14 86110 9
14 15 66507 13
15 16 31139 9
16 17 91577 12
17 18 30027 7
18 19 17865 9
19 20 16377 14
20 21 70649 14
21 22 29703 5
22 23 7...

output:

-1
-1
8952969
8952969
8952969
8952969
8952969
8952969
8952969
8952969
8952969
8952969
8952969
8952969
8952969
8952969
8952969
8952969
8952969
8952969

result:

ok 20 numbers

Test #11:

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

input:

50 30
1 2 92254 8
2 3 67112 8
3 4 51573 12
4 5 45236 11
5 6 86302 12
6 7 5974 14
7 8 96820 7
8 9 83266 13
9 10 83174 8
10 11 14722 9
11 12 80728 10
12 13 71250 12
13 14 59937 14
14 15 33700 7
15 16 58668 9
16 17 66269 9
17 18 30776 9
18 19 91575 11
19 20 51383 7
20 21 92925 14
21 22 70739 7
22 23 60...

output:

-1
-1
-1
-1
-1
18181356
18181356
18181356
18181356
18181356
18181356
18181356
18181356
18181356
18181356
18181356
18181356
18181356
18181356
18181356
18181356
18181356
18181356
18181356
18181356
18181356
18181356
18181356
18181356
18181356

result:

ok 30 numbers

Test #12:

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

input:

50 50
1 2 44120 30
2 3 73250 30
3 4 68398 30
4 5 98932 30
5 6 98719 30
6 7 96765 30
7 8 71479 30
8 9 37151 30
9 10 91752 30
10 11 8218 30
11 12 66373 30
12 13 49494 30
13 14 56744 30
14 15 829 30
15 16 61166 30
16 17 64926 30
17 18 76821 30
18 19 18028 30
19 20 3749 30
20 21 38173 30
21 22 57828 30
...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
33741592
33741592
33741592
33741592
33741592
33741592
33741592
33741592
33741592
33741592
33741592
33741592
33741592
33741592
33741592
33741592
33741592
33741592
33741592
33741592
33741592
33741592
33741592
33741592
33741592
33741592
33741592
33741592
33741592
...

result:

ok 50 numbers

Test #13:

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

input:

50 50
1 2 32039 30
2 3 25573 30
3 4 93435 30
4 5 12864 30
5 6 81011 30
6 7 72386 30
7 8 60555 30
8 9 44065 30
9 10 87410 30
10 11 95846 30
11 12 22377 30
12 13 33453 30
13 14 24010 30
14 15 84584 30
15 16 66399 30
16 17 15580 30
17 18 91590 30
18 19 72162 30
19 20 96308 30
20 21 57991 30
21 22 69903...

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

result:

ok 50 numbers

Test #14:

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

input:

50 50
1 2 90182 100
2 3 80679 100
3 4 17341 100
4 5 14788 100
5 6 25843 100
6 7 19327 100
7 8 64668 100
8 9 261 100
9 10 11742 100
10 11 87415 100
11 12 4372 100
12 13 27691 100
13 14 88014 100
14 15 71401 100
15 16 79534 100
16 17 74095 100
17 18 81196 100
18 19 93774 100
19 20 18579 100
20 21 8033...

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
126552274

result:

ok 50 numbers

Test #15:

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

input:

50 50
1 2 36276 100
2 3 234 100
3 4 42378 100
4 5 28720 100
5 6 8136 100
6 7 27716 100
7 8 53744 100
8 9 7176 100
9 10 49224 100
10 11 33219 100
11 12 25912 100
12 13 44418 100
13 14 78991 100
14 15 55156 100
15 16 84767 100
16 17 91981 100
17 18 63197 100
18 19 40548 100
19 20 78370 100
20 21 149 1...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
104297593

result:

ok 50 numbers

Test #16:

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

input:

50 50
1 2 89387 100
2 3 41204 100
3 4 80467 100
4 5 13758 100
5 6 11818 100
6 7 30592 100
7 8 28372 100
8 9 48338 100
9 10 1818 100
10 11 70286 100
11 12 52808 100
12 13 74834 100
13 14 69168 100
14 15 25792 100
15 16 28166 100
16 17 19009 100
17 18 80450 100
18 19 63550 100
19 20 35778 100
20 21 84...

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
133219774

result:

ok 50 numbers

Test #17:

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

input:

50 50
1 2 15303 100
2 3 98808 100
3 4 15515 100
4 5 76922 100
5 6 45606 100
6 7 18024 100
7 8 83194 100
8 9 22871 100
9 10 93775 100
10 11 59712 100
11 12 13986 100
12 13 94177 100
13 14 20817 100
14 15 66237 100
15 16 34816 100
16 17 3800 100
17 18 76471 100
18 19 23516 100
19 20 11297 100
20 21 18...

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
143745580

result:

ok 50 numbers

Test #18:

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

input:

50 50
1 2 58242 100
2 3 52909 100
3 4 68175 100
4 5 35825 100
5 6 26534 100
6 7 23990 100
7 8 65980 100
8 9 64364 100
9 10 53688 100
10 11 61013 100
11 12 61050 100
12 13 93001 100
13 14 65905 100
14 15 68787 100
15 16 11043 100
16 17 67314 100
17 18 1482 100
18 19 14105 100
19 20 35473 100
20 21 44...

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
136747391
136747391
136747391

result:

ok 50 numbers

Test #19:

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

input:

50 50
1 2 87313 100
2 3 34142 100
3 4 75601 100
4 5 86787 100
5 6 19862 100
6 7 13844 100
7 8 59860 100
8 9 71550 100
9 10 15855 100
10 11 53118 100
11 12 89343 100
12 13 90120 100
13 14 30675 100
14 15 24900 100
15 16 46699 100
16 17 30187 100
17 18 47132 100
18 19 79439 100
19 20 46609 100
20 21 8...

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
180004277

result:

ok 50 numbers

Test #20:

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

input:

50 50
1 2 6377 100
2 3 74759 100
3 4 12929 100
4 5 78652 100
5 6 45614 100
6 7 63300 100
7 8 2272 100
8 9 29671 100
9 10 1466 100
10 11 57378 100
11 12 69874 100
12 13 88680 100
13 14 59380 100
14 15 98428 100
15 16 1823 100
16 17 32536 100
17 18 73638 100
18 19 41194 100
19 20 39472 100
20 21 90418...

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
162625095

result:

ok 50 numbers

Test #21:

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

input:

50 50
1 2 49316 100
2 3 28860 100
3 4 98357 100
4 5 4787 100
5 6 68367 100
6 7 60210 100
7 8 61346 100
8 9 3932 100
9 10 26915 100
10 11 25911 100
11 12 49706 100
12 13 20271 100
13 14 46292 100
14 15 33746 100
15 16 78050 100
16 17 96050 100
17 18 98649 100
18 19 99015 100
19 20 30880 100
20 21 163...

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
178165310

result:

ok 50 numbers

Test #22:

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

input:

50 50
1 2 50686 100
2 3 61764 100
3 4 2158 100
4 5 61656 100
5 6 16190 100
6 7 47188 100
7 8 71543 100
8 9 79011 100
9 10 3719 100
10 11 80950 100
11 12 43743 100
12 13 12383 100
13 14 46293 100
14 15 93814 100
15 16 70307 100
16 17 73720 100
17 18 59814 100
18 19 6883 100
19 20 26432 100
20 21 1051...

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
168905607

result:

ok 50 numbers

Test #23:

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

input:

50 50
1 2 52472 100
2 3 52489 100
3 4 37966 100
4 5 59816 100
5 6 27907 100
6 7 29864 100
7 8 58580 100
8 9 36585 100
9 10 97123 100
10 11 3182 100
11 12 84054 100
12 13 72639 100
13 14 26646 100
14 15 56775 100
15 16 7056 100
16 17 83190 100
17 18 88407 100
18 19 62560 100
19 20 66495 100
20 21 102...

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
126132174

result:

ok 50 numbers

Test #24:

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

input:

50 50
1 2 26269 57
2 3 54838 68
3 4 33860 53
4 5 610 57
5 6 13881 94
6 7 8362 52
7 8 80460 75
8 9 84662 81
9 10 19967 86
10 11 60644 60
11 12 74314 65
12 13 19781 55
13 14 7800 61
14 15 11166 61
15 16 55688 61
16 17 86280 56
17 18 87661 91
18 19 65104 79
19 20 74638 57
20 21 72951 82
21 22 77319 100...

output:

-1
6500083
6500083
6500083
6500083
6500083
6500083
6500083
6500083
6500083
6500083
6500083
6500083
6500083
6500083
6500083
6500083
6500083
6500083
6500083
6500083
6500083
6500083
6500083
6500083
6500083
6500083
6500083
6500083
6500083
6500083
6500083
6500083
6500083
6500083
6500083
6500083
6500083
6...

result:

ok 50 numbers

Test #25:

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

input:

50 50
1 2 20786 58
2 3 36289 99
3 4 72709 65
4 5 20643 51
5 6 28260 59
6 7 82771 56
7 8 54535 62
8 9 67042 54
9 10 88729 91
10 11 63285 100
11 12 87705 92
12 13 98468 66
13 14 68505 96
14 15 37086 57
15 16 96419 55
16 17 14275 56
17 18 3023 77
18 19 169 70
19 20 87534 97
20 21 58552 70
21 22 94659 7...

output:

-1
6115126
6115126
6115126
6115126
6115126
6115126
6115126
6115126
6115126
6115126
6115126
6115126
6115126
6115126
6115126
6115126
6115126
6115126
6115126
6115126
6115126
6115126
6115126
6115126
6115126
6115126
6115126
6115126
6115126
6115126
6115126
6115126
6115126
6115126
6115126
6115126
6115126
6...

result:

ok 50 numbers

Test #26:

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

input:

50 50
1 2 48235 88
2 3 73049 100
3 4 59657 71
4 5 7714 51
5 6 32279 51
6 7 46460 58
7 8 1752 75
8 9 26 85
9 10 99024 53
10 11 46614 62
11 12 74988 62
12 13 10188 54
13 14 36538 60
14 15 82973 90
15 16 49197 96
16 17 28844 64
17 18 67770 81
18 19 5892 65
19 20 31742 61
20 21 26417 75
21 22 81333 62
2...

output:

-1
5708762
5708762
5708762
5708762
5708762
5708762
5708762
5708762
5708762
5708762
5708762
5708762
5708762
5708762
5708762
5708762
5708762
5708762
5708762
5708762
5708762
5708762
5708762
5708762
5708762
5708762
5708762
5708762
5708762
5708762
5708762
5708762
5708762
5708762
5708762
5708762
5708762
5...

result:

ok 50 numbers

Test #27:

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

input:

50 1
1 2 64846 1
2 3 76726 1
3 4 75087 1
4 5 248 1
5 6 1934 1
6 7 8476 1
7 8 20723 1
8 9 1597 1
9 10 75343 1
10 11 33438 1
11 12 59347 1
12 13 4097 2
12 26 13782 2
12 27 35089 1
13 14 17043 2
14 15 69465 2
15 16 91817 2
15 29 35818 2
16 17 73625 2
17 18 83002 2
18 19 87947 2
18 32 4127 2
19 20 73738...

output:

4159205

result:

ok 1 number(s): "4159205"

Test #28:

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

input:

50 2
1 2 58565 2
2 3 98266 2
3 4 83717 2
4 5 93399 2
5 6 50704 1
6 7 51541 1
7 8 26818 1
8 9 52929 1
9 10 84124 1
10 11 55215 1
11 12 36194 1
12 13 43797 1
13 14 34685 1
14 15 98478 2
14 26 75129 1
15 16 54681 2
16 17 71688 2
17 18 73687 2
17 31 95774 2
18 19 14608 2
18 32 30611 2
19 20 61422 2
19 2...

output:

-1
4959570

result:

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

Test #29:

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

input:

50 10
1 2 12734 10
2 3 27338 10
3 4 15936 10
4 5 30198 9
5 6 59960 9
6 7 14693 9
7 8 67702 9
8 9 63361 8
9 10 76125 7
10 11 77894 6
11 12 6787 6
12 13 12390 5
13 14 30868 9
13 26 57318 10
13 27 6991 6
14 15 14783 9
15 16 15431 7
16 17 31742 5
17 18 73924 6
17 30 98533 5
18 19 48352 6
18 31 40456 4
1...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
10817378

result:

ok 10 numbers

Test #30:

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

input:

50 50
1 2 8473 43
2 3 71048 38
3 4 54201 37
4 5 49351 35
5 6 33457 32
6 7 70017 30
7 8 41296 26
8 9 51812 21
9 10 508 17
10 11 46766 14
11 12 69582 14
12 13 41682 13
13 14 52211 17
13 28 3255 20
14 15 1549 17
15 16 93912 15
16 17 6064 14
17 18 60581 10
18 19 53797 12
18 26 99776 15
18 27 12746 14
18...

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
30524399
30524399
30524399
30524399
30524399
30524399
30524399
30524399

result:

ok 50 numbers

Test #31:

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

input:

50 50
1 2 67321 42
2 3 26698 37
3 4 85929 35
4 5 97341 29
5 6 64650 27
6 7 35137 23
7 8 75283 21
8 9 57707 21
9 10 86844 20
10 11 3992 16
11 12 92196 13
12 13 5032 12
13 14 65067 12
14 15 3646 10
14 26 89560 18
15 16 3394 10
16 17 37812 15
16 27 10336 14
16 29 19308 13
17 18 54566 13
18 19 56404 10
...

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
39756081
39756081
39756081
39756081
39756081
39756081
39756081
39756081
39756081

result:

ok 50 numbers

Test #32:

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

input:

50 50
1 2 85385 41
2 3 77845 38
3 4 33944 32
4 5 38550 28
5 6 32835 24
6 7 24247 17
7 8 69157 15
8 9 51497 14
9 10 27936 13
10 11 381 12
11 12 16281 10
12 13 59050 10
13 14 32472 8
14 15 5164 7
15 16 50121 7
16 17 94207 8
16 29 87325 11
17 18 53384 6
17 32 54346 10
18 19 11948 6
18 30 95782 8
19 20 ...

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
28676009
28676009
28676009
28676009
28676009
28676009
28676009
28676009
28676009
28676009

result:

ok 50 numbers

Test #33:

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

input:

50 50
1 2 97493 43
2 3 93134 39
3 4 71163 37
4 5 74205 37
5 6 93088 31
6 7 63629 28
7 8 1505 26
8 9 79134 23
9 10 52544 22
10 11 146 19
11 12 15842 19
11 26 89715 30
12 13 85906 19
13 14 65003 19
14 15 92124 19
15 16 13802 17
15 28 65107 20
16 17 26724 17
17 18 24108 19
17 30 66288 18
18 19 5760 15
...

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
56153920
56153920
56153920
56153920
56153920
56153920
56153920
56153920

result:

ok 50 numbers

Test #34:

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

input:

50 50
1 2 56938 42
2 3 59402 35
3 4 69840 30
4 5 43455 27
5 6 85737 27
6 7 57562 24
7 8 99187 22
8 9 77083 21
9 10 85265 19
10 11 52260 17
11 12 70886 14
12 13 79327 13
13 14 41214 12
14 15 27029 10
15 16 16710 10
16 17 77240 12
16 26 32047 15
16 27 73115 15
17 18 82223 11
18 19 99445 11
19 20 85248...

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
40563245
40563245
40563245
40563245
40563245
40563245
40563245
40563245
40563245

result:

ok 50 numbers

Test #35:

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

input:

50 50
1 2 98510 46
2 3 93965 46
3 4 41929 44
4 5 19848 42
5 6 68598 39
6 7 70832 35
7 8 83776 33
8 9 33801 31
9 10 77350 27
10 11 55278 26
11 12 32635 24
12 13 89355 22
13 14 98727 21
14 15 38114 23
14 29 88163 36
15 16 26791 34
15 26 14880 35
15 27 18787 34
16 17 38977 32
17 18 56052 30
18 19 10461...

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
86355759
86355759
86355759
86355759
86355759

result:

ok 50 numbers

Test #36:

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

input:

50 50
1 2 76463 46
2 3 31143 44
3 4 76369 41
4 5 15357 40
5 6 21881 37
6 7 70117 36
7 8 23175 35
8 9 41791 34
9 10 43869 32
10 11 50610 31
11 12 65893 27
12 13 52967 27
12 27 44201 50
13 14 89804 26
14 15 89880 22
15 16 65330 22
16 17 8584 24
16 28 51503 40
16 30 36335 36
17 18 4796 22
18 19 83241 2...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
70604858
70604858
70604858
70604858
70604858

result:

ok 50 numbers

Test #37:

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

input:

50 50
1 2 24405 44
2 3 62219 39
3 4 72335 37
4 5 15808 34
5 6 71844 34
6 7 3009 32
7 8 62543 31
8 9 87213 30
9 10 1651 29
10 11 29640 26
11 12 72054 25
12 13 59995 30
12 26 1153 43
13 14 50864 26
14 15 37921 28
14 28 88374 28
15 16 77545 24
16 17 15843 20
17 18 3630 21
17 29 15181 27
18 19 10 21
18 ...

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
56132191
56132191
56132191
56132191
56132191
56132191
56132191

result:

ok 50 numbers

Test #38:

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

input:

50 50
1 2 80463 50
2 3 52642 46
3 4 60998 41
4 5 82093 41
5 6 35487 34
6 7 26785 31
7 8 40155 28
8 9 19547 27
9 10 68628 21
10 11 14443 16
11 12 64052 17
12 13 13207 17
13 14 89753 17
13 28 5337 19
14 15 96152 12
14 29 39804 20
15 16 18519 15
16 17 43395 14
16 27 50929 21
17 18 16195 17
17 31 40822 ...

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
30531572
30531572
30531572
30531572
30531572
30531572
30531572
30531572
30531572
30531572

result:

ok 50 numbers

Test #39:

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

input:

50 50
1 2 86377 46
2 3 39502 40
3 4 50121 30
4 5 2762 27
5 6 90187 28
6 7 56040 27
7 8 42193 20
8 9 12189 19
9 10 26945 20
10 11 96194 14
11 12 62631 18
12 13 92402 12
13 14 96849 14
14 15 41552 13
15 16 22385 15
15 26 18815 22
16 17 93023 14
16 31 89063 18
17 18 35476 12
17 27 79383 16
18 19 67023 ...

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
29089524
29089524
29089524
29089524
29089524
29089524
29089524
29089524
29089524
29089524

result:

ok 50 numbers

Test #40:

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

input:

50 50
1 2 99844 51
2 3 73364 45
3 4 27309 33
4 5 33862 29
5 6 3739 24
6 7 78082 17
7 8 84577 23
8 9 29919 23
9 10 96344 15
10 11 51253 20
11 12 32795 11
12 13 66178 10
13 14 83625 8
14 15 49160 13
14 27 51079 12
15 16 91341 18
15 26 49339 17
15 29 4602 15
16 17 2706 12
17 18 95293 8
17 28 12923 17
1...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
21645025
21645025
21645025
21645025
21645025
21645025
21645025
21645025

result:

ok 50 numbers

Test #41:

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

input:

50 50
1 2 77698 46
2 3 96016 46
3 4 43785 41
4 5 86726 38
5 6 63069 34
6 7 63396 30
7 8 51770 28
8 9 60419 20
9 10 63858 20
10 11 23436 15
11 12 51818 13
12 13 91135 14
13 14 33979 13
14 15 143 12
15 16 79186 9
15 27 33604 14
16 17 43185 11
17 18 79288 8
17 26 7628 16
18 19 85146 10
18 33 96908 13
1...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
30019114
30019114
30019114
30019114
30019114
30019114
30019114
30019114
30019114
30019114

result:

ok 50 numbers

Test #42:

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

input:

50 50
1 2 20167 43
2 3 53262 40
3 4 39931 42
4 5 37885 37
5 6 75474 33
6 7 22855 34
7 8 74049 29
8 9 28188 27
9 10 65682 22
10 11 26686 17
11 12 1730 11
12 13 88870 13
13 14 29953 12
14 15 73596 11
15 16 26037 5
15 29 58466 15
15 30 44952 14
16 17 14090 6
17 18 55989 5
18 19 29084 10
18 26 72367 12
...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
19378390
19378390
19378390
19378390
19378390
19378390
19378390
19378390
19378390
19378390
19378390
19378390

result:

ok 50 numbers

Test #43:

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

input:

50 50
1 2 12142 49
2 3 30573 41
3 4 39885 35
4 5 8853 35
5 6 89261 34
6 7 91249 28
7 8 55843 32
8 9 71878 20
9 10 59528 19
10 11 76319 16
11 12 41015 11
12 13 41003 15
13 14 87699 19
14 15 97980 19
15 16 46558 21
15 30 41546 11
16 17 28227 6
17 18 18671 8
17 26 30765 17
17 31 84553 12
18 19 70893 12...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
20575841
20575841
20575841
20575841
20575841
20575841

result:

ok 50 numbers

Test #44:

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

input:

50 50
1 2 10901 52
2 3 94622 45
3 4 26574 36
4 5 24672 35
5 6 26633 34
6 7 36144 30
7 8 32927 22
8 9 50330 21
9 10 56016 24
10 11 55152 26
11 12 12766 23
11 26 95845 33
12 13 82159 22
13 14 8531 20
13 27 84591 29
14 15 12790 29
14 29 79499 18
15 16 52143 20
16 17 91896 18
17 18 56194 25
17 32 37162 ...

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
27788632
27788632
27788632
27788632
27788632
27788632
27788632
27788632

result:

ok 50 numbers

Test #45:

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

input:

50 50
1 2 5193 55
2 3 99911 42
3 4 70425 38
4 5 31958 29
5 6 28031 30
6 7 26187 30
7 8 18786 26
8 9 68615 19
9 10 45881 22
10 11 30651 16
11 12 24499 19
12 13 22832 14
12 26 9776 30
13 14 84000 21
14 15 33541 18
15 16 2331 17
15 27 3036 16
16 17 18787 16
17 18 79602 12
18 19 72112 16
19 20 44759 10
...

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
20314715
20314715
20314715
20314715
20314715
20314715
20314715
20314715
20314715
20314715

result:

ok 50 numbers

Test #46:

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

input:

50 50
1 2 69735 91
1 3 67629 91
1 4 64395 97
1 5 57674 98
1 6 22880 94
1 7 44243 95
1 8 5977 92
1 9 79874 91
1 10 28888 93
1 11 16709 84
1 12 30710 92
1 13 66175 98
1 14 90591 92
1 15 72133 93
1 16 64499 93
1 17 97794 94
1 18 55719 97
1 19 64532 91
1 20 88034 89
1 21 71181 94
1 22 56480 88
1 23 9681...

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
230913673

result:

ok 50 numbers

Test #47:

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

input:

50 50
1 2 18560 97
1 3 58108 96
1 4 24196 96
1 5 52010 87
1 6 81513 93
1 7 84070 94
1 8 98678 98
1 9 17889 98
1 10 90085 96
1 11 9886 98
1 12 6373 97
1 13 41975 98
1 14 77175 98
1 15 92566 91
1 16 43026 97
1 17 73277 95
1 18 16287 89
1 19 10238 95
1 20 63998 102
1 21 55652 93
1 22 54335 92
1 23 7469...

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
240713938
240616501

result:

ok 50 numbers

Test #48:

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

input:

50 50
1 2 65214 68
1 3 81530 86
1 4 15657 87
1 5 44143 88
2 6 21706 86
2 7 10019 90
2 8 35299 90
2 9 98504 87
2 10 97049 89
3 11 52918 86
3 12 56531 89
3 13 74630 92
3 14 19967 85
3 15 40632 87
4 16 64973 83
4 17 73838 92
4 18 66291 86
4 19 65935 86
4 20 45191 82
5 21 89637 88
5 22 29800 84
5 23 798...

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
236485086
236241924
235998762

result:

ok 50 numbers

Test #49:

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

input:

50 50
1 2 99276 84
1 3 73308 83
1 4 82748 85
1 5 89983 88
1 6 54934 93
1 7 39985 89
1 8 15266 90
1 9 22213 93
1 10 56030 97
2 11 86209 89
2 12 87543 91
2 13 44224 91
2 14 53076 89
2 15 6318 89
2 16 97675 92
2 17 59919 85
2 18 92202 89
2 19 3289 82
2 20 89391 89
3 21 48342 93
3 22 9584 91
3 23 12547 ...

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
242594441
242397490
242200539

result:

ok 50 numbers

Test #50:

score: 0
Accepted
time: 169ms
memory: 5016kb

input:

10000 10000
1 2 199194692 986
2 3 923159214 862
2 4 548448431 11785
2 5 196017345 3828
4 6 617436340 13406
3 7 939115752 7521
1 8 378387969 13234
2 9 930724711 19784
6 10 235683367 1335
9 11 715849733 17244
9 12 646199534 15253
8 13 130696451 12121
5 14 532284400 3526
6 15 105642585 18051
14 16 8220...

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

Test #51:

score: 0
Accepted
time: 579ms
memory: 5936kb

input:

10000 10000
1 2 456724468 16746
2 3 942677058 18642
1 4 948400701 18003
1 5 712253535 16506
3 6 290056119 15461
2 7 534818430 14742
3 8 676296013 14679
1 9 902251366 11339
3 10 437662004 10510
9 11 283485265 17689
7 12 980587179 14243
6 13 42172584 16257
10 14 181427286 10824
11 15 264856579 17429
1...

output:

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

result:

ok 10000 numbers

Test #52:

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

input:

10000 10000
1 2 242668490 10180041
2 3 823547727 484450939
3 4 828905869 473282776
3 5 136634816 935795341
3 6 966680067 33192004
1 7 189115788 238815725
5 8 557803192 75920607
5 9 757402081 137851514
2 10 564136803 399914223
6 11 33900894 976547841
7 12 400298516 316754394
2 13 29812211 15546700
4 ...

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

Test #53:

score: 0
Accepted
time: 573ms
memory: 5836kb

input:

10000 10000
1 2 172369195 19984
2 3 760612326 19994
2 4 903408646 19979
2 5 35441943 19953
1 6 907139285 19955
2 7 355937832 19915
2 8 12459999 19966
2 9 598862143 19947
3 10 290691412 19965
2 11 385518907 19966
3 12 316436715 19931
9 13 206486304 19944
13 14 405947504 19967
10 15 222741186 19904
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 10000 numbers

Test #54:

score: 0
Accepted
time: 483ms
memory: 7888kb

input:

10000 10000
1 2 470902064 20000
2 3 730926699 20000
3 4 724199166 20000
4 5 42535658 20000
5 6 540971485 20000
6 7 311396936 20000
7 8 31959735 20000
8 9 250228066 20000
9 10 908495359 20000
10 11 996671963 20000
11 12 51243049 20000
12 13 17290906 20000
13 14 486831662 20000
14 15 272522313 20000
1...

output:

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

result:

ok 10000 numbers

Test #55:

score: 0
Accepted
time: 515ms
memory: 7908kb

input:

10000 10000
1 2 50193305 20000
2 3 507643193 20000
3 4 371873421 20000
4 5 452206830 20000
5 6 678447435 20000
6 7 766194217 20000
7 8 968359655 20000
8 9 127376455 20000
9 10 591999530 20000
10 11 32268955 20000
11 12 118520335 20000
12 13 287077611 20000
13 14 114982471 20000
14 15 2018290 20000
1...

output:

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

result:

ok 10000 numbers

Test #56:

score: 0
Accepted
time: 519ms
memory: 7820kb

input:

10000 10000
1 2 843440777 20000
2 3 716690542 20000
3 4 137000513 20000
4 5 367407003 20000
5 6 54270186 20000
6 7 69392404 20000
7 8 160926813 20000
8 9 403422090 20000
9 10 738894406 20000
10 11 820956614 20000
11 12 928339113 20000
12 13 873999650 20000
13 14 224964184 20000
14 15 537510157 20000...

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

Test #57:

score: 0
Accepted
time: 481ms
memory: 7848kb

input:

10000 10000
1 2 742315885 20000
2 3 351239111 20000
3 4 889278529 20000
4 5 963556998 20000
5 6 358467656 20000
6 7 287214902 20000
7 8 701451560 20000
8 9 865981085 20000
9 10 279556456 20000
10 11 780527014 20000
11 12 475717363 20000
12 13 732482526 20000
13 14 766130586 20000
14 15 62525942 2000...

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

Test #58:

score: 0
Accepted
time: 525ms
memory: 7844kb

input:

10000 10000
1 2 898706716 20000
2 3 618822339 20000
3 4 73234645 20000
4 5 296662228 20000
5 6 676226692 20000
6 7 847108584 20000
7 8 183383404 20000
8 9 16707684 20000
9 10 295800245 20000
10 11 115044050 20000
11 12 266752747 20000
12 13 66410081 20000
13 14 563349116 20000
14 15 17830752 20000
1...

output:

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

result:

ok 10000 numbers

Test #59:

score: 0
Accepted
time: 592ms
memory: 8332kb

input:

10000 10000
1 2 201608990 20000
2 3 815659005 20000
3 4 210163629 20000
4 5 336599638 20000
5 6 226911555 20000
6 7 562038001 20000
7 8 618053990 20000
8 9 506449092 20000
9 10 691437598 20000
10 11 963271306 20000
11 12 512751224 20000
12 13 214264130 20000
13 14 171131140 20000
14 15 73372845 2000...

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

Test #60:

score: 0
Accepted
time: 524ms
memory: 8124kb

input:

10000 10000
1 2 11778435 20000
2 3 675118330 20000
3 4 897647553 20000
4 5 2537790 20000
5 6 536412131 20000
6 7 409882452 20000
7 8 248519628 20000
8 9 174995133 20000
9 10 747830966 20000
10 11 687725706 20000
11 12 75340719 20000
12 13 61579748 20000
13 14 331500054 20000
14 15 395929221 20000
15...

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

Test #61:

score: 0
Accepted
time: 465ms
memory: 7780kb

input:

10000 10000
1 2 257326193 12817
2 3 55118035 12450
3 4 530859569 17727
4 5 132645273 12209
5 6 141015079 11381
6 7 169570331 18278
7 8 403744814 17095
8 9 947933479 17887
9 10 997852585 12192
10 11 20870223 12643
11 12 438841339 15390
12 13 38197866 17888
13 14 445242636 15959
14 15 563454995 15952
...

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

Test #62:

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

input:

10000 10000
1 2 912604814 10836
2 3 679776381 12686
3 4 732861314 11420
4 5 333277451 14107
5 6 480161298 14754
6 7 554629957 10410
7 8 837759077 11439
8 9 870551276 19729
9 10 265021426 18661
10 11 523919697 15271
11 12 521278984 18152
12 13 306157021 14877
13 14 512886855 13931
14 15 230061706 164...

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

Test #63:

score: 0
Accepted
time: 83ms
memory: 5468kb

input:

10000 10000
1 2 838225710 5
2 3 360543469 2
3 4 39697505 1
4 5 638936782 1
5 6 729198770 1
6 7 368106080 1
7 8 14913003 1
8 9 280246341 1
9 10 46877096 1
10 11 592884021 1
11 12 253085148 1
12 13 291585659 1
13 14 37510986 1
14 15 841871990 1
15 16 211110412 1
16 17 371824921 1
17 18 294578192 1
18 ...

output:

-1
-1
-1
-1
7760561365021
7760561365021
7760561365021
7760561365021
7760561365021
7760561365021
7760561365021
7760561365021
7760561365021
7760561365021
7760561365021
7760561365021
7760561365021
7760561365021
7760561365021
7760561365021
7760561365021
7760561365021
7760561365021
7760561365021
77605613...

result:

ok 10000 numbers

Test #64:

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

input:

10000 10000
1 2 443327465 809
2 3 262713315 631
3 4 957264335 492
4 5 689092169 400
5 6 860802051 324
6 7 582913639 246
7 8 35177342 189
8 9 541659409 154
9 10 453709070 129
10 11 430026028 101
11 12 28662226 86
12 13 273197110 73
13 14 551092162 61
14 15 210841275 49
15 16 732541476 40
16 17 585053...

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

Test #65:

score: 0
Accepted
time: 75ms
memory: 5484kb

input:

10000 10000
1 2 534124873 8907
2 3 676990283 7915
3 4 755336743 7083
4 5 781573373 6321
5 6 746401710 5645
6 7 530944075 5041
7 8 835930317 4502
8 9 598083334 3973
9 10 859505879 3527
10 11 896467108 3118
11 12 868227589 2790
12 13 13723326 2496
13 14 361321458 2238
14 15 685221779 1997
15 16 336934...

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

Test #66:

score: 0
Accepted
time: 84ms
memory: 5744kb

input:

10000 10000
1 2 193147412 8269
2 3 138039617 7404
3 4 376802838 6576
4 5 786235637 5879
5 6 629733018 5245
6 7 928837633 4657
7 8 595646852 4198
8 9 452869445 3747
9 10 812971211 3329
10 11 301571568 2977
11 12 923653882 2674
12 13 213452296 2375
13 14 163950512 2115
14 15 890773734 1887
15 16 13699...

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

Test #67:

score: 0
Accepted
time: 84ms
memory: 5744kb

input:

10000 10000
1 2 36143840 9418
2 3 817477336 8883
3 4 736510666 8383
4 5 244106659 7882
5 6 61590367 7417
6 7 941772853 6965
7 8 30071310 6562
8 9 284273212 6161
9 10 339815273 5819
10 11 722329549 5453
11 12 277872549 5150
12 13 828520416 4822
13 14 6819099 4539
14 15 972375759 4274
15 16 595895497 ...

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

Test #68:

score: 0
Accepted
time: 76ms
memory: 5412kb

input:

10000 10000
1 2 32503394 5952
2 3 751394114 5634
3 4 320566182 5297
4 5 470092868 4990
5 6 580641646 4720
6 7 948768477 4416
7 8 5091502 4175
8 9 341695402 3948
9 10 364285130 3703
10 11 458481146 3489
11 12 484202014 3281
12 13 309230163 3092
13 14 596051063 2939
14 15 521069291 2744
15 16 37757890...

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

Test #69:

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

input:

10000 10000
1 2 338399926 5416
2 3 678635843 5171
3 4 931114625 4839
4 5 546062107 4516
5 6 839049637 4339
6 7 437121840 4006
7 8 617300508 3798
8 9 169626414 3592
9 10 756665570 3420
10 11 254059779 3224
11 12 412691576 2979
12 13 958334305 2818
13 14 27103075 2665
14 15 969733695 2532
15 16 325455...

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

Test #70:

score: 0
Accepted
time: 107ms
memory: 5768kb

input:

10000 10000
1 2 536856172 8198
2 3 400954742 7877
3 4 209238343 7202
4 5 70376206 6934
5 6 678025158 6195
6 7 485180102 6287
7 8 354514580 5238
8 9 686663675 5392
9 10 186101597 4955
10 11 593460298 5013
11 12 774858576 4195
12 13 602887701 4342
13 14 167077284 4484
14 15 790040325 3289
15 16 903870...

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

Test #71:

score: 0
Accepted
time: 83ms
memory: 5440kb

input:

10000 10000
1 2 414913155 5194
2 3 592334595 4895
3 4 95026466 4594
4 5 951317012 4324
5 6 40305022 4063
6 7 255522093 3821
7 8 438316296 3617
8 9 891714371 3394
9 10 616272086 3222
10 11 529600046 3036
11 12 622496802 2852
12 13 18310952 2683
13 14 257468105 2541
14 15 773391186 2390
15 16 92346670...

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

Test #72:

score: 0
Accepted
time: 85ms
memory: 5728kb

input:

10000 10000
1 2 560969984 7510
2 3 360580736 7113
3 4 18875027 6696
4 5 738263779 6323
5 6 417553880 5939
6 7 479333654 5613
7 8 72350023 5240
8 9 714861338 4914
9 10 796142987 4615
10 11 264908134 4344
11 12 805673990 4065
12 13 390826851 3829
13 14 877011276 3569
14 15 17829872 3387
15 16 4126627 ...

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

Test #73:

score: 0
Accepted
time: 99ms
memory: 5716kb

input:

10000 10000
1 2 576183052 8407
2 3 852669690 8361
3 4 809474020 8163
4 5 995648254 7668
5 6 780646482 7164
6 7 124588984 6963
7 8 687689218 6372
8 9 675569783 5760
9 10 902364291 5211
10 11 361450412 5081
11 12 934013896 4922
12 13 598309741 4554
13 14 138627754 4417
14 15 570295284 3958
15 16 17225...

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

Test #74:

score: 0
Accepted
time: 108ms
memory: 5760kb

input:

10000 10000
1 2 967913524 9113
2 3 430077159 8570
3 4 600977672 7680
4 5 785495560 7786
5 6 575516578 6831
6 7 444440417 7276
7 8 17721187 6677
8 9 383045212 6183
9 10 76222173 5856
10 11 851932119 5805
11 12 23248475 4901
12 13 28083875 4459
13 14 162245206 4494
14 15 948535816 4324
15 16 639795712...

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

Test #75:

score: 0
Accepted
time: 472ms
memory: 10312kb

input:

10000 10000
1 2 31785526 20000
2 3 613365255 20000
3 4 445577083 20000
4 5 41607506 20000
5 6 765040443 20000
6 7 804730172 20000
7 8 413224531 20000
8 9 469810782 20000
9 10 441602872 20000
10 11 205787429 20000
11 12 68209776 20000
12 13 778166866 20000
13 14 423461654 20000
14 15 824962939 20000
...

output:

-1
12890302976564
12890302976564
12890302976564
12890302976564
12890302976564
12890302976564
12890302976564
12890302976564
12890302976564
12890302976564
12890302976564
12890302976564
12890302976564
12890302976564
12890302976564
12890302976564
12890302976564
12890302976564
12890302976564
128903029765...

result:

ok 10000 numbers

Test #76:

score: 0
Accepted
time: 496ms
memory: 11624kb

input:

10000 10000
1 2 787750397 10000
2 3 386501730 10000
3 4 48104855 10000
4 5 615617261 10000
5 6 315426426 10000
6 7 347044889 10000
7 8 760474545 10000
8 9 17065659 10000
9 10 837266174 10000
10 11 698342557 10000
11 12 807381332 10000
12 13 59841279 10000
13 14 250990428 10000
14 15 945156881 10000
...

output:

7031885141209
7031885141209
7031885141209
7031885141209
7031885141209
7031885141209
7031885141209
7031885141209
7031885141209
7031885141209
7031885141209
7031885141209
7031885141209
7031885141209
7031885141209
7031885141209
7031885141209
7031885141209
7031885141209
7031885141209
7031885141209
703188...

result:

ok 10000 numbers

Test #77:

score: 0
Accepted
time: 805ms
memory: 4948kb

input:

10000 10000
1 2 866358132 15630
1 3 231117247 15587
1 4 243683937 18860
1 5 377586155 18820
1 6 124936022 18797
1 7 369369323 18901
1 8 265363552 18865
1 9 528028228 18830
1 10 954059933 18762
1 11 930832591 18851
1 12 417598655 18889
1 13 492390201 18762
1 14 948202383 18814
1 15 475154563 18847
1 ...

output:

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

result:

ok 10000 numbers

Test #78:

score: 0
Accepted
time: 708ms
memory: 4772kb

input:

10000 10000
1 2 636160157 13959
1 3 891178133 14024
1 4 34412657 16966
1 5 121787658 17018
1 6 383017695 16857
1 7 687624876 16933
1 8 407243838 17005
1 9 224450437 16918
1 10 16331243 16973
1 11 919431652 16937
1 12 811016902 16924
1 13 59640028 16941
1 14 852873653 16961
1 15 136641730 16943
1 16 ...

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

Extra Test:

score: 0
Extra Test Passed