QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#201321#6545. Connect the Dotsucup-team1209#AC ✓83ms16044kbC++202.5kb2023-10-05 13:42:422023-10-05 13:42:42

Judging History

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

  • [2023-10-05 13:42:42]
  • 评测
  • 测评结果:AC
  • 用时:83ms
  • 内存:16044kb
  • [2023-10-05 13:42:42]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define drep(i,y,x) for (int i=(y);i>=(x);i--)
#define pii pair<int,int>
#define fir first
#define sec second
#define MP make_pair
template<typename T> bool chkmin(T &x,T y){return x>y?x=y,1:0;}
template<typename T> bool chkmax(T &x,T y){return x<y?x=y,1:0;}
void file() {
    #ifdef zqj
    freopen("a.in","r",stdin);
    #endif
}
typedef long long ll;
#define sz 202020

int n,MX;
int a[sz];
int b[sz],pos[sz],m;
int cnt[sz];

void work() {
    cin>>n>>MX; 
    rep(i,1,n) cin>>a[i];
    vector<pii>ans;
    if (a[1]==a[n]) {
        int k=n;
        while (k&&a[k]==a[n]) --k;
        if (!k) {
            cout<<"0\n";
            return;
        }
        rep(i,k+1,n) ans.push_back({k,i});
        n=k;
    }
    rep(i,1,n-1) if (a[i]!=a[i+1]) ans.push_back({i,i+1});
    m=0;
    for (int l=1,r;l<=n;l=r+1) {
        for (r=l;r!=n&&a[r+1]==a[r];r++);
        if (r!=n) {
            rep(i,l,r) ans.push_back({i,r+1});
            b[++m]=a[l],pos[m]=l;
        }
        else {
            rep(i,l,r) ans.push_back({pos[m],i});
            b[++m]=a[r],pos[m]=r;
        }
    }
    n=m;
    rep(i,1,n-1) ans.push_back({pos[i],pos[i+1]});
    rep(i,1,n) ++cnt[b[i]];
    int cc=0;
    rep(i,1,MX) cc+=!!cnt[i];
    if (cc>=3) {
        ans.push_back({pos[1],pos[n]});
        int L=1;
        rep(i,2,n-1) if (b[i]!=b[L]&&b[i]!=b[n]) {
            rep(j,L,i-1) --cnt[b[j]];
            if (cnt[b[L]]) {
                rep(j,L,i-1) ans.push_back({pos[j],pos[i]});
                ans.push_back({pos[i],pos[n]});
                L=i;
            }
            else {
                rep(j,i,n) ans.push_back({pos[L],pos[j]});
                rep(j,L+1,i-1) ans.push_back({pos[j],pos[i]});
                break;
            }
        }
    }
    else {
        for (int i=4;i<=n;i+=2) ans.push_back({pos[1],pos[i]});
    }
    sort(ans.begin(),ans.end()),ans.erase(unique(ans.begin(),ans.end()),ans.end());
    cout<<ans.size()<<'\n';
    for (auto [x,y]:ans) cout<<x<<' '<<y<<'\n';

    // {
         for (auto [x,y]:ans) assert(a[x]!=a[y]);
    //     for (auto [x,y]:ans) for (auto [l,r]:ans) if (l<x) assert(!(x<r&&r<y));
    // }


    rep(i,1,n) a[i]=b[i]=pos[i]=0;
    rep(i,0,MX) cnt[i]=0;
}

int main() {
    file();
    ios::sync_with_stdio(false),cin.tie(0);
    int T; cin>>T;
    while (T--) work();
    return 0;
}

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

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 5872kb

input:

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

output:

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

result:

ok all 3 test passed

Test #2:

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

input:

1
2 2
1 2

output:

1
1 2

result:

ok all 1 test passed

Test #3:

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

input:

10
5 2
2 2 2 1 2
5 2
2 1 2 1 2
5 2
1 2 2 2 1
5 2
2 1 2 1 1
5 2
1 1 1 2 1
5 2
1 2 2 1 2
5 2
2 1 1 2 2
5 2
2 2 2 1 1
5 2
1 1 2 1 2
5 2
1 2 2 2 1

output:

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

result:

ok all 10 test passed

Test #4:

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

input:

10
7 2
1 2 1 1 1 2 1
7 2
1 1 2 1 2 1 2
7 2
2 2 1 1 2 1 1
7 2
1 1 1 2 2 1 1
7 2
1 2 2 1 2 2 1
7 2
2 1 2 2 2 2 1
7 2
1 2 1 2 2 2 2
7 2
2 2 1 2 1 2 1
7 2
2 1 1 2 1 2 2
7 2
2 2 1 2 1 1 2

output:

7
1 2
1 6
2 3
3 6
4 6
5 6
6 7
8
1 3
1 5
1 7
2 3
3 4
4 5
5 6
6 7
7
1 3
1 7
2 3
3 5
4 5
5 6
5 7
6
1 4
1 5
2 4
3 4
5 6
5 7
7
1 2
1 6
2 4
3 4
4 5
4 6
6 7
7
1 2
1 7
2 3
3 7
4 7
5 7
6 7
7
1 2
1 7
2 3
3 4
3 5
3 6
3 7
8
1 3
1 5
1 7
2 3
3 4
4 5
5 6
6 7
7
1 2
1 5
2 4
3 4
4 5
5 6
5 7
7
1 3
1 6
2 3
3 4
4 5
4 6
...

result:

ok all 10 test passed

Test #5:

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

input:

10
9 2
1 1 1 2 1 2 2 1 2
9 2
1 2 1 1 2 2 2 2 1
9 2
2 1 2 1 1 2 1 2 1
9 2
1 1 2 1 1 1 1 2 2
9 2
1 1 2 2 1 2 1 2 2
9 2
2 2 1 2 1 2 2 2 2
9 2
1 1 2 2 2 1 2 1 2
9 2
1 1 2 1 1 2 2 2 2
9 2
1 1 1 1 2 1 1 2 1
9 2
2 1 2 2 1 1 2 2 1

output:

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

result:

ok all 10 test passed

Test #6:

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

input:

1
5 2
1 1 2 2 1

output:

4
1 3
1 4
2 3
4 5

result:

ok all 1 test passed

Test #7:

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

input:

1
7 2
2 1 1 2 1 1 2

output:

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

result:

ok all 1 test passed

Test #8:

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

input:

1
9 2
2 1 1 2 1 1 1 2 2

output:

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

result:

ok all 1 test passed

Test #9:

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

input:

4
20 2
2 1 1 2 1 2 1 1 2 1 1 1 1 2 2 2 1 1 2 2
20 2
2 1 2 2 2 1 1 2 2 2 1 2 2 2 2 1 2 2 1 2
20 2
2 2 1 1 2 2 1 1 1 1 1 2 1 1 2 2 1 2 1 1
20 2
2 1 2 2 2 1 2 2 1 1 1 2 1 2 2 1 2 1 1 2

output:

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

result:

ok all 4 test passed

Test #10:

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

input:

4
100 2
2 2 2 1 2 1 1 1 1 2 2 1 2 2 2 1 2 2 2 2 1 1 1 2 2 1 1 2 1 1 2 1 2 2 1 1 1 2 1 2 1 1 2 1 2 1 2 1 2 1 1 1 1 2 1 1 1 2 2 2 1 2 2 2 1 1 1 2 1 2 1 2 2 1 2 2 1 1 2 1 1 1 1 2 2 1 2 1 1 2 2 1 2 2 1 2 1 2 2 2
100 2
2 1 1 1 1 1 2 2 2 1 2 1 2 2 1 2 2 1 1 1 1 2 1 1 1 2 2 1 1 2 1 1 2 1 1 2 1 1 1 1 1 2 1 ...

output:

126
1 4
1 6
1 12
1 16
1 21
1 26
1 29
1 32
1 35
1 39
1 41
1 44
1 46
1 48
1 50
1 55
1 61
1 65
1 69
1 71
1 74
1 77
1 80
1 86
1 88
1 92
1 95
1 97
2 4
3 4
4 5
5 6
6 10
7 10
8 10
9 10
10 12
11 12
12 13
13 16
14 16
15 16
16 17
17 21
18 21
19 21
20 21
21 24
22 24
23 24
24 26
25 26
26 28
27 28
28 29
29 31
30...

result:

ok all 4 test passed

Test #11:

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

input:

1
100 2
2 2 1 1 2 2 2 1 1 2 1 1 1 2 2 1 2 2 2 1 1 2 2 1 1 2 2 2 1 2 1 1 2 1 1 2 2 1 2 1 1 2 1 2 2 1 2 2 2 2 1 2 1 2 1 1 2 1 1 1 1 1 2 2 2 1 1 2 1 2 2 2 2 1 1 2 2 2 1 1 2 2 2 1 2 2 1 2 1 2 1 2 2 2 1 2 2 2 1 1

output:

125
1 3
1 8
1 11
1 16
1 20
1 24
1 29
1 31
1 34
1 38
1 40
1 43
1 46
1 51
1 53
1 55
1 58
1 66
1 69
1 74
1 79
1 84
1 87
1 89
1 91
1 95
1 100
2 3
3 5
4 5
5 8
6 8
7 8
8 10
9 10
10 11
11 14
12 14
13 14
14 16
15 16
16 17
17 20
18 20
19 20
20 22
21 22
22 24
23 24
24 26
25 26
26 29
27 29
28 29
29 30
30 31
31...

result:

ok all 1 test passed

Test #12:

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

input:

1
100 2
1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1

output:

123
1 2
1 6
1 10
1 14
1 18
1 22
1 26
1 30
1 34
1 38
1 42
1 46
1 50
1 54
1 58
1 62
1 66
1 70
1 74
1 78
1 82
1 86
1 90
1 94
1 99
2 4
3 4
4 6
5 6
6 8
7 8
8 10
9 10
10 12
11 12
12 14
13 14
14 16
15 16
16 18
17 18
18 20
19 20
20 22
21 22
22 24
23 24
24 26
25 26
26 28
27 28
28 30
29 30
30 32
31 32
32 34
3...

result:

ok all 1 test passed

Test #13:

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

input:

1
200 2
1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 ...

output:

208
1 4
1 24
1 44
1 64
1 84
1 104
1 124
1 144
1 164
1 193
2 4
3 4
4 14
5 14
6 14
7 14
8 14
9 14
10 14
11 14
12 14
13 14
14 24
15 24
16 24
17 24
18 24
19 24
20 24
21 24
22 24
23 24
24 34
25 34
26 34
27 34
28 34
29 34
30 34
31 34
32 34
33 34
34 44
35 44
36 44
37 44
38 44
39 44
40 44
41 44
42 44
43 44
...

