QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#167746#4092. 진화Lynkcat#26 669ms80048kbC++202.1kb2023-09-07 17:06:372024-07-04 02:41:33

Judging History

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

  • [2024-07-04 02:41:33]
  • 评测
  • 测评结果:26
  • 用时:669ms
  • 内存:80048kb
  • [2023-09-07 17:06:37]
  • 提交

answer

#include "evolution.h"
#include<bits/stdc++.h>
#define poly vector<int>
#define IOS ios::sync_with_stdio(false)
#define ll long long
#define mp make_pair
#define mt make_tuple
#define pa pair < int,int >
#define fi first
#define se second
#define inf 1e18
#define mod 998244353
#define sz(x) ((int)((x).size()))
// #define int ll
#define N 500005
using namespace std;
namespace 
{
    int n;
    multiset<int>S[N],all;
    int dis[N],ans[N];
    int ffa[N];
}
inline int mx(multiset<int>&s)
{
    if (s.empty()) return 0;
    return (*--s.end());
}
inline int smx(multiset<int>&s)
{
    if (s.size()<=1) return 0;
    return (*(--(--s.end())))+1;
}
inline int ssmx(multiset<int>&s)
{
    if (s.size()<=2) return 0;
    return (*(--(--(--s.end()))))+1;
}
inline int qry(int k)
{
    return max(mx(S[k]),smx(S[k]));
}
inline int qry1(int k)
{
    return max({mx(S[k])+smx(S[k]),smx(S[k])+ssmx(S[k])});
}
void init()
{
    n=1;
    all.insert(qry1(1));
}
void work(int k,int x)
{
    if (k==1) return;
    int fa=ffa[k];
    // cout<<k<<" "<<x<<" "<<ans[k]<<" "<<dis[k]<<" "<<qry1(k)<<" "<<S[k].size()<<endl;
    S[fa].insert(dis[k]);
    bool bl=1;
    all.erase(all.find(ans[fa]));

    bl&=(ans[fa]==max(x,qry1(fa)));
    bl&=(dis[fa]==qry(fa));
    // cout<<k<<" "<<x<<" "<<fa<<endl;

    ans[fa]=max(x,qry1(fa));
    all.insert(ans[fa]);
    // cout<<k<<" "<<x<<" "<<fa<<endl;
    // 
    if (bl) return;
    if (fa!=1) S[ffa[fa]].erase(S[ffa[fa]].find(dis[fa]));
    // cout<<k<<" "<<x<<" "<<fa<<endl;
    dis[fa]=qry(fa);
    work(fa,max(x,ans[fa]));
}