result:

ok all 1 test passed

Test #14:

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

input:

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

output:

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

result:

ok all 4 test passed

Test #15:

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

input:

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

output:

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

result:

ok all 4 test passed

Test #16:

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

input:

4
100 3
1 3 3 2 1 1 1 1 3 1 1 2 2 3 2 3 3 1 1 1 1 1 3 2 2 3 2 1 3 3 3 1 1 2 3 1 2 1 2 3 2 1 2 2 2 3 2 3 3 2 3 1 1 2 3 1 3 1 3 3 2 1 1 3 3 1 2 2 2 2 3 1 2 3 3 3 3 2 3 1 3 1 2 1 1 3 2 1 2 1 1 1 1 1 1 3 2 1 3 1
100 3
2 1 3 3 1 3 3 3 1 2 1 1 2 3 1 1 1 2 3 2 3 3 3 2 2 1 2 2 2 1 1 1 1 2 3 3 2 3 1 3 1 3 3 ...

output:

162
1 2
1 4
1 99
2 4
3 4
4 5
4 99
5 9
5 12
5 99
6 9
7 9
8 9
9 10
9 12
10 12
11 12
12 14
12 18
12 99
13 14
14 15
14 18
15 16
15 18
16 18
17 18
18 23
18 24
18 99
19 23
20 23
21 23
22 23
23 24
24 26
24 28
24 99
25 26
26 27
26 28
27 28
28 29
28 34
28 99
29 32
29 34
30 32
31 32
32 34
33 34
34 35
34 36
34...

result:

ok all 4 test passed

Test #17:

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

input:

1
200 3
1 3 3 3 2 3 3 3 1 3 3 3 1 3 1 1 2 2 2 3 2 2 3 3 2 2 2 1 3 1 3 1 3 3 1 1 1 2 2 1 2 1 3 3 3 3 3 1 2 1 1 1 3 3 3 1 1 2 2 1 1 3 2 3 2 1 3 3 1 1 3 1 2 1 2 2 2 1 3 2 2 1 3 1 2 3 2 2 1 2 1 3 3 3 2 1 1 3 3 2 2 3 2 3 3 1 2 3 1 2 2 3 2 2 1 2 2 1 2 3 1 2 2 3 1 2 3 1 2 1 1 3 1 3 1 3 2 1 3 2 1 2 2 1 3 2 ...

output:

331
1 2
1 5
1 200
2 5
3 5
4 5
5 6
5 9
5 200
6 9
7 9
8 9
9 10
9 17
9 200
10 13
10 17
11 13
12 13
13 14
13 17
14 15
14 17
15 17
16 17
17 20
17 28
17 200
18 20
19 20
20 21
20 28
21 23
21 28
22 23
23 25
23 28
24 25
25 28
26 28
27 28
28 29
28 38
28 200
29 30
29 38
30 31
30 38
31 32
31 38
32 33
32 38
33 3...

result:

ok all 1 test passed

Test #18:

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

input:

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

output:

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

result:

ok all 4 test passed

Test #19:

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

input:

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

output:

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

result:

ok all 4 test passed

Test #20:

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

input:

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

output:

197
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 61
1 62...

result:

ok all 4 test passed

Test #21:

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

input:

1
200 200
77 83 76 63 45 147 185 154 69 89 78 59 118 39 161 48 165 99 120 68 74 159 162 43 168 30 82 199 101 103 33 61 31 34 180 88 149 3 71 114 166 64 145 23 15 54 97 111 75 72 38 112 129 122 107 148 79 25 2 13 109 10 60 173 20 44 117 94 175 26 121 93 153 151 172 108 194 73 140 135 57 18 164 171 13...

output:

397
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 61
1 62...

result:

ok all 1 test passed

Test #22:

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

input:

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

output:

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

result:

ok all 4 test passed

Test #23:

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

input:

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

output:

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

result:

ok all 4 test passed

Test #24:

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

input:

1
300 2
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

299
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 61
1 62
1 63
1 64
1 65
1 66
1 67
1 68
1 69
1 70
1 71
1 72
1 73
1 74
1 75
1 76
1 77
1 78
1 79
1 80
1 81
1 82
1 83
1 84
1 85
1 86
1 87
1 88
1 89
1 90
1 91
1 92
1 93
1 94
1...

result:

ok all 1 test passed

Test #25:

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

input:

1
100 3
1 2 2 3 3 1 2 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 1 2 3 3 1 1 2 2 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1

output:

147
1 2
1 99
2 4
2 6
2 99
3 4
4 6
5 6
6 7
6 99
7 10
7 12
7 99
8 10
9 10
10 12
11 12
12 14
12 99
13 14
14 16
14 18
14 99
15 16
16 18
17 18
18 20
18 99
19 20
20 22
20 24
20 99
21 22
22 24
23 24
24 26
24 99
25 26
26 28
26 30
26 99
27 28
28 30
29 30
30 32
30 99
31 32
32 34
32 36
32 99
33 34
34 36
35 36
...

result:

ok all 1 test passed

Test #26:

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

input:

1
100 3
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3

output:

100
1 31
1 97
2 31
3 31
4 31
5 31
6 31
7 31
8 31
9 31
10 31
11 31
12 31
13 31
14 31
15 31
16 31
17 31
18 31
19 31
20 31
21 31
22 31
23 31
24 31
25 31
26 31
27 31
28 31
29 31
30 31
31 65
31 66
31 67
31 68
31 69
31 70
31 71
31 72
31 73
31 74
31 75
31 76
31 77
31 78
31 79
31 80
31 81
31 82
31 83
31 84
...

result:

ok all 1 test passed

Test #27:

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

input:

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

output:

107
1 9
1 19
1 29
1 39
1 49
1 59
1 69
1 79
1 98
2 9
3 9
4 9
5 9
6 9
7 9
8 9
9 19
10 19
11 19
12 19
13 19
14 19
15 19
16 19
17 19
18 19
19 29
20 29
21 29
22 29
23 29
24 29
25 29
26 29
27 29
28 29
29 39
30 39
31 39
32 39
33 39
34 39
35 39
36 39
37 39
38 39
39 49
40 49
41 49
42 49
43 49
44 49
45 49
46 ...

result:

ok all 1 test passed

Test #28:

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

input:

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

output:

449
1 3
1 300
2 3
3 5
3 300
4 5
5 7
5 300
6 7
7 9
7 300
8 9
9 11
9 300
10 11
11 13
11 300
12 13
13 15
13 300
14 15
15 17
15 300
16 17
17 19
17 21
17 300
18 19
19 21
20 21
21 23
21 300
22 23
23 25
23 300
24 25
25 27
25 300
26 27
27 29
27 300
28 29
29 30
29 300
30 31
30 300
31 33
31 300
32 33
33 35
33...

result:

ok all 1 test passed

Test #29:

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

input:

1
1000 2
2 1 1 2 2 1 1 1 1 2 2 2 2 1 1 1 1 2 1 1 2 2 1 1 1 2 1 1 1 2 1 2 2 2 1 1 1 2 2 1 2 1 2 1 2 2 2 1 1 2 1 2 1 2 1 1 2 1 2 1 2 2 1 2 2 2 2 2 1 2 2 1 2 2 2 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 1 2 2 2 1 2 1 2 1 1 2 1 1 2 2 2 1 1 1 2 1 1 2 1 1 2 2 2 2 2 2 1 1 1 2 2 1 2 2 1 1 2 2 1 1 1 2 2 1 2 2 2 2 1 2 1...

output:

1251
1 2
1 6
1 14
1 19
1 23
1 27
1 31
1 35
1 40
1 42
1 44
1 48
1 51
1 53
1 55
1 58
1 60
1 63
1 69
1 72
1 76
1 84
1 91
1 95
1 97
1 99
1 102
1 107
1 111
1 114
1 122
1 127
1 130
1 134
1 139
1 144
1 146
1 150
1 153
1 158
1 168
1 171
1 176
1 179
1 181
1 187
1 192
1 195
1 199
1 202
1 205
1 208
1 211
1 213...

result:

ok all 1 test passed

Test #30:

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

input:

1
3000 2
1 2 2 2 2 1 1 1 1 1 1 2 1 1 2 1 2 2 1 1 2 2 2 2 1 1 1 1 2 2 1 2 1 1 1 2 2 2 2 2 1 2 1 1 1 2 1 1 2 1 2 1 2 1 1 2 1 1 1 2 2 1 1 2 1 1 2 2 2 2 1 1 2 2 2 1 1 2 2 2 2 2 2 2 1 1 2 1 2 2 1 2 2 1 1 2 1 2 1 1 2 1 2 1 2 2 2 1 2 1 1 1 1 1 1 1 2 1 2 1 2 1 1 2 2 1 2 1 1 2 2 2 2 1 2 2 2 1 2 1 1 2 1 2 2 2...

output:

3766
1 2
1 12
1 15
1 17
1 21
1 29
1 32
1 36
1 42
1 46
1 49
1 51
1 53
1 56
1 60
1 64
1 67
1 73
1 78
1 87
1 89
1 92
1 96
1 98
1 101
1 103
1 105
1 109
1 117
1 119
1 121
1 124
1 127
1 130
1 135
1 139
1 142
1 144
1 150
1 153
1 157
1 165
1 167
1 169
1 174
1 180
1 183
1 188
1 191
1 199
1 203
1 210
1 212
1 ...

result:

ok all 1 test passed

Test #31:

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

input:

1
2000 2
2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2...

output:

2498
1 3
1 7
1 11
1 15
1 19
1 23
1 27
1 31
1 35
1 39
1 43
1 47
1 51
1 55
1 59
1 63
1 67
1 71
1 75
1 79
1 83
1 87
1 91
1 95
1 99
1 103
1 107
1 111
1 115
1 119
1 123
1 127
1 131
1 135
1 139
1 143
1 147
1 151
1 155
1 159
1 163
1 167
1 171
1 175
1 179
1 183
1 187
1 191
1 195
1 199
1 203
1 207
1 211
1 21...

result:

ok all 1 test passed

Test #32:

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

input:

1
1000 2
2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 2 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2...

output:

1050
1 11
1 31
1 51
1 54
1 71
1 91
1 111
1 131
1 151
1 171
1 191
1 211
1 231
1 251
1 271
1 291
1 311
1 331
1 351
1 371
1 391
1 411
1 431
1 451
1 471
1 491
1 511
1 531
1 551
1 571
1 591
1 611
1 631
1 651
1 671
1 691
1 711
1 731
1 751
1 765
1 771
1 791
1 811
1 831
1 851
1 871
1 891
1 911
1 931
1 951
1...

result:

ok all 1 test passed

Test #33:

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

input:

1
1000 2
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2...

output:

999
1 97
1 98
1 99
1 100
1 101
1 102
1 103
1 104
1 105
1 106
1 107
1 108
1 109
1 110
1 111
1 112
1 113
1 114
1 115
1 116
1 117
1 118
1 119
1 120
1 121
1 122
1 123
1 124
1 125
1 126
1 127
1 128
1 129
1 130
1 131
1 132
1 133
1 134
1 135
1 136
1 137
1 138
1 139
1 140
1 141
1 142
1 143
1 144
1 145
1 146...

result:

ok all 1 test passed

Test #34:

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

input:

1
22000 2
1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 ...

output:

27498
1 3
1 7
1 11
1 15
1 19
1 23
1 27
1 31
1 35
1 39
1 43
1 47
1 51
1 55
1 59
1 63
1 67
1 71
1 75
1 79
1 83
1 87
1 91
1 95
1 99
1 103
1 107
1 111
1 115
1 119
1 123
1 127
1 131
1 135
1 139
1 143
1 147
1 151
1 155
1 159
1 163
1 167
1 171
1 175
1 179
1 183
1 187
1 191
1 195
1 199
1 203
1 207
1 211
1 2...

result:

ok all 1 test passed

Test #35:

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

input:

1
12000 2
2 1 1 2 2 1 2 1 1 2 1 1 1 2 1 2 1 1 2 2 1 1 2 2 2 2 1 2 1 2 1 1 1 1 2 2 2 2 2 1 1 2 1 1 1 1 1 1 1 1 1 2 2 1 2 2 1 2 1 2 1 1 1 1 1 2 1 2 1 1 2 1 1 2 1 2 2 1 1 2 1 1 2 2 2 2 1 1 1 2 1 1 2 1 2 2 1 1 2 2 1 1 2 2 1 2 2 2 2 1 2 2 2 2 2 2 1 1 1 2 2 2 2 2 1 1 2 1 2 1 2 1 1 1 2 1 2 1 1 2 1 2 2 2 2 ...

output:

14969
1 2
1 6
1 8
1 11
1 15
1 17
1 21
1 27
1 29
1 31
1 40
1 43
1 54
1 57
1 59
1 61
1 67
1 69
1 72
1 75
1 78
1 81
1 87
1 91
1 94
1 97
1 101
1 105
1 110
1 117
1 125
1 128
1 130
1 132
1 136
1 138
1 141
1 146
1 154
1 157
1 159
1 164
1 166
1 172
1 174
1 177
1 181
1 184
1 187
1 195
1 198
1 204
1 206
1 210...

result:

ok all 1 test passed

Test #36:

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

input:

1
300 150
21 91 61 3 124 47 39 37 35 86 28 74 50 79 125 146 38 32 60 111 114 29 103 121 126 55 61 47 149 9 149 124 92 29 78 104 54 34 54 27 1 59 44 123 9 36 29 25 124 88 125 145 113 137 119 108 27 132 124 114 143 143 77 97 84 83 40 132 77 62 72 37 51 139 56 80 34 87 69 131 100 57 120 148 42 42 123 2...

output:

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

result:

ok all 1 test passed

Test #37:

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

input:

1
1000 3
3 2 3 3 2 1 2 1 2 1 2 3 1 1 2 3 1 3 3 2 1 3 1 1 3 3 1 2 1 2 1 1 3 2 2 1 2 3 2 2 3 1 2 2 1 1 2 2 1 2 1 1 3 1 1 3 3 2 1 2 3 2 1 3 3 2 2 2 3 2 3 3 1 2 1 1 2 1 2 3 1 2 1 3 1 3 3 1 2 1 1 2 2 1 1 2 2 2 1 1 3 1 1 1 3 2 2 1 1 3 2 3 1 2 3 3 3 2 3 3 1 2 3 3 2 2 2 2 2 1 2 3 3 3 2 2 3 3 1 1 2 3 1 1 1 2...

output:

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

result:

ok all 1 test passed

Test #38:

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

input:

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

output:

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

result:

ok all 1 test passed

Test #39:

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

input:

1
30000 3
3 3 1 1 3 2 2 2 3 2 2 2 3 3 3 2 3 1 2 2 1 1 3 1 1 3 3 1 2 2 3 1 1 3 3 3 3 1 2 2 2 3 3 2 1 3 1 2 1 1 2 2 2 2 1 3 1 2 1 1 2 2 3 2 1 2 2 2 1 2 3 2 2 2 1 3 1 3 3 3 2 2 3 1 3 2 3 2 2 3 3 2 2 1 2 3 1 1 2 1 3 2 3 2 3 3 3 2 3 2 1 3 2 3 1 3 3 3 2 3 2 1 2 1 3 2 2 1 1 1 1 2 1 3 2 2 1 1 2 1 3 1 1 2 1 ...

output:

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

result:

ok all 1 test passed

Test #40:

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

input:

1
15000 3
1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 ...

output:

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

result:

ok all 1 test passed

Test #41:

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

input:

1
13998 3
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

13998
1 1264
1 10595
2 1264
3 1264
4 1264
5 1264
6 1264
7 1264
8 1264
9 1264
10 1264
11 1264
12 1264
13 1264
14 1264
15 1264
16 1264
17 1264
18 1264
19 1264
20 1264
21 1264
22 1264
23 1264
24 1264
25 1264
26 1264
27 1264
28 1264
29 1264
30 1264
31 1264
32 1264
33 1264
34 1264
35 1264
36 1264
37 1264...

result:

ok all 1 test passed

Test #42:

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

input:

1
10000 5000
1401 1401 1402 1402 1403 1403 1404 1404 1405 1405 1406 1406 1407 1407 1408 1408 1409 1409 1410 1410 1411 1411 1412 1412 1413 1413 1414 1414 1415 1415 1416 1416 1417 1417 1418 1418 1419 1419 1420 1420 1421 1421 1422 1422 1423 1423 1424 1424 1425 1425 1426 1426 1427 1427 1428 1428 1429 14...

output:

14997
1 3
1 5
1 7
1 9
1 11
1 13
1 15
1 17
1 19
1 21
1 23
1 25
1 27
1 29
1 31
1 33
1 35
1 37
1 39
1 41
1 43
1 45
1 47
1 49
1 51
1 53
1 55
1 57
1 59
1 61
1 63
1 65
1 67
1 69
1 71
1 73
1 75
1 77
1 79
1 81
1 83
1 85
1 87
1 89
1 91
1 93
1 95
1 97
1 99
1 101
1 103
1 105
1 107
1 109
1 111
1 113
1 115
1 117...

result:

ok all 1 test passed

Test #43:

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

input:

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

output:

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

result:

ok all 3 test passed

Test #44:

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

input:

1
2 2
1 2

output:

1
1 2

result:

ok all 1 test passed

Test #45:

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

input:

10
5 2
2 2 2 1 2
5 2
2 1 2 1 2
5 2
1 2 2 2 1
5 2
2 1 2 1 1
5 2
1 1 1 2 1
5 2
1 2 2 1 2
5 2
2 1 1 2 2
5 2
2 2 2 1 1
5 2
1 1 2 1 2
5 2
1 2 2 2 1

output:

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

result:

ok all 10 test passed

Test #46:

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

input:

10
7 2
1 2 1 1 1 2 1
7 2
1 1 2 1 2 1 2
7 2
2 2 1 1 2 1 1
7 2
1 1 1 2 2 1 1
7 2
1 2 2 1 2 2 1
7 2
2 1 2 2 2 2 1
7 2
1 2 1 2 2 2 2
7 2
2 2 1 2 1 2 1
7 2
2 1 1 2 1 2 2
7 2
2 2 1 2 1 1 2

output:

7
1 2
1 6
2 3
3 6
4 6
5 6
6 7
8
1 3
1 5
1 7
2 3
3 4
4 5
5 6
6 7
7
1 3
1 7
2 3
3 5
4 5
5 6
5 7
6
1 4
1 5
2 4
3 4
5 6
5 7
7
1 2
1 6
2 4
3 4
4 5
4 6
6 7
7
1 2
1 7
2 3
3 7
4 7
5 7
6 7
7
1 2
1 7
2 3
3 4
3 5
3 6
3 7
8
1 3
1 5
1 7
2 3
3 4
4 5
5 6
6 7
7
1 2
1 5
2 4
3 4
4 5
5 6
5 7
7
1 3
1 6
2 3
3 4
4 5
4 6
...

result:

ok all 10 test passed

Test #47:

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

input:

10
9 2
1 1 1 2 1 2 2 1 2
9 2
1 2 1 1 2 2 2 2 1
9 2
2 1 2 1 1 2 1 2 1
9 2
1 1 2 1 1 1 1 2 2
9 2
1 1 2 2 1 2 1 2 2
9 2
2 2 1 2 1 2 2 2 2
9 2
1 1 2 2 2 1 2 1 2
9 2
1 1 2 1 1 2 2 2 2
9 2
1 1 1 1 2 1 1 2 1
9 2
2 1 2 2 1 1 2 2 1

output:

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

result:

ok all 10 test passed

Test #48:

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

input:

1
5 2
1 1 2 2 1

output:

4
1 3
1 4
2 3
4 5

result:

ok all 1 test passed

Test #49:

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

input:

1
7 2
2 1 1 2 1 1 2

output:

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

result:

ok all 1 test passed

Test #50:

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

input:

1
9 2
2 1 1 2 1 1 1 2 2

output:

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

result:

ok all 1 test passed

Test #51:

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

input:

4
20 2
2 1 1 2 1 2 1 1 2 1 1 1 1 2 2 2 1 1 2 2
20 2
2 1 2 2 2 1 1 2 2 2 1 2 2 2 2 1 2 2 1 2
20 2
2 2 1 1 2 2 1 1 1 1 1 2 1 1 2 2 1 2 1 1
20 2
2 1 2 2 2 1 2 2 1 1 1 2 1 2 2 1 2 1 1 2

output:

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

result:

ok all 4 test passed

Test #52:

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

input:

4
100 2
2 2 2 1 2 1 1 1 1 2 2 1 2 2 2 1 2 2 2 2 1 1 1 2 2 1 1 2 1 1 2 1 2 2 1 1 1 2 1 2 1 1 2 1 2 1 2 1 2 1 1 1 1 2 1 1 1 2 2 2 1 2 2 2 1 1 1 2 1 2 1 2 2 1 2 2 1 1 2 1 1 1 1 2 2 1 2 1 1 2 2 1 2 2 1 2 1 2 2 2
100 2
2 1 1 1 1 1 2 2 2 1 2 1 2 2 1 2 2 1 1 1 1 2 1 1 1 2 2 1 1 2 1 1 2 1 1 2 1 1 1 1 1 2 1 ...