void observation(int P)
{
    ++n;
    ffa[n]=P;
    all.insert(qry1(n));
    work(n,0);
    // cout<<P<<" "<<n<<endl;
    // cout<<endl;
    // for (int i=1;i<=n;i++) cout<<ans[i]<<' ';
    // cout<<endl;
    // for (int i=1;i<=n;i++) cout<<dis[i]<<' ';
    // cout<<endl;
    // for (int i=1;i<=n;i++) cout<<mx(S[i])<<' ';
    // cout<<endl;
    // for (int i=1;i<=n;i++) cout<<smx(S[i])<<' ';
    // cout<<endl;
}
int analyze(int R)
{
    // cout<<"qry "<<R<<endl;
    return ans[R];
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 7
Accepted
time: 3ms
memory: 27392kb

input:

30
1 1
2 1
2 1
2 1
2 2
1 1
1 3
2 1
2 4
2 3
1 3
1 5
1 4
1 2
2 5
1 7
1 4
2 7
2 7
2 3
1 3
2 6
1 10
1 1
2 13
2 2
1 6
1 1
2 12
1 3

output:

3989776153
7481903423
6741079408

result:

ok 3 lines

Test #2:

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

input:

30
2 1
1 1
2 1
1 1
2 3
2 2
2 2
1 3
1 3
1 5
2 3
2 6
2 5
1 5
2 3
1 1
1 5
2 5
1 6
2 10
1 8
1 1
2 7
1 4
2 1
2 12
1 5
1 10
2 15
1 14

output:

4085837229
8898398677
7224337819

result:

ok 3 lines

Test #3:

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

input:

30
2 1
1 1
2 2
2 1
2 1
1 2
1 3
2 1
2 3
1 3
1 3
1 6
2 7
1 7
1 8
2 5
2 8
2 8
2 8
2 1
2 3
1 2
1 7
2 8
1 3
1 1
2 9
1 2
1 13
1 10

output:

3655449673
6979384347
7116385622

result:

ok 3 lines

Test #4:

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

input:

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

output:

5020315711
8126182581
7528146226

result:

ok 3 lines

Test #5:

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

input:

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

output:

3863214647
9004572285
6917008405

result:

ok 3 lines

Test #6:

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

input:

30
2 1
2 1
2 1
2 1
1 1
2 1
1 2
1 2
2 4
2 2
1 1
1 4
1 4
1 6
1 7
2 5
2 2
1 9
1 9
2 6
1 9
2 1
1 12
1 13
2 6
1 8
2 1
2 7
1 15
2 11

output:

3652881517
6273534925
8008251562

result:

ok 3 lines

Test #7:

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

input:

29
1 1
2 2
1 1
1 2
1 4
2 2
1 5
2 2
1 6
2 4
2 4
2 5
2 1
2 2
1 7
1 2
1 7
1 4
2 5
1 11
2 3
2 5
1 11
2 1
1 11
2 8
1 14
2 5
2 1

output:

3725140493
7344134703
8142212909

result:

ok 3 lines

Test #8:

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

input:

30
2 1
2 1
2 1
1 1
2 2
2 2
1 2
2 1
2 2
1 2
1 4
1 4
1 3
1 4
1 4
1 9
1 3
2 3
2 9
2 2
1 10
2 5
2 2
2 9
1 12
2 2
1 9
2 10
1 14
1 15

output:

4216385963
6981773419
9451704565

result:

ok 3 lines

Test #9:

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

input:

29
2 1
2 1
1 1
2 2
2 1
1 1
1 3
2 3
2 2
1 4
1 1
2 1
1 6
1 3
1 5
1 5
1 7
1 8
1 9
2 4
2 6
1 13
2 9
2 11
2 11
2 2
1 8
2 1
1 15

output:

2671636536
8087981266
7681836138

result:

ok 3 lines

Test #10:

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

input:

30
2 1
1 1
1 1
2 1
2 3
2 1
1 3
2 3
2 1
1 1
1 5
2 5
1 2
1 7
2 7
2 1
1 7
2 7
1 5
1 9
2 5
1 10
2 5
2 3
1 12
1 10
2 3
2 5
1 9
1 10

output:

5734571725
8303927063
9400323222

result:

ok 3 lines

Test #11:

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

input:

30
1 1
1 1
1 1
1 2
1 2
1 2
1 7
1 4
1 3
1 7
1 9
1 6
1 7
1 7
1 10
2 7
2 1
2 1
2 1
2 2
2 1
2 1
2 1
2 3
2 4
2 1
2 4
2 1
2 1
2 1

output:

7775546089
5981974793
8038532257

result:

ok 3 lines

Test #12:

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

input:

30
1 1
1 2
1 2
1 4
1 2
1 6
1 4
1 8
1 8
1 8
1 7
1 12
1 11
1 14
1 12
2 5
2 1
2 1
2 3
2 2
2 4
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1

output:

6133216433
6334176229
10274413981

result:

ok 3 lines

Test #13:

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

input:

30
1 1
1 2
1 2
1 2
1 5
1 4
1 7
1 3
1 6
1 2
1 6
1 10
1 12
1 12
1 14
2 1
2 1
2 2
2 3
2 3
2 3
2 1
2 1
2 1
2 1
2 6
2 2
2 1
2 2
2 1

output:

7011904871
7447892923
7896128456

result:

ok 3 lines

Test #14:

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

input:

30
1 1
1 1
1 2
1 4
1 5
1 2
1 5
1 6
1 2
1 8
1 8
1 12
1 11
1 13
1 11
2 1
2 3
2 1
2 1
2 9
2 8
2 1
2 1
2 3
2 9
2 1
2 4
2 1
2 1
2 1

output:

7235939759
6270114761
8318033369

result:

ok 3 lines

Test #15:

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

input:

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

output:

6065360561
6104872627
10436812948

result:

ok 3 lines

Test #16:

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

input:

30
2 1
1 1
2 1
2 2
1 2
2 1
2 2
1 3
1 4
1 4
1 4
1 7
2 2
2 2
2 3
1 7
1 7
1 4
2 1
1 10
1 5
2 13
2 12
2 6
1 8
1 13
2 13
2 15
1 9
2 16

output:

3738213511
6482823973
8216824708

result:

ok 3 lines

Test #17:

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

input:

30
1 1
2 1
2 1
1 2
1 3
2 3
2 4
2 1
2 2
2 4
1 4
1 5
1 4
2 2
2 1
2 3
1 4
1 6
1 9
2 9
2 10
2 7
1 9
2 1
1 6
2 11
1 2
1 4
1 14
1 12

output:

4693745583
7742558919
7646775389

result:

ok 3 lines

Test #18:

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

input:

30
1 1
1 2
1 3
1 4
2 1
2 5
2 2
2 4
2 1
1 4
2 1
1 6
1 4
2 1
1 1
2 8
2 2
2 8
1 6
2 4
2 9
2 6
1 2
1 5
1 4
1 5
2 3
1 2
1 2
2 4

output:

4570815573
5702629941
7848389807

result:

ok 3 lines

Test #19:

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

input:

30
1 1
1 2
2 1
2 2
2 1
2 1
1 3
2 2
2 1
1 4
1 4
2 6
2 5
1 4
2 5
2 4
2 2
2 2
2 1
1 1
1 2
1 5
1 3
1 4
1 6
2 11
1 8
1 10
1 7
2 3

output:

5214538151
7726306013
7485674391

result:

ok 3 lines

Test #20:

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

input:

30
1 1
1 2
1 3
2 3
2 1
1 4
1 4
2 4
2 6
2 1
1 6
1 7
2 6
2 3
2 7
2 2
2 5
2 8
2 7
1 7
1 9
2 1
1 9
1 2
2 8
1 2
1 13
1 2
2 5
1 5

output:

4806816967
7308341709
6988462606

result:

ok 3 lines

Test #21:

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

input:

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

output:

5702183321
7697492445
6404427529

result:

ok 3 lines

Test #22:

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

input:

30
2 1
2 1
1 1
2 1
2 1
1 2
1 3
1 4
1 4
1 6
2 2
1 6
2 3
2 1
1 2
2 3
2 2
1 8
2 8
1 4
2 4
2 8
1 1
1 11
2 2
1 10
1 4
1 15
2 6
2 10

output:

5747397881
6661658357
8996758003

result:

ok 3 lines

Test #23:

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

input:

30
2 1
2 1
2 1
1 1
1 2
1 3
2 4
1 3
1 3
1 5
1 7
1 4
1 6
2 3
2 1
1 1
2 11
1 9
2 3
1 11
2 10
2 13
2 3
2 3
1 2
1 6
2 14
2 12
2 6
1 6

output:

4675237001
7243073851
9074221286

result:

ok 3 lines

Test #24:

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

input:

30
2 1
1 1
2 1
2 2
2 2
1 2
2 2
2 3
1 3
1 1
2 1
1 4
1 6
2 4
1 5
1 2
1 2
2 4
2 2
2 7
1 6
2 10
1 2
1 11
1 13
1 6
1 10
2 5
2 7
2 3

output:

4325089139
6920647293
7948900553

result:

ok 3 lines

Test #25:

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

input:

30
2 1
1 1
2 1
1 1
1 1
1 1
1 2
2 3
1 5
2 1
2 1
1 6
1 7
1 9
2 10
2 1
1 8
2 7
2 5
2 4
1 8
1 3
2 3
1 7
2 3
1 12
1 12
2 2
2 11
2 13

output:

3833877395
7849657363
7425325851

result:

ok 3 lines

Test #26:

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

input:

30
2 1
2 1
1 1
1 2
2 3
1 3
2 2
1 3
2 4
1 5
1 6
2 6
1 4
1 6
2 9
1 5
1 3
2 1
2 3
2 5
2 7
2 6
1 8
1 10
2 1
1 12
2 6
1 8
1 3
2 14

output:

5090644709
8207166119
7214047711

result:

ok 3 lines

Test #27:

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

input:

30
1 1
2 2
1 2
2 2
2 1
2 2
1 3
1 4
2 3
1 4
1 1
1 4
2 8
1 1
1 1
2 1
2 6
1 5
2 2
2 3
2 1
1 9
2 12
1 7
1 4
2 9
2 14
1 13
1 11
2 15

output:

5178034157
8107774363
7080979268

result:

ok 3 lines

Test #28:

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

input:

30
1 1
2 2
2 2
2 2
2 2
1 2
2 3
2 3
1 3
1 4
1 4
2 3
1 4
2 2
2 7
2 6
1 5
2 2
1 5
2 9
1 7
1 9
2 6
1 2
1 3
1 11
1 4
2 1
2 5
1 5

output:

4211069353
8168855675
8911723060

result:

ok 3 lines

Test #29:

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

input:

30
2 1
1 1
1 1
2 2
2 1
1 2
1 1
1 4
1 6
2 7
1 3
2 7
2 3
1 1
2 1
2 2
1 6
1 1
1 6
1 10
2 2
1 3
1 7
2 2
2 8
2 8
1 11
2 2
2 7
2 11

output:

4096414487
7265766149
8171354152

result:

ok 3 lines

Test #30:

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

input:

30
1 1
1 2
1 3
1 3
1 4
1 3
1 5
1 5
1 4
1 6
1 11
1 9
1 13
1 14
1 13
2 3
2 1
2 3
2 2
2 1
2 1
2 3
2 1
2 1
2 1
2 6
2 1
2 1
2 2
2 1

output:

6208849637
6397786567
10847712031

result:

ok 3 lines

Test #31:

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

input:

30
1 1
1 1
1 3
1 1
1 4
1 6
1 6
1 4
1 6
1 10
1 8
1 12
1 11
1 11
1 7
2 1
2 1
2 1
2 1
2 1
2 1
2 2
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1

output:

8630760759
6645585839
7499274594

result:

ok 3 lines

Test #32:

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

input:

30
1 1
1 1
1 3
1 3
1 2
1 6
1 6
1 4
1 8
1 6
1 11
1 11
1 10
1 10
1 13
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1

output:

7848960625
8197325795
7613386658

result:

ok 3 lines

Test #33:

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

input:

30
1 1
1 2
1 3
1 1
1 3
1 4
1 7
1 8
1 9
1 10
1 10
1 7
1 13
1 13
1 14
2 3
2 1
2 1
2 3
2 4
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 2
2 1

output:

6641072129
6480327839
11121578914

result:

ok 3 lines

Test #34:

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

input:

30
1 1
1 1
1 2
1 3
1 5
1 3
1 7
1 8
1 7
1 9
1 8
1 11
1 10
1 14
1 15
2 1
2 1
2 7
2 1
2 1
2 3
2 10
2 5
2 1
2 1
2 4
2 1
2 1
2 1
2 1

output:

7663312763
7556579533
7044923063

result:

ok 3 lines

Test #35:

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

input:

30
1 1
1 2
1 2
1 1
1 3
1 6
1 4
1 5
1 9
1 8
1 10
1 11
1 5
1 14
1 13
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 1
2 4
2 1
2 6
2 1

output:

5761711633
7367929517
10205437603

result:

ok 3 lines

Test #36:

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

input:

29
2 1
1 1
1 1
2 1
1 3
2 3
1 4
2 1
1 2
2 1
1 5
1 2
2 1
1 4
1 9
1 9
1 10
2 3
2 1
2 3
2 3
2 6
2 1
1 10
1 8
2 8
2 2
1 13
1 14

output:

6252442258
5055070144
7607858420

result:

ok 3 lines

Test #37:

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

input:

28
1 1
2 1
2 2
1 1
2 3
2 2
1 2
2 4
2 1
1 3
2 4
1 5
2 4
1 3
2 1
1 7
1 7
2 3
2 3
2 3
1 8
2 1
1 9
2 2
1 11
2 7
1 12
1 10

output:

4575912253
7564835103
7440019979

result:

ok 3 lines

Test #38:

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

input:

26
2 1
1 1
2 1
2 1
2 2
2 2
2 1
1 1
1 1
1 3
2 1
1 4
1 2
2 5
2 1
1 2
2 3
1 6
1 3
1 9
1 11
1 6
1 10
2 4
2 4
1 3

output:

2698850804
6609353536
5086904239

result:

ok 3 lines

Test #39:

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

input:

30
1 1
2 2
2 1
1 2
1 2
2 2
2 2
2 2
1 3
2 1
2 1
2 1
2 2
1 4
2 4
1 6
1 4
1 4
2 1
1 9
2 3
1 4
2 1
1 10
1 10
1 5
2 1
1 1
1 9
2 2

output:

7413943993
8110462931
7555990679

result:

ok 3 lines

Test #40:

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

input:

30
1 1
2 1
2 2
2 1
2 1
2 1
1 1
2 2
1 2
1 2
1 3
2 3
1 3
2 1
1 4
2 3
2 7
1 4
1 5
1 5
1 6
2 4
1 12
1 13
1 14
2 1
2 2
2 4
1 15
2 6

output:

4683630535
5923048231
9341976550

result:

ok 3 lines

Test #41:

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

input:

29
2 1
1 1
1 1
1 2
2 4
1 2
1 3
2 1
2 1
2 2
2 3
2 2
2 2
2 2
1 3
1 4
1 4
2 2
1 9
1 10
2 1
1 11
2 3
1 12
2 1
2 5
1 13
2 5
1 14

output:

5402194083
8220084679
8034822586

result:

ok 3 lines

Test #42:

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

input:

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

output:

4408158587
8574650327
7855430431

result:

ok 3 lines

Test #43:

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

input:

30
2 1
1 1
2 1
1 1
2 2
2 1
2 1
1 1
1 1
1 1
2 1
2 2
2 1
1 1
2 2
1 2
1 1
2 6
1 2
2 7
1 1
1 2
2 7
1 1
2 1
2 2
1 1
1 2
2 10
1 1

output:

4991313051
7858485995
6619364293

result:

ok 3 lines

Test #44:

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

input:

30
2 1
2 1
2 1
2 1
2 1
1 1
2 2
2 2
2 2
1 2
1 2
2 1
2 3
1 3
1 4
1 5
1 1
1 1
1 7
1 9
2 10
1 2
1 9
2 6
1 4
2 2
2 12
1 11
2 5
1 12

output:

3638320765
8918971937
8185731020

result:

ok 3 lines

Test #45:

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

input:

30
1 1
1 2
1 3
1 2
1 4
2 6
2 6
1 5
2 1
1 1
2 1
1 1
2 9
2 7
1 6
2 1
1 5
2 7
1 1
2 7
2 1
1 2
1 8
1 6
2 13
2 1
1 5
2 1
2 3
2 11

output:

4913879207
7116642941
6413091141

result:

ok 3 lines

Test #46:

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

input:

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

output:

2173193534
5693784896
5225829218

result:

ok 3 lines

Test #47:

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

input:

30
2 1
1 1
2 1
2 2
1 2
2 2
1 2
1 1
1 4
2 4
1 4
1 3
1 7
2 7
2 6
1 6
2 7
2 2
1 3
2 2
1 2
1 1
1 2
1 1
2 1
2 9
2 1
2 1
1 9
2 16

output:

3738649353
7300858859
9229259764

result:

ok 3 lines

Test #48:

score: -7
Wrong Answer
time: 8ms
memory: 27692kb

input:

30
1 1
1 2
2 2
2 2
1 2
2 3
2 1
1 3
2 4
2 3
2 4
1 4
1 2
2 1
1 7
1 8
1 4
2 8
2 8
2 7
1 7
1 3
1 6
1 4
2 4
2 2
1 1
2 1
2 6
1 4

output:

4552042377
6148909761
7708953630

result:

wrong answer 1st lines differ - expected: '5178350073', found: '4552042377'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 5
Accepted

Test #98:

score: 5
Accepted
time: 532ms
memory: 78496kb

input:

1000000
2 1
1 1
1 1
1 2
2 4
1 2
2 1
1 3
1 3
1 4
2 1
1 4
1 5
1 5
2 3
2 4
2 2
1 6
1 6
2 9
1 7
2 2
1 7
2 2
2 3
1 8
2 4
2 9
2 2
1 8
1 9
1 9
2 1
2 4
2 1
2 4
2 6
2 3
2 4
1 10
1 10
2 3
1 11
2 2
2 13
1 11
2 1
1 12
1 12
1 13
1 13
2 1
2 5
1 14
2 3
2 4
1 14
1 15
2 5
1 15
1 16
1 16
1 17
1 17
1 18
1 18
2 10
2 7
...

output:

226384484418682
252721864385826
254136704849695

result:

ok 3 lines

Test #99:

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

input:

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

output:

14784500253954
14669250414504
15283613553821

result:

ok 3 lines

Test #100:

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

input:

35000
1 1
2 1
1 1
2 1
1 2
1 2
2 3
2 1
2 2
2 1
1 3
1 3
2 1
1 4
2 8
2 4
1 4
1 5
2 3
2 5
1 5
1 6
2 2
2 5
1 6
1 7
1 7
2 5
1 8
2 5
2 1
2 4
2 9
1 8
1 9
1 9
1 10
1 10
1 11
2 3
2 6
2 3
2 5
2 1
1 11
2 4
1 12
2 3
2 8
1 12
1 13
1 13
2 3
2 7
2 1
1 14
1 14
1 15
2 5
1 15
2 3
1 16
1 16
1 17
1 17
2 2
1 18
1 18
2 18...

output:

6096455559752
6054967272968
6357768376585

result:

ok 3 lines

Test #101:

score: 0
Accepted
time: 192ms
memory: 48696kb

input:

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

output:

121665563089444
126544857831942
129761372078861

result:

ok 3 lines

Test #102:

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

input:

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

output:

25220690929170
25344636746902
26447936619463

result:

ok 3 lines

Test #103:

score: 0
Accepted
time: 349ms
memory: 63684kb

input:

840000
2 1
2 1
2 1
1 1
2 1
2 1
1 1
2 2
1 2
1 2
2 3
1 3
2 4
1 3
2 5
1 4
2 1
2 2
1 4
2 5
2 2
2 2
2 4
2 2
2 3
1 5
2 2
1 5
2 2
2 2
2 5
2 1
1 6
2 1
2 2
2 8
1 6
2 1
2 5
1 7
2 2
2 1
2 1
2 1
2 10
2 5
2 3
1 7
2 2
2 11
2 1
2 9
1 8
2 1
2 2
1 8
2 2
1 9
2 4
1 9
1 10
1 10
1 11
2 2
1 11
1 12
1 12
2 4
2 3
1 13
1 13...

output:

228116240634290
247830472818950
249540875626368

result:

ok 3 lines

Test #104:

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

input:

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

output:

13192477991316
13159119140522
13696711811391

result:

ok 3 lines

Test #105:

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

input:

6800
2 1
2 1
2 1
1 1
1 1
2 2
1 2
1 2
1 3
1 3
2 1
1 4
2 3
1 4
2 3
1 5
2 3
1 5
1 6
1 6
2 3
1 7
1 7
2 9
1 8
1 8
1 9
2 3
2 1
1 9
1 10
2 6
1 10
1 11
1 11
1 12
1 12
2 2
1 13
1 13
1 14
1 14
2 2
1 15
1 15
1 16
1 16
2 1
1 17
1 17
2 1
1 18
1 18
1 19
1 19
2 3
1 20
1 20
1 21
2 2
1 21
1 22
1 22
2 1
1 23
1 23
1 2...

output:

1180474027890
1141458473508
1221476654564

result:

ok 3 lines

Test #106:

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

input:

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

output:

2522281844666
2559303105128
2646473666443

result:

ok 3 lines

Test #107:

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

input:

10000
2 1
2 1
2 1
1 1
1 1
1 2
2 4
1 2
1 3
2 1
2 1
1 3
2 1
2 6
1 4
1 4
1 5
1 5
2 3
1 6
1 6
1 7
2 4
2 7
1 7
1 8
2 2
1 8
1 9
2 1
1 9
1 10
2 1
2 8
2 1
1 10
1 11
2 1
2 5
2 1
1 11
1 12
2 2
1 12
2 2
2 3
1 13
1 13
1 14
1 14
2 2
1 15
2 1
2 4
1 15
1 16
2 1
1 16
2 1
1 17
2 8
2 1
1 17
2 6
2 17
1 18
2 1
2 5
1 18...

output:

2489817197164
2536287789128
2651483685195

result:

ok 3 lines

Subtask #4:

score: 21
Accepted

Test #108:

score: 21
Accepted
time: 669ms
memory: 79928kb

input:

1000000
2 1
2 1
1 1
1 1
2 1
1 2
1 4
2 1
2 3
2 1
1 5
1 3
1 6
2 2
2 2
2 2
2 2
1 8
2 1
1 5
2 3
1 8
1 11
1 12
1 13
1 12
2 3
2 5
1 14
2 3
2 4
1 16
2 2
1 17
1 18
2 10
2 3
1 19
2 4
1 10
1 17
2 1
2 4
2 5
1 19
2 9
1 15
1 24
2 8
1 25
2 2
2 3
2 2
2 5
1 25
2 5
1 20
1 26
1 29
2 7
2 2
2 6
2 1
1 30
2 3
1 30
2 3
2 ...

output:

212888413200404
252999291073822
268758073967755

result:

ok 3 lines

Test #109:

score: 0
Accepted
time: 665ms
memory: 80048kb

input:

1000000
1 1
1 2
2 2
2 2
2 1
1 2
2 2
2 4
2 3
2 1
1 3
1 3
1 6
2 4
1 6
1 7
1 8
2 4
1 10
1 10
2 5
2 1
2 6
2 6
2 1
2 3
2 2
1 12
1 7
1 14
2 2
1 13
1 9
2 6
2 10
2 6
2 4
2 1
2 1
2 4
2 3
2 2
2 2
2 7
1 13
2 4
1 17
2 5
1 17
1 18
2 2
2 8
2 4
2 6
1 20
1 15
1 22
1 22
1 19
2 1
1 19
2 2
1 24
1 24
1 29
1 30
2 11
2 1...

output:

216652818522776
252512151299728
264334796237779

result:

ok 3 lines

Test #110:

score: 0
Accepted
time: 657ms
memory: 78972kb

input:

950000
1 1
1 2
2 3
2 3
2 1
2 2
2 1
1 3
1 2
2 3
1 5
1 5
1 7
1 7
1 8
2 2
2 2
2 1
2 2
1 8
1 10
1 10
2 4
1 12
1 13
1 11
2 1
2 1
1 13
1 11
1 14
1 15
1 15
2 10
1 18
2 3
2 1
2 4
2 2
1 20
1 16
2 9
1 16
1 20
2 4
1 26
1 19
1 26
1 28
1 28
1 25
1 29
2 12
2 5
1 22
1 30
2 2
1 33
1 25
1 37
2 2
2 6
2 12
1 34
2 3
2 ...

output:

183007317550094
232592077066068
242935152728547

result:

ok 3 lines

Test #111:

score: 0
Accepted
time: 630ms
memory: 77960kb

input:

980000
2 1
2 1
1 1
1 1
1 2
1 4
1 5
1 5
1 6
1 6
2 1
2 5
1 8
1 10
2 2
2 1
2 1
1 11
2 1
2 7
2 2
2 8
1 7
1 13
2 3
2 4
1 13
1 10
1 15
1 17
2 15
2 1
1 16
2 8
2 11
1 12
2 6
1 16
1 20
1 20
2 1
2 1
1 15
1 24
2 2
1 24
2 1
1 23
2 3
1 25
2 6
1 25
2 5
1 27
1 29
2 1
2 7
2 3
2 1
2 2
2 6
2 1
1 29
1 30
2 1
2 15
1 32...

output:

221416376201390
252867939843982
264949199527408

result:

ok 3 lines

Test #112:

score: 0
Accepted
time: 53ms
memory: 33728kb

input:

96000
2 1
2 1
2 1
1 1
2 1
2 1
1 1
1 2
2 1
1 3
2 1
2 1
1 5
1 5
2 2
1 6
2 2
1 4
2 7
1 8
1 10
1 11
1 7
2 9
2 7
2 5
2 3
2 6
1 10
1 14
2 3
1 15
1 14
1 17
1 12
1 19
1 18
2 7
2 9
1 21
2 3
1 13
1 20
2 5
2 6
2 7
2 6
2 8
1 24
1 20
1 26
1 27
1 28
2 2
2 1
1 27
1 29
1 29
1 32
2 5
2 1
1 31
1 21
2 13
2 1
2 1
1 34
...

output:

18815724775190
24813196073346
25874741354392

result:

ok 3 lines

Test #113:

score: 0
Accepted
time: 51ms
memory: 33832kb

input:

94000
1 1
2 1
2 2
1 2
1 3
1 4
2 4
1 2
2 5
2 2
1 4
2 3
2 1
2 4
1 6
1 5
1 9
1 6
2 4
2 6
2 3
2 4
2 7
1 11
1 8
2 8
1 12
2 7
2 3
2 1
1 14
1 15
1 12
2 1
2 5
1 16
1 16
1 11
1 10
2 2
1 21
2 6
1 17
1 19
1 24
2 3
1 23
2 2
1 20
1 24
2 3
1 14
1 22
1 20
1 31
2 3
2 9
1 31
1 28
1 32
2 8
1 32
2 1
1 34
2 3
1 34
1 38...

output:

19869823846930
24319436189068
24925563190330

result:

ok 3 lines

Test #114:

score: 0
Accepted
time: 38ms
memory: 32148kb

input:

78000
1 1
2 1
2 1
1 1
2 2
2 1
2 1
1 2
2 4
1 2
2 2
2 3
1 4
1 5
2 6
2 2
1 6
2 2
2 4
1 8
1 4
2 3
2 1
1 10
2 1
1 8
2 11
1 10
1 13
2 9
2 8
1 12
2 11
2 7
2 2
1 14
2 3
2 1
1 16
2 2
2 12
2 1
1 14
1 17
2 3
1 15
2 5
2 3
2 1
2 1
2 5
2 9
2 2
1 19
1 21
2 5
1 7
2 2
1 22
1 22
2 10
2 6
2 3
2 10
2 7
2 8
1 24
1 23
1 ...

output:

20912474411470
23709193057924
24829752720547

result:

ok 3 lines

Test #115:

score: 0
Accepted
time: 435ms
memory: 61796kb

input:

820000
2 1
1 1
1 2
2 3
1 1
2 2
2 2
1 3
2 1
2 2
2 1
1 5
2 2
2 2
2 1
2 2
2 1
1 4
2 5
1 4
2 5
2 1
2 2
2 2
1 3
2 6
2 6
2 3
2 2
1 8
2 6
2 4
2 3
2 2
2 1
1 7
1 9
1 5
2 7
2 2
2 4
1 9
2 2
2 1
2 4
1 11
2 4
2 1
2 2
1 15
2 11
1 14
2 2
1 14
2 1
1 17
2 10
1 19
2 9
1 18
2 3
1 21
2 2
1 19
2 13
1 21
2 2
1 22
2 5
2 5...

output:

207280564659982
252718401626124
262828853170875

result:

ok 3 lines

Test #116:

score: 0
Accepted
time: 118ms
memory: 39436kb

input:

150000
1 1
1 1
1 2
1 2
1 3
2 4
2 1
1 6
1 7
2 6
1 4
2 6
2 1
1 6
1 7
1 9
2 7
2 4
1 10
1 13
1 12
1 12
1 9
1 16
1 17
1 19
1 19
1 21
2 2
2 1
1 16
2 10
2 7
1 23
1 22
1 23
1 25
1 20
2 2
1 24
1 28
2 4
1 27
2 1
1 29
2 4
1 25
2 3
1 33
1 34
2 4
1 34
1 32
1 31
2 10
2 3
2 19
2 1
1 33
2 6
2 3
1 39
1 38
1 38
2 1
2...

output:

21656009746666
25268160422762
25744035927314

result:

ok 3 lines

Test #117:

score: 0
Accepted
time: 175ms
memory: 43552kb

input:

200000
2 1
1 1
1 2
2 3
1 3
1 3
2 2
2 3
1 5
2 1
1 4
1 5
1 8
2 3
1 8
2 2
1 9
1 7
2 2
1 11
1 13
1 12
2 4
2 2
2 2
2 2
1 13
1 16
2 2
1 16
1 15
1 17
2 1
2 6
1 15
2 16
1 20
1 21
1 23
2 1
1 21
1 19
1 25
1 25
1 27
2 3
1 22
1 30
1 30
1 31
1 32
1 34
1 28
2 4
2 1
1 34
1 20
1 38
1 36
1 38
1 31
1 40
1 42
1 40
1 4...

output:

23213148977150
25367178543244
26055403134620

result:

ok 3 lines

Test #118:

score: 0
Accepted
time: 146ms
memory: 40144kb

input:

370000
1 1
2 2
2 1
2 2
2 1
1 2
2 2
1 1
1 4
2 3
2 2
2 3
2 2
2 2
2 1
2 2
1 3
1 4
2 2
2 5
2 1
2 7
2 2
2 4
2 1
2 6
2 1
2 2
2 4
2 3
2 1
1 6
2 2
2 2
2 2
1 7
2 2
1 7
2 2
2 6
2 7
2 4
2 2
2 2
2 7
2 3
2 2
1 8
2 3
1 11
1 8
2 3
1 12
1 11
2 1
2 5
1 15
1 16
1 17
1 13
2 7
2 5
2 7
2 4
2 1
1 15
1 20
2 3
2 2
1 14
2 8...

output:

111952754781846
131463422858176
135653613656541

result:

ok 3 lines

Test #119:

score: 0
Accepted
time: 237ms
memory: 49572kb

input:

410000
2 1
2 1
1 1
2 2
2 2
1 2
1 2
2 2
2 2
1 3
2 4
2 2
1 4
1 5
1 6
2 1
1 8
1 9
2 2
1 10
1 3
2 5
2 2
1 11
2 1
1 8
1 14
1 15
2 3
1 14
1 17
1 9
1 11
2 1
1 17
1 15
2 4
1 21
2 3
2 11
1 21
2 6
1 20
2 1
2 9
1 22
1 26
1 27
2 1
2 2
1 28
2 4
1 27
2 1
2 4
2 8
2 1
1 30
1 30
1 32
2 4
1 32
2 3
2 7
1 33
2 8
1 31
1...

output:

88274311580206
101132097226452
105086878401260

result:

ok 3 lines

Test #120:

score: 0
Accepted
time: 200ms
memory: 44484kb

input:

550000
2 1
2 1
1 1
2 1
2 2
2 2
1 2
2 3
2 3
2 3
2 1
1 2
2 2
1 1
2 2
2 1
1 3
2 2
2 2
2 1
2 2
2 5
2 2
2 2
1 4
1 5
1 7
2 1
1 3
2 3
2 2
1 10
2 4
1 7
1 12
2 1
2 6
2 4
2 8
1 12
2 1
1 14
2 2
2 1
1 9
2 2
2 6
1 16
1 10
1 18
2 1
1 19
2 2
2 3
2 5
2 1
1 19
1 21
2 5
1 20
2 6
1 18
2 9
2 8
2 1
2 3
1 23
1 25
2 1
2 2...

output:

161661913357544
202368530694518
207144218365022

result:

ok 3 lines

Test #121:

score: 0
Accepted
time: 206ms
memory: 45432kb

input:

360000
2 1
2 1
2 1
2 1
2 1
1 1
2 1
2 1
2 1
1 1
2 3
2 1
1 2
2 4
2 3
1 3
1 5
1 6
1 5
1 2
2 4
1 7
2 2
2 5
1 9
1 3
2 4
2 1
2 1
1 4
1 13
1 12
2 6
1 10
2 1
1 15
2 2
1 17
1 14
1 18
1 19
1 15
2 6
1 22
2 3
2 1
2 3
2 1
1 17
1 16
1 24
1 26
1 27
2 12
2 6
1 24
2 6
2 9
2 1
2 3
2 14
2 3
2 13
2 2
1 22
2 7
2 4
2 1
2...

output:

84886227141042
101183173507148
105730653305369

result:

ok 3 lines

Test #122:

score: 0
Accepted
time: 185ms
memory: 44448kb

input:

450000
2 1
2 1
2 1
2 1
2 1
2 1
2 1
1 1
2 1
2 2
2 2
1 2
1 1
1 4
2 1
2 4
2 5
2 5
1 2
2 1
2 1
1 3
2 2
2 4
2 1
1 7
2 2
1 6
2 8
2 2
1 9
2 6
1 6
2 6
1 8
1 12
2 2
2 1
2 5
1 9
2 12
1 14
1 15
2 3
2 1
2 2
1 16
2 1
2 9
2 5
1 17
1 14
1 19
2 3
1 15
2 1
1 20
1 19
2 3
2 8
2 7
2 1
2 9
1 23
2 1
1 24
1 22
2 7
2 9
2 4...

output:

101769364802942
151719632819002
157050038243212

result:

ok 3 lines

Test #123:

score: 0
Accepted
time: 279ms
memory: 52696kb

input:

480000
1 1
2 1
1 2
1 2
1 1
1 5
1 6
2 1
2 4
1 7
2 1
2 3
1 6
1 9
1 7
1 11
1 12
2 4
1 11
2 2
1 12
1 14
2 1
1 16
1 17
2 7
1 15
1 16
2 1
2 2
2 1
2 9
2 4
2 10
2 1
2 1
1 19
1 21
1 22
2 6
1 19
2 1
2 3
2 5
1 23
1 25
1 22
1 26
1 26
2 7
1 29
2 3
2 2
1 24
1 27
1 23
2 1
1 33
2 5
1 34
1 33
2 2
1 36
1 25
1 34
1 38...

output:

97009825440726
126332341758490
131180186840641

result:

ok 3 lines

Test #124:

score: 0
Accepted
time: 128ms
memory: 39288kb

input:

220000
2 1
2 1
1 1
1 1
1 2
2 4
2 3
1 2
2 2
2 1
1 5
2 2
2 4
1 5
1 7
2 5
2 5
2 2
1 7
2 4
1 3
2 1
2 1
2 1
2 2
1 8
1 10
1 6
1 10
1 11
1 13
1 13
2 7
1 11
1 14
2 4
2 1
1 18
1 18
1 21
2 1
1 22
2 1
2 2
1 20
1 16
2 4
1 25
2 1
1 26
1 21
2 1
1 24
2 4
1 25
1 23
2 2
2 1
1 27
1 30
1 32
2 1
2 1
2 1
2 5
2 3
2 1
2 1...

output:

48398808279498
55776602966614
57129151897680

result:

ok 3 lines

Test #125:

score: 0
Accepted
time: 196ms
memory: 45544kb

input:

360000
2 1
2 1
1 1
2 2
1 1
1 3
2 3
1 4
1 4
1 5
1 7
2 3
2 8
2 5
2 1
1 7
2 1
2 5
2 1
1 9
2 5
1 8
2 1
2 2
1 8
2 1
1 12
1 12
1 14
2 6
2 3
1 15
2 3
2 2
1 15
1 10
2 1
2 6
1 14
2 6
1 19
2 9
2 5
1 18
1 21
2 3
2 4
2 3
2 1
2 5
1 13
1 23
1 24
2 1
1 21
1 26
1 18
2 5
1 26
1 23
2 3
1 25
1 25
1 29
1 28
2 1
2 3
2 8...

output:

83984777491434
101002143862162
107652134193034

result:

ok 3 lines

Test #126:

score: 0
Accepted
time: 371ms
memory: 78080kb

input:

1000000
2 1
1 1
2 2
1 1
1 2
1 2
1 3
1 3
2 5
2 1
2 2
1 4
2 3
2 2
2 4
2 6
1 4
2 1
1 5
2 2
1 5
1 6
1 6
2 6
1 7
1 7
2 10
2 9
1 8
1 8
2 1
1 9
2 9
2 3
1 9
1 10
1 10
2 3
2 5
1 11
1 11
2 1
2 10
1 12
1 12
2 7
1 13
1 13
2 1
1 14
1 14
1 15
2 17
2 3
2 1
1 15
1 16
2 8
2 4
1 16
1 17
2 2
2 10
1 17
2 2
1 18
2 6
2 5...

output:

232029820165550
252599887943204
254031602734437

result:

ok 3 lines

Test #127:

score: 0
Accepted
time: 417ms
memory: 78244kb

input:

990000
1 1
2 1
2 2
1 1
1 2
1 2
1 3
2 3
1 3
2 1
1 4
2 1
2 1
2 3
2 4
1 4
2 4
1 5
2 3
2 4
2 5
1 5
1 6
2 3
2 6
2 5
2 2
2 2
1 6
2 5
1 7
1 7
1 8
2 10
2 2
2 3
1 8
1 9
1 9
1 10
2 1
1 10
1 11
2 1
1 11
1 12
2 9
2 4
1 12
1 13
2 6
1 13
2 2
1 14
2 1
1 14
1 15
1 15
1 16
1 16
1 17
1 17
2 3
1 18
2 3
1 18
1 19
2 13
...

output:

225936593244440
252962041429676
252125432335985

result:

ok 3 lines

Subtask #5:

score: 0
Skipped

Dependency #2:

0%

Subtask #6:

score: 0
Skipped

Dependency #1:

0%