output:

126
1 4
1 6
1 12
1 16
1 21
1 26
1 29
1 32
1 35
1 39
1 41
1 44
1 46
1 48
1 50
1 55
1 61
1 65
1 69
1 71
1 74
1 77
1 80
1 86
1 88
1 92
1 95
1 97
2 4
3 4
4 5
5 6
6 10
7 10
8 10
9 10
10 12
11 12
12 13
13 16
14 16
15 16
16 17
17 21
18 21
19 21
20 21
21 24
22 24
23 24
24 26
25 26
26 28
27 28
28 29
29 31
30...

result:

ok all 4 test passed

Test #53:

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

input:

1
300 2
2 2 1 1 1 2 2 2 2 2 2 2 2 1 2 2 2 2 1 1 1 1 1 2 1 1 1 1 2 1 2 1 1 1 1 1 2 2 2 1 2 2 2 2 1 2 2 2 1 2 2 2 1 1 1 1 1 1 1 2 2 2 1 2 2 1 2 2 1 2 2 1 2 1 2 2 2 1 2 2 2 2 2 1 1 2 1 1 2 2 1 2 2 2 1 1 2 1 1 2 2 2 2 1 2 2 2 2 2 2 1 2 1 2 2 1 2 1 2 1 1 1 1 2 1 2 1 1 1 1 2 2 2 2 1 2 2 1 2 1 2 1 1 2 2 1 ...

output:

367
1 3
1 14
1 19
1 25
1 30
1 32
1 40
1 45
1 49
1 53
1 63
1 66
1 69
1 72
1 74
1 78
1 84
1 87
1 91
1 95
1 98
1 104
1 111
1 113
1 116
1 118
1 120
1 125
1 127
1 135
1 138
1 140
1 142
1 146
1 148
1 153
1 155
1 157
1 163
1 166
1 177
1 179
1 183
1 186
1 188
1 192
1 197
1 207
1 213
1 216
1 219
1 223
1 226
...

result:

ok all 1 test passed

Test #54:

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

input:

1
300 2
1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 ...

output:

373
1 3
1 7
1 11
1 15
1 19
1 23
1 27
1 31
1 35
1 39
1 43
1 47
1 51
1 55
1 59
1 63
1 67
1 71
1 75
1 79
1 83
1 87
1 91
1 95
1 99
1 103
1 107
1 111
1 115
1 119
1 123
1 127
1 131
1 135
1 139
1 143
1 147
1 151
1 155
1 159
1 163
1 167
1 171
1 175
1 179
1 183
1 187
1 191
1 195
1 199
1 203
1 207
1 211
1 215...

result:

ok all 1 test passed

Test #55:

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

input:

1
300 2
2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 ...

output:

313
1 5
1 25
1 45
1 65
1 85
1 105
1 125
1 145
1 165
1 185
1 205
1 225
1 245
1 265
1 294
2 5
3 5
4 5
5 15
6 15
7 15
8 15
9 15
10 15
11 15
12 15
13 15
14 15
15 25
16 25
17 25
18 25
19 25
20 25
21 25
22 25
23 25
24 25
25 35
26 35
27 35
28 35
29 35
30 35
31 35
32 35
33 35
34 35
35 45
36 45
37 45
38 45
3...

result:

ok all 1 test passed

Test #56:

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

input:

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

output:

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

result:

ok all 4 test passed

Test #57:

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

input:

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

output:

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

result:

ok all 4 test passed

Test #58:

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

input:

4
100 3
1 3 3 2 1 1 1 1 3 1 1 2 2 3 2 3 3 1 1 1 1 1 3 2 2 3 2 1 3 3 3 1 1 2 3 1 2 1 2 3 2 1 2 2 2 3 2 3 3 2 3 1 1 2 3 1 3 1 3 3 2 1 1 3 3 1 2 2 2 2 3 1 2 3 3 3 3 2 3 1 3 1 2 1 1 3 2 1 2 1 1 1 1 1 1 3 2 1 3 1
100 3
2 1 3 3 1 3 3 3 1 2 1 1 2 3 1 1 1 2 3 2 3 3 3 2 2 1 2 2 2 1 1 1 1 2 3 3 2 3 1 3 1 3 3 ...

output:

162
1 2
1 4
1 99
2 4
3 4
4 5
4 99
5 9
5 12
5 99
6 9
7 9
8 9
9 10
9 12
10 12
11 12
12 14
12 18
12 99
13 14
14 15
14 18
15 16
15 18
16 18
17 18
18 23
18 24
18 99
19 23
20 23
21 23
22 23
23 24
24 26
24 28
24 99
25 26
26 27
26 28
27 28
28 29
28 34
28 99
29 32
29 34
30 32
31 32
32 34
33 34
34 35
34 36
34...

result:

ok all 4 test passed

Test #59:

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

input:

1
300 3
2 1 2 1 2 2 1 2 3 1 1 2 3 3 3 2 3 1 1 2 1 1 1 3 3 3 2 1 1 2 2 1 1 3 2 3 1 3 2 2 2 3 1 3 2 1 3 1 1 3 1 2 1 2 1 3 2 1 3 3 1 2 1 2 2 1 1 3 2 1 2 3 1 2 2 2 1 3 3 1 2 3 1 3 1 1 3 1 3 1 2 1 1 3 1 3 3 2 2 2 1 2 1 2 2 3 2 1 3 3 1 2 1 3 2 3 1 2 1 1 2 2 1 1 2 3 1 1 3 2 3 3 1 1 1 3 2 1 1 2 1 3 3 2 3 1 ...

output:

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

result:

ok all 1 test passed

Test #60:

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

input:

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

output:

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

result:

ok all 4 test passed

Test #61:

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

input:

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

output:

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

result:

ok all 4 test passed

Test #62:

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

input:

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

output:

197
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 61
1 62...

result:

ok all 4 test passed

Test #63:

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

input:

1
300 300
77 46 15 213 13 258 21 73 122 114 55 238 294 179 97 175 25 104 83 153 80 36 135 216 252 100 50 169 5 211 253 146 223 82 76 44 90 288 261 174 14 222 127 298 203 151 286 178 68 28 85 75 42 167 112 226 106 123 220 230 242 160 132 2 161 232 229 291 22 170 158 57 193 263 266 71 184 289 195 136 ...

output:

597
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 61
1 62...

result:

ok all 1 test passed

Test #64:

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

input:

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

output:

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

result:

ok all 4 test passed

Test #65:

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

input:

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

output:

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

result:

ok all 4 test passed

Test #66:

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

input:

1
300 2
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

299
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 61
1 62
1 63
1 64
1 65
1 66
1 67
1 68
1 69
1 70
1 71
1 72
1 73
1 74
1 75
1 76
1 77
1 78
1 79
1 80
1 81
1 82
1 83
1 84
1 85
1 86
1 87
1 88
1 89
1 90
1 91
1 92
1 93
1 94
1...

result:

ok all 1 test passed

Test #67:

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

input:

1
300 3
2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 ...

output:

447
1 3
1 300
2 3
3 5
3 7
3 300
4 5
5 7
6 7
7 9
7 300
8 9
9 11
9 13
9 300
10 11
11 13
12 13
13 15
13 300
14 15
15 17
15 19
15 300
16 17
17 19
18 19
19 21
19 300
20 21
21 23
21 25
21 300
22 23
23 25
24 25
25 27
25 300
26 27
27 29
27 31
27 300
28 29
29 31
30 31
31 33
31 300
32 33
33 35
33 37
33 300
34...

result:

ok all 1 test passed

Test #68:

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

input:

1
300 3
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

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

result:

ok all 1 test passed

Test #69:

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

input:

1
300 10
9 9 9 9 5 9 9 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 7 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4...

output:

315
1 5
1 277
2 5
3 5
4 5
5 6
5 277
6 8
6 277
7 8
8 38
8 68
8 74
8 75
8 98
8 128
8 158
8 186
8 187
8 188
8 218
8 240
8 241
8 277
9 38
10 38
11 38
12 38
13 38
14 38
15 38
16 38
17 38
18 38
19 38
20 38
21 38
22 38
23 38
24 38
25 38
26 38
27 38
28 38
29 38
30 38
31 38
32 38
33 38
34 38
35 38
36 38
37 3...

result:

ok all 1 test passed

Test #70:

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

input:

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

output:

449
1 3
1 300
2 3
3 5
3 300
4 5
5 7
5 300
6 7
7 9
7 300
8 9
9 11
9 300
10 11
11 13
11 300
12 13
13 15
13 300
14 15
15 17
15 300
16 17
17 19
17 21
17 300
18 19
19 21
20 21
21 23
21 300
22 23
23 25
23 300
24 25
25 27
25 300
26 27
27 29
27 300
28 29
29 30
29 300
30 31
30 300
31 33
31 300
32 33
33 35
33...

result:

ok all 1 test passed

Test #71:

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

input:

1
1000 2
2 1 1 2 2 1 1 1 1 2 2 2 2 1 1 1 1 2 1 1 2 2 1 1 1 2 1 1 1 2 1 2 2 2 1 1 1 2 2 1 2 1 2 1 2 2 2 1 1 2 1 2 1 2 1 1 2 1 2 1 2 2 1 2 2 2 2 2 1 2 2 1 2 2 2 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 1 2 2 2 1 2 1 2 1 1 2 1 1 2 2 2 1 1 1 2 1 1 2 1 1 2 2 2 2 2 2 1 1 1 2 2 1 2 2 1 1 2 2 1 1 1 2 2 1 2 2 2 2 1 2 1...

output:

1251
1 2
1 6
1 14
1 19
1 23
1 27
1 31
1 35
1 40
1 42
1 44
1 48
1 51
1 53
1 55
1 58
1 60
1 63
1 69
1 72
1 76
1 84
1 91
1 95
1 97
1 99
1 102
1 107
1 111
1 114
1 122
1 127
1 130
1 134
1 139
1 144
1 146
1 150
1 153
1 158
1 168
1 171
1 176
1 179
1 181
1 187
1 192
1 195
1 199
1 202
1 205
1 208
1 211
1 213...

result:

ok all 1 test passed

Test #72:

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

input:

1
3000 2
1 2 2 2 2 1 1 1 1 1 1 2 1 1 2 1 2 2 1 1 2 2 2 2 1 1 1 1 2 2 1 2 1 1 1 2 2 2 2 2 1 2 1 1 1 2 1 1 2 1 2 1 2 1 1 2 1 1 1 2 2 1 1 2 1 1 2 2 2 2 1 1 2 2 2 1 1 2 2 2 2 2 2 2 1 1 2 1 2 2 1 2 2 1 1 2 1 2 1 1 2 1 2 1 2 2 2 1 2 1 1 1 1 1 1 1 2 1 2 1 2 1 1 2 2 1 2 1 1 2 2 2 2 1 2 2 2 1 2 1 1 2 1 2 2 2...

output:

3766
1 2
1 12
1 15
1 17
1 21
1 29
1 32
1 36
1 42
1 46
1 49
1 51
1 53
1 56
1 60
1 64
1 67
1 73
1 78
1 87
1 89
1 92
1 96
1 98
1 101
1 103
1 105
1 109
1 117
1 119
1 121
1 124
1 127
1 130
1 135
1 139
1 142
1 144
1 150
1 153
1 157
1 165
1 167
1 169
1 174
1 180
1 183
1 188
1 191
1 199
1 203
1 210
1 212
1 ...

result:

ok all 1 test passed

Test #73:

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

input:

1
2000 2
2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2...

output:

2498
1 3
1 7
1 11
1 15
1 19
1 23
1 27
1 31
1 35
1 39
1 43
1 47
1 51
1 55
1 59
1 63
1 67
1 71
1 75
1 79
1 83
1 87
1 91
1 95
1 99
1 103
1 107
1 111
1 115
1 119
1 123
1 127
1 131
1 135
1 139
1 143
1 147
1 151
1 155
1 159
1 163
1 167
1 171
1 175
1 179
1 183
1 187
1 191
1 195
1 199
1 203
1 207
1 211
1 21...

result:

ok all 1 test passed

Test #74:

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

input:

1
1000 2
2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 2 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2...

output:

1050
1 11
1 31
1 51
1 54
1 71
1 91
1 111
1 131
1 151
1 171
1 191
1 211
1 231
1 251
1 271
1 291
1 311
1 331
1 351
1 371
1 391
1 411
1 431
1 451
1 471
1 491
1 511
1 531
1 551
1 571
1 591
1 611
1 631
1 651
1 671
1 691
1 711
1 731
1 751
1 765
1 771
1 791
1 811
1 831
1 851
1 871
1 891
1 911
1 931
1 951
1...

result:

ok all 1 test passed

Test #75:

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

input:

1
1000 2
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2...

output:

999
1 97
1 98
1 99
1 100
1 101
1 102
1 103
1 104
1 105
1 106
1 107
1 108
1 109
1 110
1 111
1 112
1 113
1 114
1 115
1 116
1 117
1 118
1 119
1 120
1 121
1 122
1 123
1 124
1 125
1 126
1 127
1 128
1 129
1 130
1 131
1 132
1 133
1 134
1 135
1 136
1 137
1 138
1 139
1 140
1 141
1 142
1 143
1 144
1 145
1 146...

result:

ok all 1 test passed

Test #76:

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

input:

1
22000 2
1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 ...

output:

27498
1 3
1 7
1 11
1 15
1 19
1 23
1 27
1 31
1 35
1 39
1 43
1 47
1 51
1 55
1 59
1 63
1 67
1 71
1 75
1 79
1 83
1 87
1 91
1 95
1 99
1 103
1 107
1 111
1 115
1 119
1 123
1 127
1 131
1 135
1 139
1 143
1 147
1 151
1 155
1 159
1 163
1 167
1 171
1 175
1 179
1 183
1 187
1 191
1 195
1 199
1 203
1 207
1 211
1 2...

result:

ok all 1 test passed

Test #77:

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

input:

1
12000 2
2 1 1 2 2 1 2 1 1 2 1 1 1 2 1 2 1 1 2 2 1 1 2 2 2 2 1 2 1 2 1 1 1 1 2 2 2 2 2 1 1 2 1 1 1 1 1 1 1 1 1 2 2 1 2 2 1 2 1 2 1 1 1 1 1 2 1 2 1 1 2 1 1 2 1 2 2 1 1 2 1 1 2 2 2 2 1 1 1 2 1 1 2 1 2 2 1 1 2 2 1 1 2 2 1 2 2 2 2 1 2 2 2 2 2 2 1 1 1 2 2 2 2 2 1 1 2 1 2 1 2 1 1 1 2 1 2 1 1 2 1 2 2 2 2 ...

output:

14969
1 2
1 6
1 8
1 11
1 15
1 17
1 21
1 27
1 29
1 31
1 40
1 43
1 54
1 57
1 59
1 61
1 67
1 69
1 72
1 75
1 78
1 81
1 87
1 91
1 94
1 97
1 101
1 105
1 110
1 117
1 125
1 128
1 130
1 132
1 136
1 138
1 141
1 146
1 154
1 157
1 159
1 164
1 166
1 172
1 174
1 177
1 181
1 184
1 187
1 195
1 198
1 204
1 206
1 210...

result:

ok all 1 test passed

Test #78:

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

input:

1
300 150
21 91 61 3 124 47 39 37 35 86 28 74 50 79 125 146 38 32 60 111 114 29 103 121 126 55 61 47 149 9 149 124 92 29 78 104 54 34 54 27 1 59 44 123 9 36 29 25 124 88 125 145 113 137 119 108 27 132 124 114 143 143 77 97 84 83 40 132 77 62 72 37 51 139 56 80 34 87 69 131 100 57 120 148 42 42 123 2...

output:

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

result:

ok all 1 test passed

Test #79:

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

input:

1
1000 3
3 2 3 3 2 1 2 1 2 1 2 3 1 1 2 3 1 3 3 2 1 3 1 1 3 3 1 2 1 2 1 1 3 2 2 1 2 3 2 2 3 1 2 2 1 1 2 2 1 2 1 1 3 1 1 3 3 2 1 2 3 2 1 3 3 2 2 2 3 2 3 3 1 2 1 1 2 1 2 3 1 2 1 3 1 3 3 1 2 1 1 2 2 1 1 2 2 2 1 1 3 1 1 1 3 2 2 1 1 3 2 3 1 2 3 3 3 2 3 3 1 2 3 3 2 2 2 2 2 1 2 3 3 3 2 2 3 3 1 1 2 3 1 1 1 2...

output:

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

result:

ok all 1 test passed

Test #80:

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

input:

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

output:

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

result:

ok all 1 test passed

Test #81:

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

input:

1
30000 3
3 3 1 1 3 2 2 2 3 2 2 2 3 3 3 2 3 1 2 2 1 1 3 1 1 3 3 1 2 2 3 1 1 3 3 3 3 1 2 2 2 3 3 2 1 3 1 2 1 1 2 2 2 2 1 3 1 2 1 1 2 2 3 2 1 2 2 2 1 2 3 2 2 2 1 3 1 3 3 3 2 2 3 1 3 2 3 2 2 3 3 2 2 1 2 3 1 1 2 1 3 2 3 2 3 3 3 2 3 2 1 3 2 3 1 3 3 3 2 3 2 1 2 1 3 2 2 1 1 1 1 2 1 3 2 2 1 1 2 1 3 1 1 2 1 ...

output:

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

result:

ok all 1 test passed

Test #82:

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

input:

1
15000 3
1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 ...

output:

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

result:

ok all 1 test passed

Test #83:

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

input:

1
13998 3
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

13998
1 1264
1 10595
2 1264
3 1264
4 1264
5 1264
6 1264
7 1264
8 1264
9 1264
10 1264
11 1264
12 1264
13 1264
14 1264
15 1264
16 1264
17 1264
18 1264
19 1264
20 1264
21 1264
22 1264
23 1264
24 1264
25 1264
26 1264
27 1264
28 1264
29 1264
30 1264
31 1264
32 1264
33 1264
34 1264
35 1264
36 1264
37 1264...

result:

ok all 1 test passed

Test #84:

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

input:

1
10000 5000
1401 1401 1402 1402 1403 1403 1404 1404 1405 1405 1406 1406 1407 1407 1408 1408 1409 1409 1410 1410 1411 1411 1412 1412 1413 1413 1414 1414 1415 1415 1416 1416 1417 1417 1418 1418 1419 1419 1420 1420 1421 1421 1422 1422 1423 1423 1424 1424 1425 1425 1426 1426 1427 1427 1428 1428 1429 14...

output:

14997
1 3
1 5
1 7
1 9
1 11
1 13
1 15
1 17
1 19
1 21
1 23
1 25
1 27
1 29
1 31
1 33
1 35
1 37
1 39
1 41
1 43
1 45
1 47
1 49
1 51
1 53
1 55
1 57
1 59
1 61
1 63
1 65
1 67
1 69
1 71
1 73
1 75
1 77
1 79
1 81
1 83
1 85
1 87
1 89
1 91
1 93
1 95
1 97
1 99
1 101
1 103
1 105
1 107
1 109
1 111
1 113
1 115
1 117...

result:

ok all 1 test passed

Test #85:

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

input:

101
4 2
1 1 2 2
4 2
1 2 1 2
3 3
1 2 3
2 2
1 2
5 2
2 2 2 1 2
5 2
2 1 2 1 2
5 2
1 2 2 2 1
5 2
2 1 2 1 1
5 2
1 1 1 2 1
5 2
1 2 2 1 2
5 2
2 1 1 2 2
5 2
2 2 2 1 1
5 2
1 1 2 1 2
5 2
1 2 2 2 1
7 2
1 2 1 1 1 2 1
7 2
1 1 2 1 2 1 2
7 2
2 2 1 1 2 1 1
7 2
1 1 1 2 2 1 1
7 2
1 2 2 1 2 2 1
7 2
2 1 2 2 2 2 1
7 2
1 ...

output:

3
1 3
1 4
2 3
4
1 2
1 4
2 3
3 4
3
1 2
1 3
2 3
1
1 2
4
1 4
2 4
3 4
4 5
5
1 2
1 4
2 3
3 4
4 5
4
1 2
1 3
1 4
4 5
5
1 2
1 5
2 3
3 4
3 5
4
1 4
2 4
3 4
4 5
5
1 2
1 5
2 4
3 4
4 5
4
1 2
1 3
3 4
3 5
4
1 4
1 5
2 4
3 4
5
1 3
1 5
2 3
3 4
4 5
4
1 2
1 3
1 4
4 5
7
1 2
1 6
2 3
3 6
4 6
5 6
6 7
8
1 3
1 5
1 7
2 3
3 4
...

result:

ok all 101 test passed

Test #86:

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

input:

87
4 2
1 1 2 2
4 2
1 2 1 2
3 3
1 2 3
2 2
1 2
5 2
2 2 2 1 2
5 2
2 1 2 1 2
5 2
1 2 2 2 1
5 2
2 1 2 1 1
5 2
1 1 1 2 1
5 2
1 2 2 1 2
5 2
2 1 1 2 2
5 2
2 2 2 1 1
5 2
1 1 2 1 2
5 2
1 2 2 2 1
7 2
1 2 1 1 1 2 1
7 2
1 1 2 1 2 1 2
7 2
2 2 1 1 2 1 1
7 2
1 1 1 2 2 1 1
7 2
1 2 2 1 2 2 1
7 2
2 1 2 2 2 2 1
7 2
1 2...

output:

3
1 3
1 4
2 3
4
1 2
1 4
2 3
3 4
3
1 2
1 3
2 3
1
1 2
4
1 4
2 4
3 4
4 5
5
1 2
1 4
2 3
3 4
4 5
4
1 2
1 3
1 4
4 5
5
1 2
1 5
2 3
3 4
3 5
4
1 4
2 4
3 4
4 5
5
1 2
1 5
2 4
3 4
4 5
4
1 2
1 3
3 4
3 5
4
1 4
1 5
2 4
3 4
5
1 3
1 5
2 3
3 4
4 5
4
1 2
1 3
1 4
4 5
7
1 2
1 6
2 3
3 6
4 6
5 6
6 7
8
1 3
1 5
1 7
2 3
3 4
...

result:

ok all 87 test passed

Test #87:

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

input:

101
4 2
1 1 2 2
4 2
1 2 1 2
3 3
1 2 3
2 2
1 2
5 2
2 2 2 1 2
5 2
2 1 2 1 2
5 2
1 2 2 2 1
5 2
2 1 2 1 1
5 2
1 1 1 2 1
5 2
1 2 2 1 2
5 2
2 1 1 2 2
5 2
2 2 2 1 1
5 2
1 1 2 1 2
5 2
1 2 2 2 1
7 2
1 2 1 1 1 2 1
7 2
1 1 2 1 2 1 2
7 2
2 2 1 1 2 1 1
7 2
1 1 1 2 2 1 1
7 2
1 2 2 1 2 2 1
7 2
2 1 2 2 2 2 1
7 2
1 ...

output:

3
1 3
1 4
2 3
4
1 2
1 4
2 3
3 4
3
1 2
1 3
2 3
1
1 2
4
1 4
2 4
3 4
4 5
5
1 2
1 4
2 3
3 4
4 5
4
1 2
1 3
1 4
4 5
5
1 2
1 5
2 3
3 4
3 5
4
1 4
2 4
3 4
4 5
5
1 2
1 5
2 4
3 4
4 5
4
1 2
1 3
3 4
3 5
4
1 4
1 5
2 4
3 4
5
1 3
1 5
2 3
3 4
4 5
4
1 2
1 3
1 4
4 5
7
1 2
1 6
2 3
3 6
4 6
5 6
6 7
8
1 3
1 5
1 7
2 3
3 4
...

result:

ok all 101 test passed

Test #88:

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

input:

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

output:

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

result:

ok all 3 test passed

Test #89:

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

input:

1
100000 2
2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1...

output:

104998
1 4
1 24
1 44
1 64
1 84
1 104
1 124
1 144
1 164
1 184
1 204
1 224
1 244
1 264
1 284
1 304
1 324
1 344
1 364
1 384
1 404
1 424
1 444
1 464
1 484
1 504
1 524
1 544
1 564
1 584
1 604
1 624
1 644
1 664
1 684
1 704
1 724
1 744
1 764
1 784
1 804
1 824
1 844
1 864
1 884
1 904
1 924
1 944
1 964
1 984...

result:

ok all 1 test passed

Test #90:

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

input:

1
2 2
1 2

output:

1
1 2

result:

ok all 1 test passed

Test #91:

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

input:

10
5 2
2 2 2 1 2
5 2
2 1 2 1 2
5 2
1 2 2 2 1
5 2
2 1 2 1 1
5 2
1 1 1 2 1
5 2
1 2 2 1 2
5 2
2 1 1 2 2
5 2
2 2 2 1 1
5 2
1 1 2 1 2
5 2
1 2 2 2 1

output:

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

result:

ok all 10 test passed

Test #92:

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

input:

10
7 2
1 2 1 1 1 2 1
7 2
1 1 2 1 2 1 2
7 2
2 2 1 1 2 1 1
7 2
1 1 1 2 2 1 1
7 2
1 2 2 1 2 2 1
7 2
2 1 2 2 2 2 1
7 2
1 2 1 2 2 2 2
7 2
2 2 1 2 1 2 1
7 2
2 1 1 2 1 2 2
7 2
2 2 1 2 1 1 2

output:

7
1 2
1 6
2 3
3 6
4 6
5 6
6 7
8
1 3
1 5
1 7
2 3
3 4
4 5
5 6
6 7
7
1 3
1 7
2 3
3 5
4 5
5 6
5 7
6
1 4
1 5
2 4
3 4
5 6
5 7
7
1 2
1 6
2 4
3 4
4 5
4 6
6 7
7
1 2
1 7
2 3
3 7
4 7
5 7
6 7
7
1 2
1 7
2 3
3 4
3 5
3 6
3 7
8
1 3
1 5
1 7
2 3
3 4
4 5
5 6
6 7
7
1 2
1 5
2 4
3 4
4 5
5 6
5 7
7
1 3
1 6
2 3
3 4
4 5
4 6
...

result:

ok all 10 test passed

Test #93:

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

input:

10
9 2
1 1 1 2 1 2 2 1 2
9 2
1 2 1 1 2 2 2 2 1
9 2
2 1 2 1 1 2 1 2 1
9 2
1 1 2 1 1 1 1 2 2
9 2
1 1 2 2 1 2 1 2 2
9 2
2 2 1 2 1 2 2 2 2
9 2
1 1 2 2 2 1 2 1 2
9 2
1 1 2 1 1 2 2 2 2
9 2
1 1 1 1 2 1 1 2 1
9 2
2 1 2 2 1 1 2 2 1

output:

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

result:

ok all 10 test passed

Test #94:

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

input:

1
5 2
1 1 2 2 1

output:

4
1 3
1 4
2 3
4 5

result:

ok all 1 test passed

Test #95:

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

input:

1
7 2
2 1 1 2 1 1 2

output:

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

result:

ok all 1 test passed

Test #96:

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

input:

1
9 2
2 1 1 2 1 1 1 2 2

output:

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

result:

ok all 1 test passed

Test #97:

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

input:

10
20 2
2 1 1 1 2 2 1 1 2 1 2 1 2 1 1 2 1 2 2 2
20 2
2 1 1 1 2 1 1 1 1 2 1 2 2 1 2 1 1 1 1 2
20 2
2 1 1 2 1 2 1 1 2 1 2 2 2 1 1 2 1 2 2 2
20 2
2 2 1 2 2 2 2 1 1 2 2 2 1 2 1 1 1 2 1 2
20 2
1 1 2 2 2 1 2 1 1 2 1 2 2 2 1 1 2 1 1 1
20 2
2 1 2 1 1 2 1 2 2 1 1 2 2 1 2 2 1 2 2 1
20 2
1 1 1 2 1 2 2 1 2 1 2 ...

output:

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

result:

ok all 10 test passed

Test #98:

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

input:

10
100 2
2 1 1 2 2 1 1 2 2 1 2 1 1 2 1 1 2 1 2 2 2 1 2 2 1 1 2 1 1 2 2 2 2 2 1 1 1 1 2 2 1 2 1 2 1 2 1 1 2 2 1 1 2 1 2 2 1 1 2 2 2 2 2 2 2 1 1 2 1 2 1 1 1 1 1 2 1 1 1 2 1 2 2 1 2 2 1 2 1 2 1 1 1 1 2 2 2 2 1 1
100 2
1 1 2 1 1 1 1 1 2 2 1 2 2 1 1 1 1 2 2 1 1 2 2 2 2 2 2 2 2 2 1 2 1 2 1 2 2 1 2 2 2 1 2...

output:

125
1 2
1 6
1 10
1 12
1 15
1 18
1 22
1 25
1 28
1 35
1 41
1 43
1 45
1 47
1 51
1 54
1 57
1 66
1 69
1 71
1 77
1 81
1 84
1 87
1 89
1 91
1 100
2 4
3 4
4 6
5 6
6 8
7 8
8 10
9 10
10 11
11 12
12 14
13 14
14 15
15 17
16 17
17 18
18 19
19 22
20 22
21 22
22 23
23 25
24 25
25 27
26 27
27 28
28 30
29 30
30 35
31...

result:

ok all 10 test passed

Test #99:

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

input:

1
300 2
2 2 1 1 1 2 2 2 2 2 2 2 2 1 2 2 2 2 1 1 1 1 1 2 1 1 1 1 2 1 2 1 1 1 1 1 2 2 2 1 2 2 2 2 1 2 2 2 1 2 2 2 1 1 1 1 1 1 1 2 2 2 1 2 2 1 2 2 1 2 2 1 2 1 2 2 2 1 2 2 2 2 2 1 1 2 1 1 2 2 1 2 2 2 1 1 2 1 1 2 2 2 2 1 2 2 2 2 2 2 1 2 1 2 2 1 2 1 2 1 1 1 1 2 1 2 1 1 1 1 2 2 2 2 1 2 2 1 2 1 2 1 1 2 2 1 ...

output:

367
1 3
1 14
1 19
1 25
1 30
1 32
1 40
1 45
1 49
1 53
1 63
1 66
1 69
1 72
1 74
1 78
1 84
1 87
1 91
1 95
1 98
1 104
1 111
1 113
1 116
1 118
1 120
1 125
1 127
1 135
1 138
1 140
1 142
1 146
1 148
1 153
1 155
1 157
1 163
1 166
1 177
1 179
1 183
1 186
1 188
1 192
1 197
1 207
1 213
1 216
1 219
1 223
1 226
...

result:

ok all 1 test passed

Test #100:

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

input:

10
7 3
2 3 1 2 2 3 3
7 3
1 2 3 1 3 3 2
7 3
1 3 1 2 1 2 1
7 3
3 1 2 3 1 2 2
7 3
1 2 3 2 1 1 2
7 3
3 2 2 3 3 1 1
7 3
3 1 2 2 1 3 3
7 3
3 3 3 2 2 1 1
7 3
2 1 3 1 3 1 2
7 3
3 2 3 1 1 1 1

output:

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

result:

ok all 10 test passed

Test #101:

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

input:

10
20 3
2 1 2 1 3 2 2 1 3 3 3 1 3 3 2 3 3 3 1 2
20 3
3 2 2 1 2 1 3 1 3 1 3 2 2 2 1 2 2 1 1 3
20 3
3 3 2 2 2 2 3 1 2 1 3 1 1 1 2 1 1 3 3 2
20 3
1 1 1 3 2 3 2 3 3 1 3 2 2 2 2 3 3 2 1 1
20 3
2 3 1 2 3 3 3 1 2 3 1 3 2 3 2 2 3 3 1 1
20 3
2 3 2 2 1 3 1 2 1 3 3 1 3 1 3 1 1 3 1 2
20 3
3 1 2 1 3 3 3 1 3 3 1 ...

output:

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

result:

ok all 10 test passed

Test #102:

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

input:

10
100 3
3 1 3 3 2 3 1 3 3 3 1 2 1 1 1 2 2 2 1 1 1 2 3 1 2 1 3 2 1 2 2 2 2 1 3 1 3 3 1 3 2 2 1 1 3 3 1 1 3 2 1 1 1 2 1 1 3 2 2 3 2 3 1 3 3 3 3 1 2 3 1 2 1 3 1 2 3 2 1 3 3 1 1 3 2 1 2 3 2 2 3 3 1 1 3 3 2 1 2 2
100 3
1 2 3 2 3 2 1 3 2 1 2 2 1 3 2 1 3 2 2 1 1 3 1 3 3 2 3 2 2 2 3 2 1 1 1 3 3 3 1 1 2 1 3...

output:

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

result:

ok all 10 test passed

Test #103:

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

input:

1
300 3
2 1 2 1 2 2 1 2 3 1 1 2 3 3 3 2 3 1 1 2 1 1 1 3 3 3 2 1 1 2 2 1 1 3 2 3 1 3 2 2 2 3 1 3 2 1 3 1 1 3 1 2 1 2 1 3 2 1 3 3 1 2 1 2 2 1 1 3 2 1 2 3 1 2 2 2 1 3 3 1 2 3 1 3 1 1 3 1 3 1 2 1 1 3 1 3 3 2 2 2 1 2 1 2 2 3 2 1 3 3 1 2 1 3 2 3 1 2 1 1 2 2 1 1 2 3 1 1 3 2 3 3 1 1 1 3 2 1 1 2 1 3 3 2 3 1 ...

output:

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

result:

ok all 1 test passed

Test #104:

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

input:

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

output:

11
1 2
1 3
1 4
1 5
1 6
1 7
2 3
3 4
4 5
5 6
6 7
11
1 2
1 3
1 4
1 5
1 6
1 7
2 3
3 4
4 5
5 6
6 7
11
1 2
1 3
1 4
1 5
1 6
1 7
2 3
3 4
4 5
5 6
6 7
11
1 2
1 3
1 4
1 5
1 6
1 7
2 3
3 4
4 5
5 6
6 7
11
1 2
1 3
1 4
1 5
1 6
1 7
2 3
3 4
4 5
5 6
6 7
11
1 2
1 3
1 4
1 5
1 6
1 7
2 3
3 4
4 5
5 6
6 7
11
1 2
1 3
1 4
1 5...

result:

ok all 10 test passed

Test #105:

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

input:

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

output:

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

result:

ok all 10 test passed

Test #106:

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

input:

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

output:

197
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 61
1 62...

result:

ok all 10 test passed

Test #107:

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

input:

1
300 300
77 46 15 213 13 258 21 73 122 114 55 238 294 179 97 175 25 104 83 153 80 36 135 216 252 100 50 169 5 211 253 146 223 82 76 44 90 288 261 174 14 222 127 298 203 151 286 178 68 28 85 75 42 167 112 226 106 123 220 230 242 160 132 2 161 232 229 291 22 170 158 57 193 263 266 71 184 289 195 136 ...

output:

597
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 61
1 62...

result:

ok all 1 test passed

Test #108:

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

input:

10
20 4
4 1 1 3 1 4 2 3 2 2 1 3 2 2 3 2 3 2 2 1
20 4
4 1 3 2 4 4 4 3 2 4 1 4 3 4 2 2 3 4 1 4
20 4
4 2 2 1 3 1 2 4 1 2 1 2 1 3 1 3 4 4 1 3
20 4
1 1 1 3 4 1 4 2 3 1 4 4 2 4 2 1 2 3 4 1
20 4
1 2 3 1 1 1 3 1 1 2 1 4 2 4 3 3 3 1 3 2
20 4
1 1 4 2 1 3 1 1 3 1 3 4 2 1 2 4 2 3 1 4
20 4
2 3 2 2 1 1 2 2 2 2 4 ...

output:

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

result:

ok all 10 test passed

Test #109:

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

input:

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

output:

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

result:

ok all 10 test passed

Test #110:

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

input:

1
300 2
1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 ...

output:

373
1 3
1 7
1 11
1 15
1 19
1 23
1 27
1 31
1 35
1 39
1 43
1 47
1 51
1 55
1 59
1 63
1 67
1 71
1 75
1 79
1 83
1 87
1 91
1 95
1 99
1 103
1 107
1 111
1 115
1 119
1 123
1 127
1 131
1 135
1 139
1 143
1 147
1 151
1 155
1 159
1 163
1 167
1 171
1 175
1 179
1 183
1 187
1 191
1 195
1 199
1 203
1 207
1 211
1 215...

result:

ok all 1 test passed

Test #111:

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

input:

1
300 2
2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 ...

output:

313
1 5
1 25
1 45
1 65
1 85
1 105
1 125
1 145
1 165
1 185
1 205
1 225
1 245
1 265
1 294
2 5
3 5
4 5
5 15
6 15
7 15
8 15
9 15
10 15
11 15
12 15
13 15
14 15
15 25
16 25
17 25
18 25
19 25
20 25
21 25
22 25
23 25
24 25
25 35
26 35
27 35
28 35
29 35
30 35
31 35
32 35
33 35
34 35
35 45
36 45
37 45
38 45
3...

result:

ok all 1 test passed

Test #112:

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

input:

1
300 2
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

299
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 61
1 62
1 63
1 64
1 65
1 66
1 67
1 68
1 69
1 70
1 71
1 72
1 73
1 74
1 75
1 76
1 77
1 78
1 79
1 80
1 81
1 82
1 83
1 84
1 85
1 86
1 87
1 88
1 89
1 90
1 91
1 92
1 93
1 94
1...

result:

ok all 1 test passed

Test #113:

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

input:

1
300 3
2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 ...

output:

447
1 3
1 300
2 3
3 5
3 7
3 300
4 5
5 7
6 7
7 9
7 300
8 9
9 11
9 13
9 300
10 11
11 13
12 13
13 15
13 300
14 15
15 17
15 19
15 300
16 17
17 19
18 19
19 21
19 300
20 21
21 23
21 25
21 300
22 23
23 25
24 25
25 27
25 300
26 27
27 29
27 31
27 300
28 29
29 31
30 31
31 33
31 300
32 33
33 35
33 37
33 300
34...

result:

ok all 1 test passed

Test #114:

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

input:

1
300 3
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

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

result:

ok all 1 test passed

Test #115:

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

input:

1
300 10
9 9 9 9 5 9 9 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 7 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4...

output:

315
1 5
1 277
2 5
3 5
4 5
5 6
5 277
6 8
6 277
7 8
8 38
8 68
8 74
8 75
8 98
8 128
8 158
8 186
8 187
8 188
8 218
8 240
8 241
8 277
9 38
10 38
11 38
12 38
13 38
14 38
15 38
16 38
17 38
18 38
19 38
20 38
21 38
22 38
23 38
24 38
25 38
26 38
27 38
28 38
29 38
30 38
31 38
32 38
33 38
34 38
35 38
36 38
37 3...

result:

ok all 1 test passed

Test #116:

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

input:

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

output:

449
1 3
1 300
2 3
3 5
3 300
4 5
5 7
5 300
6 7
7 9
7 300
8 9
9 11
9 300
10 11
11 13
11 300
12 13
13 15
13 300
14 15
15 17
15 300
16 17
17 19
17 21
17 300
18 19
19 21
20 21
21 23
21 300
22 23
23 25
23 300
24 25
25 27
25 300
26 27
27 29
27 300
28 29
29 30
29 300
30 31
30 300
31 33
31 300
32 33
33 35
33...

result:

ok all 1 test passed

Test #117:

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

input:

1
300 150
21 91 61 3 124 47 39 37 35 86 28 74 50 79 125 146 38 32 60 111 114 29 103 121 126 55 61 47 149 9 149 124 92 29 78 104 54 34 54 27 1 59 44 123 9 36 29 25 124 88 125 145 113 137 119 108 27 132 124 114 143 143 77 97 84 83 40 132 77 62 72 37 51 139 56 80 34 87 69 131 100 57 120 148 42 42 123 2...

output:

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

result:

ok all 1 test passed

Test #118:

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

input:

1
1000 3
3 2 3 3 2 1 2 1 2 1 2 3 1 1 2 3 1 3 3 2 1 3 1 1 3 3 1 2 1 2 1 1 3 2 2 1 2 3 2 2 3 1 2 2 1 1 2 2 1 2 1 1 3 1 1 3 3 2 1 2 3 2 1 3 3 2 2 2 3 2 3 3 1 2 1 1 2 1 2 3 1 2 1 3 1 3 3 1 2 1 1 2 2 1 1 2 2 2 1 1 3 1 1 1 3 2 2 1 1 3 2 3 1 2 3 3 3 2 3 3 1 2 3 3 2 2 2 2 2 1 2 3 3 3 2 2 3 3 1 1 2 3 1 1 1 2...

output:

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

result:

ok all 1 test passed

Test #119:

score: 0
Accepted
time: 15ms
memory: 5808kb

input:

1
50000 3
1 1 1 2 3 1 3 3 3 2 3 1 2 1 1 3 2 3 3 3 2 3 3 3 3 1 2 3 1 3 2 2 1 2 3 2 3 3 2 1 1 3 3 2 2 2 3 1 2 3 3 3 2 2 2 2 1 3 1 1 2 1 3 3 3 2 1 3 3 3 3 3 1 3 1 1 1 2 2 1 2 1 2 3 1 2 2 3 3 3 3 2 3 2 2 3 2 1 3 2 2 3 3 2 1 1 2 3 1 2 1 1 3 3 3 3 1 3 3 3 3 3 3 1 3 1 2 2 1 3 2 2 1 1 3 2 1 1 3 3 1 2 3 3 3 ...

output:

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

result:

ok all 1 test passed

Test #120:

score: 0
Accepted
time: 59ms
memory: 14056kb

input:

1
200000 3
2 2 3 2 2 2 3 2 3 2 3 2 1 2 3 3 3 2 2 2 1 1 1 3 1 1 2 2 2 3 1 2 3 2 1 2 3 1 2 2 2 2 1 3 1 2 3 1 1 3 3 1 1 3 1 1 3 1 3 2 2 1 3 1 3 1 1 3 1 3 1 2 1 1 3 2 1 1 3 2 2 2 1 3 2 1 3 2 1 2 3 2 2 1 2 2 2 1 1 1 2 2 3 1 2 2 2 3 1 2 3 1 2 1 3 2 2 2 1 1 1 3 2 2 3 1 3 2 1 3 2 3 1 3 3 3 3 1 1 1 3 1 1 3 3...

output:

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

result:

ok all 1 test passed

Test #121:

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

input:

1
200000 200000
71411 193310 53795 23615 45771 160252 44119 78297 131589 51364 26492 146125 67205 6162 46301 154524 63313 17662 99459 174369 2147 116145 193734 83070 149201 160201 50714 37506 63554 72954 57451 105091 66834 1649 190400 22397 45745 20241 100997 1097 105227 109475 49745 49889 23931 153...

output:

399997
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 61
1...

result:

ok all 1 test passed

Test #122:

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

input:

1
1000 2
2 1 1 2 2 1 1 1 1 2 2 2 2 1 1 1 1 2 1 1 2 2 1 1 1 2 1 1 1 2 1 2 2 2 1 1 1 2 2 1 2 1 2 1 2 2 2 1 1 2 1 2 1 2 1 1 2 1 2 1 2 2 1 2 2 2 2 2 1 2 2 1 2 2 2 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 1 2 2 2 1 2 1 2 1 1 2 1 1 2 2 2 1 1 1 2 1 1 2 1 1 2 2 2 2 2 2 1 1 1 2 2 1 2 2 1 1 2 2 1 1 1 2 2 1 2 2 2 2 1 2 1...

output:

1251
1 2
1 6
1 14
1 19
1 23
1 27
1 31
1 35
1 40
1 42
1 44
1 48
1 51
1 53
1 55
1 58
1 60
1 63
1 69
1 72
1 76
1 84
1 91
1 95
1 97
1 99
1 102
1 107
1 111
1 114
1 122
1 127
1 130
1 134
1 139
1 144
1 146
1 150
1 153
1 158
1 168
1 171
1 176
1 179
1 181
1 187
1 192
1 195
1 199
1 202
1 205
1 208
1 211
1 213...

result:

ok all 1 test passed

Test #123:

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

input:

1
50000 2
1 1 1 1 2 2 2 1 1 1 2 2 2 1 2 2 1 1 2 2 2 2 2 1 1 1 1 2 1 2 2 1 1 2 1 1 1 2 2 1 2 2 1 1 2 1 1 1 2 1 1 1 2 2 2 1 2 2 2 1 1 1 2 1 1 2 1 2 1 1 1 1 1 1 1 2 2 1 1 2 2 1 1 1 2 1 2 2 1 1 1 2 2 2 1 2 2 2 2 1 2 1 1 1 2 1 2 1 1 1 1 1 2 2 1 1 1 2 1 1 1 2 1 1 2 1 1 2 1 1 1 1 1 1 2 1 2 2 2 2 1 2 2 2 2 ...

output:

62493
1 5
1 11
1 15
1 19
1 28
1 30
1 34
1 38
1 41
1 45
1 49
1 53
1 57
1 63
1 66
1 68
1 76
1 80
1 85
1 87
1 92
1 96
1 101
1 105
1 107
1 113
1 118
1 122
1 125
1 128
1 135
1 137
1 142
1 147
1 150
1 153
1 159
1 167
1 172
1 179
1 182
1 184
1 187
1 189
1 192
1 199
1 202
1 205
1 211
1 214
1 220
1 226
1 232...

result:

ok all 1 test passed

Test #124:

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

input:

1
200000 2
2 2 2 2 1 1 2 2 1 2 2 1 2 1 1 2 1 1 2 1 1 1 2 2 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 2 1 1 2 1 1 2 2 2 1 2 2 2 2 2 1 2 2 1 1 2 1 1 1 2 1 2 1 2 1 1 2 1 1 1 1 1 1 2 2 2 2 1 1 1 1 2 2 2 1 1 1 1 2 1 2 1 1 2 2 1 2 1 1 2 1 2 1 1 2 2 2 2 2 2 1 1 2 2 1 2 2 1 2 1 1 1 2 1 1 2 1 1 2 2 1 2 1 2 2 2 1 1 2 1 1...

output:

249802
1 5
1 9
1 12
1 14
1 17
1 20
1 25
1 35
1 39
1 41
1 44
1 49
1 55
1 58
1 61
1 65
1 67
1 69
1 72
1 82
1 89
1 94
1 96
1 100
1 102
1 105
1 107
1 115
1 119
1 122
1 124
1 128
1 131
1 135
1 137
1 141
1 144
1 149
1 154
1 156
1 159
1 163
1 165
1 169
1 173
1 177
1 182
1 187
1 191
1 195
1 197
1 199
1 201
...

result:

ok all 1 test passed

Test #125:

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

input:

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

output:

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

result:

ok all 1 test passed

Test #126:

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

input:

1
50000 200
92 72 198 135 4 150 28 113 136 17 48 43 90 30 110 25 115 86 44 35 138 189 3 76 10 53 29 11 62 175 62 165 82 10 95 72 89 76 17 43 186 140 87 199 131 196 171 4 137 65 11 31 152 154 28 181 39 31 71 62 175 169 125 37 37 96 100 60 173 93 9 162 186 100 104 172 90 134 75 14 199 109 101 167 191 ...

output:

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

result:

ok all 1 test passed

Test #127:

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

input:

1
200000 400
194 273 81 167 64 136 269 276 68 53 308 233 254 201 322 244 330 315 106 300 38 267 60 206 206 1 177 19 53 219 8 378 45 190 250 55 203 159 295 243 262 86 36 83 269 154 178 255 12 224 368 371 108 11 55 208 216 110 177 101 99 50 54 196 96 399 138 78 93 292 87 218 293 192 207 60 163 325 159...

output:

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

result:

ok all 1 test passed

Test #128:

score: 0
Accepted
time: 50ms
memory: 11004kb

input:

1
200000 2
2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2 1 1 2 2...

output:

249998
1 2
1 6
1 10
1 14
1 18
1 22
1 26
1 30
1 34
1 38
1 42
1 46
1 50
1 54
1 58
1 62
1 66
1 70
1 74
1 78
1 82
1 86
1 90
1 94
1 98
1 102
1 106
1 110
1 114
1 118
1 122
1 126
1 130
1 134
1 138
1 142
1 146
1 150
1 154
1 158
1 162
1 166
1 170
1 174
1 178
1 182
1 186
1 190
1 194
1 198
1 202
1 206
1 210
1 ...

result:

ok all 1 test passed

Test #129:

score: 0
Accepted
time: 16ms
memory: 4484kb

input:

1
100000 2
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

100050
1 309
1 2309
1 4309
1 6309
1 8309
1 10309
1 12309
1 14309
1 16309
1 18309
1 20309
1 22309
1 24309
1 26309
1 28309
1 30309
1 32309
1 34309
1 36309
1 38309
1 40309
1 42309
1 44309
1 46309
1 48309
1 50309
1 51840
1 52309
1 54309
1 56309
1 58309
1 60309
1 62309
1 64309
1 66309
1 68309
1 70309
1 7...

result:

ok all 1 test passed

Test #130:

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

input:

1
200000 2
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2...

output:

200003
1 50101
1 66073
1 74863
1 76164
1 174862
2 50101
3 50101
4 50101
5 50101
6 50101
7 50101
8 50101
9 50101
10 50101
11 50101
12 50101
13 50101
14 50101
15 50101
16 50101
17 50101
18 50101
19 50101
20 50101
21 50101
22 50101
23 50101
24 50101
25 50101
26 50101
27 50101
28 50101
29 50101
30 50101...

result:

ok all 1 test passed

Test #131:

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

input:

1
150000 3
2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2 2 3 3 1 1 2...

output:

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

result:

ok all 1 test passed

Test #132:

score: 0
Accepted
time: 28ms
memory: 6088kb

input:

1
150000 3
3 3 3 3 3 3 3 3 3 3 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2...

output:

164997
1 11
1 150000
2 11
3 11
4 11
5 11
6 11
7 11
8 11
9 11
10 11
11 21
11 31
11 150000
12 21
13 21
14 21
15 21
16 21
17 21
18 21
19 21
20 21
21 31
22 31
23 31
24 31
25 31
26 31
27 31
28 31
29 31
30 31
31 41
31 150000
32 41
33 41
34 41
35 41
36 41
37 41
38 41
39 41
40 41
41 51
41 61
41 150000
42 51...

result:

ok all 1 test passed

Test #133:

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

input:

1
199998 3
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2...

output:

200002
1 11590
1 171251
2 11590
3 11590
4 11590
5 11590
6 11590
7 11590
8 11590
9 11590
10 11590
11 11590
12 11590
13 11590
14 11590
15 11590
16 11590
17 11590
18 11590
19 11590
20 11590
21 11590
22 11590
23 11590
24 11590
25 11590
26 11590
27 11590
28 11590
29 11590
30 11590
31 11590
32 11590
33 11...

result:

ok all 1 test passed

Test #134:

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

input:

1
200000 100
78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78...

output:

200097
1 779
1 2779
1 4779
1 6779
1 8779
1 10779
1 12779
1 14779
1 16779
1 18779
1 20779
1 22779
1 24779
1 26779
1 28779
1 30779
1 32779
1 34779
1 36779
1 38779
1 40779
1 42779
1 44779
1 46779
1 48779
1 50779
1 52779
1 54779
1 56779
1 58779
1 60779
1 62779
1 64779
1 66779
1 68779
1 70779
1 72779
1 7...

result:

ok all 1 test passed

Test #135:

score: 0
Accepted
time: 54ms
memory: 9444kb

input:

1
200000 100000
96138 96138 96139 96139 96140 96140 96141 96141 96142 96142 96143 96143 96144 96144 96145 96145 96146 96146 96147 96147 96148 96148 96149 96149 96150 96150 96151 96151 96152 96152 96153 96153 96154 96154 96155 96155 96156 96156 96157 96157 96158 96158 96159 96159 96160 96160 96161 96...

output:

299999
1 3
1 5
1 7
1 9
1 11
1 13
1 15
1 17
1 19
1 21
1 23
1 25
1 27
1 29
1 31
1 33
1 35
1 37
1 39
1 41
1 43
1 45
1 47
1 49
1 51
1 53
1 55
1 57
1 59
1 61
1 63
1 65
1 67
1 69
1 71
1 73
1 75
1 77
1 79
1 81
1 83
1 85
1 87
1 89
1 91
1 93
1 95
1 97
1 99
1 101
1 103
1 105
1 107
1 109
1 111
1 113
1 115
1 11...

result:

ok all 1 test passed