QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#540525#5707. Virusesbachbeo2007100 ✓79ms21152kbC++232.3kb2024-08-31 17:14:292024-08-31 17:14:29

Judging History

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

  • [2024-08-31 17:14:29]
  • 评测
  • 测评结果:100
  • 用时:79ms
  • 内存:21152kb
  • [2024-08-31 17:14:29]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn = 105;
const int inf = 1e18;
typedef array<int,4> node; 

int N,M,K;
int g[maxn][maxn],S;
int nxt[maxn][2],par[maxn],T;
int a[maxn],b[maxn][maxn];

int f[maxn][maxn][maxn],dp[maxn][maxn][maxn];


signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cin >> N >> M >> K;
    for(int i=0;i<M;i++){
        int x,sz,u=0;
        cin >> x >> sz;
        for(int j=0;j<sz;j++){
            int y;cin >> y;
            if(!g[u][y]) g[u][y]=++S;
            u=g[u][y];
        }
        b[u][x]=1;
    }
    for(int i=0;i<K;i++){
        int sz,u=0;cin >> sz;
        for(int j=0;j<sz;j++){
            int y;cin >> y;
            if(!nxt[u][y]) nxt[u][y]=++T;
            u=nxt[u][y];
        }
        a[u]=1;
    }

    queue<int> q;q.push(0);
    while(!q.empty()){
        int u=q.front(),p=par[u];
        q.pop();a[u]|=a[p];
        for(int i=0;i<=1;i++){
            if(nxt[u][i]){
                int v=nxt[u][i];
                par[v]=(u?nxt[p][i]:0);
                q.push(v);
            }
            else nxt[u][i]=nxt[p][i];
        }
    }
    for(int i=0;i<N;i++) for(int x=0;x<=T;x++) for(int y=0;y<=T;y++) f[i][x][y]=inf;
    for(int i=0;i<=S;i++) for(int x=0;x<=T;x++) for(int y=0;y<=T;y++) dp[i][x][y]=inf;
    
    for(int x=0;x<=T;x++){
        for(int i=0;i<=1;i++){
            int y=nxt[x][i];
            if(!a[x] && !a[y]) f[i][x][y]=1;
        }
    }
    
    priority_queue<node,vector<node>,greater<node>> pq;
    for(int x=0;x<=T;x++) pq.push({dp[0][x][x]=0,0,x,x});
    while(!pq.empty()){
        auto [d,u,x,y]=pq.top();pq.pop();
        if(dp[u][x][y]!=d) continue;
        for(int i=0;i<N;i++) if(b[u][i] && f[i][x][y]>d){
            f[i][x][y]=d;
            for(int j=0,v;j<=S;j++) if(v=g[j][i]){
                for(int z=0;z<=T;z++) if(dp[v][z][y]>dp[j][z][x]+d) pq.push({dp[v][z][y]=dp[j][z][x]+d,v,z,y});
            }
        }
        for(int i=0,v;i<N;i++) if(v=g[u][i]){
            for(int z=0;z<=T;z++) if(dp[v][x][z]>d+f[i][y][z]) pq.push({dp[v][x][z]=d+f[i][y][z],v,x,z});
        }
    }
    for(int i=2;i<N;i++){
        int res=*min_element(f[i][0],f[i][0]+T+1);
        if(res!=inf) cout << "NO " << res << '\n';
        else cout << "YES\n";
    }
}

详细

Subtask #1:

score: 11
Accepted

Test #1:

score: 11
Accepted
time: 2ms
memory: 13984kb

input:

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

output:

NO 2
NO 4
NO 8
NO 16
NO 32
NO 64
NO 128
NO 256
NO 512
NO 1024
NO 2048
NO 4096
NO 8192
NO 16384
NO 32768
NO 65536
NO 131072
NO 262144
NO 524288
NO 1048576
NO 2097152
NO 4194304
NO 8388608
NO 16777216
NO 33554432
NO 67108864
NO 134217728
NO 268435456
NO 536870912
NO 1073741824
NO 2147483648
NO 4294967...

result:

ok 33 lines

Test #2:

score: 11
Accepted
time: 1ms
memory: 7764kb

input:

4 23 0
2 1 0
2 1 1
2 2 0 0
2 2 0 1
2 2 1 0
2 2 1 1
3 1 2
3 3 0 0 0
3 3 0 0 1
3 3 0 1 0
3 3 0 1 1
3 3 1 0 0
3 3 0 0 1
3 3 1 1 0
3 3 1 1 1
3 4 0 0 0 3
3 4 0 0 1 3
3 4 0 1 0 3
3 4 0 1 1 3
3 4 1 0 0 3
3 4 0 0 1 3
3 4 1 1 0 3
3 4 1 1 1 3

output:

NO 1
NO 1

result:

ok 2 lines

Test #3:

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

input:

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

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
...

result:

ok 98 lines

Test #4:

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

input:

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

output:

NO 4
NO 4
NO 4
NO 13
YES
NO 9
YES
YES
YES
YES
NO 10
YES
YES

result:

ok 13 lines

Test #5:

score: 11
Accepted
time: 3ms
memory: 18128kb

input:

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

output:

NO 1
NO 2
NO 4
NO 8
NO 16
NO 32
NO 64
NO 128
NO 256
NO 512
NO 1024
NO 2048
NO 4096
NO 8192
NO 16384
NO 32768
NO 65536
NO 131072
NO 262144
NO 524288
NO 1048576
NO 2097152
NO 4194304
NO 8388608
NO 16777216
NO 33554432
NO 67108864
NO 134217728
NO 268435456
NO 536870912
NO 1073741824
NO 2147483648
NO 42...

result:

ok 49 lines

Test #6:

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

input:

14 27 0
2 4 1 1 1 1
3 4 0 0 0 1
4 4 1 1 1 1
5 3 1 1 0
6 4 2 1 0 4
7 3 4 1 4
8 3 5 6 1
9 4 8 6 1 7
10 3 1 5 8
11 3 0 10 10
12 3 9 0 9
13 3 10 11 0
10 3 13 1 13
3 5 10 13 12 1 7
11 3 2 8 0
6 5 4 13 10 3 1
5 5 8 1 9 4 3
9 4 2 0 6 6
2 4 6 12 12 1
6 3 8 0 9
2 4 2 7 1 6
9 3 13 1 9
9 4 13 0 12 7
4 3 8 0 12...

output:

NO 4
NO 4
NO 4
NO 3
NO 10
NO 9
NO 14
NO 25
NO 18
NO 8
NO 51
NO 27

result:

ok 12 lines

Test #7:

score: 11
Accepted
time: 2ms
memory: 11960kb

input:

7 24 0
2 4 0 0 1 0
3 4 1 1 1 1
4 4 0 0 1 1
5 3 1 0 2
6 4 1 4 2 0
5 4 5 2 6 0
2 5 5 4 1 5 3
3 5 1 4 2 3 2
2 4 3 3 6 0
4 3 2 5 0
5 5 3 4 5 4 1
6 5 5 5 4 1 5
6 3 4 0 4
6 4 3 4 5 0
5 3 4 1 3
3 3 4 6 0
5 5 4 1 2 3 5
2 5 6 1 2 6 3
2 3 1 4 5
3 5 2 0 5 6 4
2 5 6 3 0 5 6
2 3 1 4 3
3 5 6 2 5 0 2
3 5 6 4 1 5 4

output:

NO 4
NO 4
NO 4
NO 6
NO 9

result:

ok 5 lines

Test #8:

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

input:

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

output:

NO 4
NO 4
NO 4
NO 4
NO 9
NO 9
NO 18
NO 32

result:

ok 8 lines

Test #9:

score: 11
Accepted
time: 2ms
memory: 11920kb

input:

8 24 0
2 4 1 0 0 1
3 4 1 0 0 1
4 4 1 0 0 1
5 4 2 3 2 0
6 3 2 0 2
7 3 5 1 5
4 4 1 6 4 7
3 5 6 6 4 2 1
7 5 2 6 6 1 7
3 3 4 3 0
5 5 6 0 3 7 4
5 5 4 7 7 1 3
7 4 3 6 1 7
7 3 0 3 2
4 3 0 5 3
5 4 2 6 1 7
3 5 6 1 7 5 6
3 5 4 6 0 5 6
3 3 0 3 5
3 3 7 1 5
4 4 6 2 2 1
5 4 0 4 2 3
7 4 6 7 6 0
4 5 5 4 0 6 7

output:

NO 4
NO 4
NO 4
NO 13
NO 9
NO 9

result:

ok 6 lines

Test #10:

score: 11
Accepted
time: 2ms
memory: 13984kb

input:

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

output:

NO 4
NO 4
NO 4
NO 7
NO 9
NO 14
NO 12
NO 17
NO 9

result:

ok 9 lines

Test #11:

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

input:

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

output:

NO 4
NO 4
NO 4
NO 10
NO 15
NO 20
NO 26
NO 9

result:

ok 8 lines

Test #12:

score: 11
Accepted
time: 2ms
memory: 13952kb

input:

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

output:

NO 4
NO 4
NO 4
NO 10
NO 15
NO 9
NO 19
NO 9
NO 44
NO 34
NO 53
NO 54
NO 107
NO 48
NO 137
NO 245
NO 245

result:

ok 17 lines

Test #13:

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

input:

6 25 0
2 4 1 1 1 0
3 4 0 1 1 0
4 4 1 0 1 0
5 4 4 1 1 1
4 3 2 1 5
3 5 5 2 1 5 4
2 4 4 4 2 0
2 3 1 3 5
2 3 2 0 4
5 3 3 1 4
5 5 1 4 5 5 4
2 3 3 0 3
5 3 0 5 3
3 5 4 4 1 4 3
2 5 3 2 5 0 2
3 5 1 3 2 2 3
2 4 2 0 2 3
4 3 4 0 2
4 5 5 1 2 2 3
4 5 2 2 2 1 5
4 3 5 4 0
4 5 5 1 5 5 5
4 3 2 4 1
2 3 5 1 2
5 5 1 5 5...

output:

NO 4
NO 4
NO 4
NO 7

result:

ok 4 lines

Test #14:

score: 11
Accepted
time: 2ms
memory: 11864kb

input:

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

output:

NO 4
NO 4
NO 4
NO 6
NO 13
NO 15
NO 27
NO 24

result:

ok 8 lines

Test #15:

score: 11
Accepted
time: 2ms
memory: 13920kb

input:

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

output:

NO 4
NO 4
NO 4
NO 6
NO 7
NO 9
NO 13
NO 14

result:

ok 8 lines

Test #16:

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

input:

33 62 0
2 2 32 32
2 1 2
3 2 30 30
3 1 3
4 2 27 27
4 1 4
5 2 2 2
5 1 5
6 2 28 28
6 1 6
7 2 16 16
7 1 7
8 2 25 25
8 1 8
9 2 18 18
9 1 9
10 2 15 15
10 1 10
11 2 5 5
11 1 11
12 2 22 22
12 1 12
13 2 24 24
13 1 13
14 2 29 29
14 1 14
15 2 12 12
15 1 15
16 2 6 6
16 1 16
17 2 7 7
17 1 17
18 2 3 3
18 1 18
19 ...

output:

NO 512
NO 8192
NO 2147483648
NO 1024
NO 33554432
NO 134217728
NO 2097152
NO 32768
NO 524288
NO 2048
NO 131072
NO 128
NO 4
NO 262144
NO 67108864
NO 268435456
NO 16384
NO 4194304
NO 16
NO 536870912
NO 65536
NO 32
NO 64
NO 1048576
NO 8
NO 1073741824
NO 16777216
NO 2
NO 4096
NO 8388608
NO 256

result:

ok 31 lines

Test #17:

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

input:

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

output:

NO 3486784401
NO 9
NO 243
NO 729
NO 1594323
NO 31381059609
NO 59049
NO 14348907
NO 19683
NO 4782969
NO 129140163
NO 387420489
NO 81
NO 94143178827
NO 6561
NO 43046721
NO 2187
NO 531441
NO 10460353203
NO 3
NO 1162261467
NO 27
NO 177147

result:

ok 23 lines

Test #18:

score: 11
Accepted
time: 2ms
memory: 12096kb

input:

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

output:

NO 125
NO 6103515625
NO 244140625
NO 625
NO 9765625
NO 3125
NO 25
NO 15625
NO 1220703125
NO 78125
NO 5
NO 390625
NO 1953125
NO 48828125

result:

ok 14 lines

Test #19:

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

input:

12 20 0
2 7 8 8 8 8 8 8 8
2 1 2
3 7 2 2 2 2 2 2 2
3 1 3
4 7 9 9 9 9 9 9 9
4 1 4
5 7 3 3 3 3 3 3 3
5 1 5
6 7 1 1 1 1 1 1 1
6 1 6
7 7 10 10 10 10 10 10 10
7 1 7
8 7 6 6 6 6 6 6 6
8 1 8
9 7 7 7 7 7 7 7 7
9 1 9
10 7 11 11 11 11 11 11 11
10 1 10
11 7 5 5 5 5 5 5 5
11 1 11

output:

NO 343
NO 2401
NO 282475249
NO 16807
NO 7
NO 5764801
NO 49
NO 40353607
NO 823543
NO 117649

result:

ok 10 lines

Test #20:

score: 11
Accepted
time: 3ms
memory: 18220kb

input:

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

output:

NO 1
YES
YES
NO 1
NO 1
NO 1
NO 1
YES
YES
YES
NO 1
YES
NO 1
YES
YES
NO 1
YES
NO 1
NO 1
NO 1
YES
NO 1
YES
YES
YES
NO 1
YES
NO 1
NO 1
NO 1
NO 1
NO 1
YES
YES
NO 1
YES
YES
YES
NO 1
YES
NO 1
YES
YES
YES
NO 1
YES
YES
YES
NO 1
YES
YES
NO 1
NO 1
YES
YES
YES
YES
NO 1
YES
NO 1
YES
NO 1
YES
NO 1
YES
YES
NO 1
NO...

result:

ok 100 lines

Subtask #2:

score: 14
Accepted

Test #21:

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

input:

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

output:

NO 2
NO 4
NO 8
NO 16
NO 32
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES

result:

ok 50 lines

Test #22:

score: 14
Accepted
time: 1ms
memory: 10152kb

input:

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

output:

YES
YES
YES
YES
NO 4
YES
YES
NO 4
NO 4
YES
YES
NO 4
YES
YES
YES
YES

result:

ok 16 lines

Test #23:

score: 14
Accepted
time: 4ms
memory: 21152kb

input:

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

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
...

result:

ok 98 lines

Test #24:

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

input:

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

output:

YES
NO 4
YES
NO 2
YES
YES
YES
YES
YES
YES
YES
YES
YES

result:

ok 13 lines

Test #25:

score: 14
Accepted
time: 4ms
memory: 18576kb

input:

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

output:

NO 1
NO 2
NO 4
NO 8
NO 16
NO 32
NO 64
NO 128
NO 256
NO 512
NO 1024
NO 2048
NO 4096
NO 8192
NO 16384
NO 32768
NO 65536
NO 131072
NO 262144
NO 524288
NO 1048576
NO 2097152
NO 4194304
NO 8388608
NO 16777216
NO 33554432
NO 67108864
NO 134217728
NO 268435456
NO 536870912
NO 1073741824
NO 2147483648
NO 42...

result:

ok 49 lines

Test #26:

score: 14
Accepted
time: 2ms
memory: 14060kb

input:

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

output:

NO 3
NO 3
NO 3
NO 8
NO 20
NO 15
NO 7
YES
NO 29
YES
YES
YES
YES
YES
YES
YES
YES
YES

result:

ok 18 lines

Test #27:

score: 14
Accepted
time: 2ms
memory: 10388kb

input:

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

output:

NO 3
NO 4
NO 3
NO 11
NO 16
YES
YES
YES
YES
YES

result:

ok 10 lines

Test #28:

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

input:

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

output:

NO 3
NO 3
NO 4
NO 7
NO 3
NO 15
YES
YES
NO 11
NO 42
YES
YES
YES
YES
YES

result:

ok 15 lines

Test #29:

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

input:

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

output:

NO 3
NO 4
NO 3
NO 10

result:

ok 4 lines

Test #30:

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

input:

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

output:

NO 3
NO 3
NO 3
NO 5
YES
YES
NO 14
NO 9
YES
NO 24
YES
YES

result:

ok 12 lines

Test #31:

score: 14
Accepted
time: 2ms
memory: 10504kb

input:

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

output:

NO 3
NO 4
NO 4
NO 9
NO 11
YES
YES
YES
YES
YES
YES

result:

ok 11 lines

Test #32:

score: 14
Accepted
time: 2ms
memory: 10296kb

input:

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

output:

NO 3
NO 4
NO 4
YES
NO 8
NO 13
NO 21
NO 26
YES
YES

result:

ok 10 lines

Test #33:

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

input:

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

output:

NO 3
NO 3
NO 3
NO 10
NO 8
YES
NO 24
NO 53
NO 19
NO 44
YES
YES
YES
YES

result:

ok 14 lines

Test #34:

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

input:

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

output:

NO 3
NO 3
NO 4
YES
NO 8
NO 24
YES
NO 9
YES
YES
YES
YES
YES

result:

ok 13 lines

Test #35:

score: 14
Accepted
time: 1ms
memory: 8032kb

input:

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

output:

NO 4
NO 3
NO 3
NO 7
NO 15
YES
NO 23

result:

ok 7 lines

Test #36:

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

input:

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

output:

NO 4
NO 68719476736
NO 35184372088832
NO 65536
NO 140737488355328
NO 8388608
NO 32768
NO 8589934592
NO 16777216
NO 524288
NO 33554432
NO 4398046511104
NO 4294967296
NO 128
NO 1099511627776
NO 536870912
NO 16384
NO 281474976710656
NO 1048576
NO 2097152
NO 4096
NO 512
NO 131072
NO 64
NO 17592186044416...

result:

ok 48 lines

Test #37:

score: 14
Accepted
time: 4ms
memory: 15004kb

input:

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

output:

NO 68630377364883
NO 27
NO 729
NO 531441
NO 94143178827
NO 19683
NO 22876792454961
NO 4782969
NO 43046721
NO 129140163
NO 387420489
NO 3486784401
NO 177147
NO 10460353203
NO 1594323
NO 7625597484987
NO 847288609443
NO 59049
NO 81
NO 205891132094649
NO 14348907
NO 282429536481
NO 2187
NO 617673396283...

result:

ok 31 lines

Test #38:

score: 14
Accepted
time: 3ms
memory: 14696kb

input:

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

output:

NO 1220703125
NO 78125
NO 762939453125
NO 15625
NO 5
NO 25
NO 390625
NO 30517578125
NO 152587890625
NO 1953125
NO 3125
NO 625
NO 48828125
NO 6103515625
NO 9765625
NO 125
NO 3814697265625
NO 244140625

result:

ok 18 lines

Test #39:

score: 14
Accepted
time: 1ms
memory: 5756kb

input:

3 1 2
2 2 1 0
49 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 0

output:

YES

result:

ok single line: 'YES'

Test #40:

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

input:

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

output:

NO 9720
NO 41990400
NO 90
NO 335923200
NO 2799360
NO 1620
NO 540
NO 3
NO 167961600
NO 466560
NO 3240
NO 180
NO 933120
NO 9
NO 8398080
NO 38880
NO 18
NO 155520

result:

ok 18 lines

Test #41:

score: 14
Accepted
time: 1ms
memory: 5712kb

input:

3 1 2
2 2 1 0
9 1 0 1 0 1 0 1 0 1
1 0

output:

YES

result:

ok single line: 'YES'

Test #42:

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

input:

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

output:

YES

result:

ok single line: 'YES'

Subtask #3:

score: 25
Accepted

Test #43:

score: 25
Accepted
time: 2ms
memory: 11956kb

input:

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

output:

NO 2
NO 4
NO 6
NO 10
NO 14
NO 22
NO 30
NO 46
NO 62
NO 94
NO 126
NO 190
NO 254
NO 382
NO 510
NO 766
NO 1022
NO 1534
NO 2046
NO 3070

result:

ok 20 lines

Test #44:

score: 25
Accepted
time: 2ms
memory: 8204kb

input:

4 23 1
2 1 0
2 1 1
2 2 0 0
2 2 0 1
2 2 1 0
2 2 1 1
3 1 2
3 3 0 0 0
3 3 0 0 1
3 3 0 1 0
3 3 0 1 1
3 3 1 0 0
3 3 0 0 1
3 3 1 1 0
3 3 1 1 1
3 4 0 0 0 3
3 4 0 0 1 3
3 4 0 1 0 3
3 4 0 1 1 3
3 4 1 0 0 3
3 4 0 0 1 3
3 4 1 1 0 3
3 4 1 1 1 3
50 0 0 0 1 0 1 0 1 0 1 1 0 0 1 0 1 1 1 0 0 0 1 0 1 1 1 0 0 1 0 1 1 ...

output:

NO 1
NO 1

result:

ok 2 lines

Test #45:

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

input:

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

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES

result:

ok 48 lines

Test #46:

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

input:

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

output:

YES
NO 4
NO 4
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES

result:

ok 13 lines

Test #47:

score: 25
Accepted
time: 79ms
memory: 19104kb

input:

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

output:

NO 1
NO 2
NO 4
NO 8
NO 16
NO 32
NO 64
NO 128
NO 256
NO 512
NO 1024
NO 2048
NO 4096
NO 8192
NO 16384
NO 32768
NO 65536
NO 131072
NO 262144
NO 524288
NO 1048576
NO 2097152
NO 4194304
NO 8388608
NO 16777216
NO 33554432
NO 67108864
NO 134217728
NO 268435456
NO 536870912
NO 1073741824
NO 2147483648
NO 42...

result:

ok 49 lines

Test #48:

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

input:

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

output:

NO 4
NO 3
NO 4
YES
YES
YES

result:

ok 6 lines

Test #49:

score: 25
Accepted
time: 2ms
memory: 14068kb

input:

14 26 1
2 3 0 1 1
3 4 1 1 0 0
4 3 1 1 0
5 3 4 1 3
6 5 1 4 5 1 5
7 5 3 1 3 6 3
8 3 5 6 1
9 4 7 6 1 8
10 3 9 6 1
11 3 6 8 0
12 5 9 10 8 0 7
13 3 12 11 0
10 5 10 1 5 13 11
7 4 13 13 11 1
3 3 1 4 11
13 5 1 12 9 12 8
3 4 0 12 2 2
4 3 0 6 3
8 3 11 12 0
5 5 10 0 12 4 2
5 5 11 0 4 2 2
5 4 2 13 1 10
5 3 4 1 ...

output:

YES
NO 4
NO 3
YES
YES
YES
YES
YES
YES
YES
YES
YES

result:

ok 12 lines

Test #50:

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

input:

14 23 1
2 4 0 1 0 1
3 3 0 0 1
4 4 1 1 0 1
5 5 1 3 1 0 0
6 4 1 5 2 0
7 5 6 4 3 6 0
8 5 3 3 6 1 4
9 4 7 8 1 6
10 5 5 5 9 6 1
11 5 0 8 8 8 8
12 3 8 11 0
13 5 0 8 10 10 9
4 5 13 12 9 10 0
8 3 0 10 10
2 4 3 1 12 5
8 5 13 0 13 4 3
5 4 11 1 4 8
9 4 8 4 0 11
11 4 8 3 4 1
12 3 4 1 1
9 4 9 5 9 1
10 4 9 9 6 0
...

output:

NO 17
NO 3
NO 4
NO 7
NO 26
YES
YES
YES
YES
YES
NO 6
YES

result:

ok 12 lines

Test #51:

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

input:

14 25 1
2 3 0 1 1
3 3 0 0 0
4 3 1 1 1
5 5 0 1 2 1 4
6 5 4 4 2 3 1
7 3 2 4 1
8 5 4 5 4 1 6
9 4 8 4 0 8
10 4 8 7 9 1
11 3 1 7 8
12 4 10 7 1 9
13 4 8 1 11 9
11 5 5 0 4 3 10
6 3 1 4 6
5 5 13 9 11 0 2
7 4 2 2 6 0
2 5 7 3 10 3 0
12 3 12 1 9
9 4 11 9 1 6
2 4 6 2 11 0
6 5 13 4 6 1 9
7 3 0 3 5
2 3 0 6 12
12 ...

output:

NO 3
NO 3
NO 3
NO 9
YES
NO 7
YES
YES
YES
NO 7
YES
YES

result:

ok 12 lines

Test #52:

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

input:

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

output:

NO 4
NO 4
YES
YES
NO 10
YES
YES
YES
YES

result:

ok 9 lines

Test #53:

score: 25
Accepted
time: 2ms
memory: 14052kb

input:

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

output:

NO 3
NO 3
NO 4
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES

result:

ok 13 lines

Test #54:

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

input:

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

output:

YES
YES
YES
NO 3
YES
YES
YES
YES
YES
YES
YES
YES
YES

result:

ok 13 lines

Test #55:

score: 25
Accepted
time: 2ms
memory: 13988kb

input:

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

output:

NO 3
YES
NO 3
YES
YES
YES
YES
YES
YES

result:

ok 9 lines

Test #56:

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

input:

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

output:

NO 4
NO 4
NO 4
NO 5
NO 13
NO 31
NO 13
NO 45
NO 47
NO 90
NO 95
NO 278
NO 323
NO 419
NO 788
NO 515
NO 1208

result:

ok 17 lines

Test #57:

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

input:

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

output:

NO 3
NO 3
NO 3
NO 11
NO 16
NO 20

result:

ok 6 lines

Test #58:

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

input:

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

output:

NO 190
NO 46
NO 22
NO 1022
NO 1534
NO 2
NO 510
NO 14
NO 30
NO 4
NO 126
NO 10
NO 62
NO 254
NO 382
NO 766
NO 94
NO 6

result:

ok 18 lines

Test #59:

score: 25
Accepted
time: 2ms
memory: 14208kb

input:

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

output:

NO 53
NO 242
NO 161
NO 728
NO 17
NO 1457
NO 4373
NO 485
NO 2186
NO 2
NO 5
NO 26
NO 80
NO 8

result:

ok 14 lines

Test #60:

score: 25
Accepted
time: 60ms
memory: 16628kb

input:

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

output:

NO 1
NO 2
NO 4
NO 5
NO 10
NO 20
NO 40
NO 80
NO 160
NO 320
NO 640
NO 960
NO 962
NO 1924
NO 3848
NO 7696
NO 15392
NO 30784
NO 61568
NO 123136
NO 246272
NO 38485
NO 76970
NO 153940
NO 307880
NO 369448
NO 738896
NO 1477792
NO 2955584
NO 5911168
NO 11822336
NO 11883904
NO 23767808
NO 3853
NO 7706
NO 1541...

result:

ok 40 lines

Test #61:

score: 25
Accepted
time: 56ms
memory: 16372kb

input:

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

output:

NO 1
NO 2
NO 4
NO 8
NO 16
NO 32
NO 2
NO 4
NO 260
NO 292
NO 584
NO 840
NO 1680
NO 3360
NO 6720
NO 13440
NO 13472
NO 26944
NO 53888
NO 67328
NO 134656
NO 26945
NO 32
NO 8
NO 16
NO 32
NO 64
NO 128
NO 256
NO 94272
NO 94304
NO 188608
NO 377216
NO 377224
NO 377225
NO 94400
YES
YES
YES
YES

result:

ok 40 lines

Test #62:

score: 25
Accepted
time: 2ms
memory: 11900kb

input:

12 20 1
2 3 1 11 11
2 2 0 11
3 4 1 8 8 8
3 2 0 8
4 5 1 10 10 10 10
4 2 0 10
5 4 1 3 3 3
5 2 0 3
6 4 1 2 2 2
6 2 0 2
7 3 1 1 1
7 2 0 1
8 5 1 6 6 6 6
8 2 0 6
9 4 1 5 5 5
9 2 0 5
10 5 1 9 9 9 9
10 2 0 9
11 4 1 7 7 7
11 2 0 7
2 0 0

output:

NO 8
NO 42
NO 514
NO 80
NO 10
NO 2
NO 26
NO 128
NO 242
NO 4

result:

ok 10 lines

Test #63:

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

input:

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

output:

NO 4
NO 4
NO 4
YES
NO 6
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES

result:

ok 17 lines

Test #64:

score: 25
Accepted
time: 2ms
memory: 14036kb

input:

14 25 1
2 4 0 0 0 0
3 4 1 0 0 1
4 4 0 0 0 0
5 4 1 2 0 2
6 4 2 5 1 3
7 3 5 3 1
8 4 5 7 0 7
9 4 1 6 7 4
10 3 0 6 6
11 4 10 0 8 10
12 4 7 0 7 9
13 3 12 1 8
6 3 11 0 2
8 3 13 10 0
7 5 11 12 1 7 5
5 5 9 2 6 1 6
11 3 12 1 4
8 5 0 9 9 5 2
11 5 6 2 2 11 1
2 3 13 1 5
11 4 6 7 1 4
12 3 11 9 1
13 4 10 0 9 7
3 ...

output:

NO 4
NO 4
NO 4
NO 10
NO 29
YES
YES
YES
NO 59
NO 24
NO 19
YES

result:

ok 12 lines

Test #65:

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

input:

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

output:

NO 22
NO 2
NO 9
NO 14
NO 16
NO 8
NO 28
NO 24
NO 6
NO 3
NO 18
NO 5
NO 7
NO 4
NO 26
NO 12
NO 20
NO 10

result:

ok 18 lines

Test #66:

score: 25
Accepted
time: 6ms
memory: 14760kb

input:

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

output:

NO 4
NO 4
NO 4
NO 11
NO 9
NO 39
NO 9
NO 24
NO 23
NO 65
NO 90
NO 100
NO 280
NO 214

result:

ok 14 lines

Test #67:

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

input:

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

output:

NO 4
NO 3
NO 3
NO 13
NO 7
NO 18
NO 25
NO 47
NO 69
NO 51
NO 99
NO 241
NO 391
NO 112
NO 392
NO 70
NO 687
NO 1246

result:

ok 18 lines

Test #68:

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

input:

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

output:

NO 1
NO 2
NO 4
NO 8
NO 16
NO 32
NO 64
NO 128
NO 256
NO 512
NO 1024
NO 2048
NO 4096
NO 8192
NO 16384
NO 32768
NO 65536
NO 131072
NO 262144
NO 524288
NO 1048576
NO 2097152
NO 4194304
NO 8388608
NO 16777216
NO 33554432
NO 67108864
NO 134217728
NO 268435456
NO 536870912
NO 1073741824
NO 2147483648
NO 42...

result:

ok 47 lines

Test #69:

score: 25
Accepted
time: 50ms
memory: 16932kb

input:

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

output:

NO 1
NO 2
NO 4
NO 8
NO 16
NO 32
NO 2
NO 4
NO 260
NO 292
NO 584
NO 840
NO 1680
NO 3360
NO 6720
NO 13440
NO 13472
NO 26944
NO 53888
NO 67328
NO 134656
NO 26945
NO 32
NO 8
NO 16
NO 32
NO 64
NO 128
NO 256
NO 94272
NO 94304
NO 188608
NO 377216
NO 377217
NO 377218
NO 94400
YES
YES
YES
YES

result:

ok 40 lines

Subtask #4:

score: 32
Accepted

Test #70:

score: 32
Accepted
time: 1ms
memory: 7744kb

input:

6 6 2
2 2 0 1
3 3 2 0 0
3 2 1 3
4 4 0 3 1 2
5 2 2 1
5 1 5
2 1 1
5 0 0 1 0 0

output:

NO 2
NO 4
NO 9
YES

result:

ok 4 lines

Test #71:

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

input:

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

output:

NO 2
NO 3
NO 6
NO 10
NO 14
NO 22
NO 30
NO 46
NO 62
NO 94
NO 126
NO 190
NO 254
NO 382
NO 510
NO 766
NO 1022
NO 1534
NO 2046
NO 3070

result:

ok 20 lines

Test #72:

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

input:

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

output:

NO 1
YES
YES
YES
YES

result:

ok 5 lines

Test #73:

score: 32
Accepted
time: 2ms
memory: 13860kb

input:

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

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES

result:

ok 48 lines

Test #74:

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

input:

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

output:

NO 17
NO 4
NO 4
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES

result:

ok 13 lines

Test #75:

score: 32
Accepted
time: 2ms
memory: 16204kb

input:

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

output:

NO 1
NO 2
NO 4
NO 8
NO 16
NO 32
NO 64
NO 128
NO 256
NO 512
NO 1024
NO 2048
NO 4096
NO 8192
NO 16384
NO 32768
NO 65536
NO 131072
NO 262144
NO 524288
NO 1048576
NO 2097152
NO 4194304
NO 8388608
NO 16777216
NO 33554432
NO 67108864
NO 134217728
NO 268435456
NO 536870912
NO 1073741824
NO 2147483648
NO 42...

result:

ok 49 lines

Test #76:

score: 32
Accepted
time: 2ms
memory: 14248kb

input:

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

output:

NO 3
NO 15
YES
YES
YES
YES
YES
YES
YES
YES

result:

ok 10 lines

Test #77:

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

input:

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

output:

NO 4
YES
NO 3
NO 19
NO 8
YES
YES
YES
YES
YES
NO 13
YES
YES

result:

ok 13 lines

Test #78:

score: 32
Accepted
time: 2ms
memory: 12024kb

input:

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

output:

NO 12
NO 4
NO 3
NO 8
YES
YES

result:

ok 6 lines

Test #79:

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

input:

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

output:

NO 4
NO 4
NO 4
NO 27
NO 13
NO 18
NO 41
NO 36
NO 142

result:

ok 9 lines

Test #80:

score: 32
Accepted
time: 2ms
memory: 14068kb

input:

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

output:

NO 4
NO 4
YES
NO 6
NO 12
YES
NO 23

result:

ok 7 lines

Test #81:

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

input:

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

output:

NO 4
YES
YES
YES
NO 6
YES
YES
YES
YES
YES
YES
YES
YES
YES

result:

ok 14 lines

Test #82:

score: 32
Accepted
time: 2ms
memory: 14112kb

input:

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

output:

NO 4
NO 4
NO 4
NO 6
NO 15
YES
NO 9
YES
YES
YES
YES

result:

ok 11 lines

Test #83:

score: 32
Accepted
time: 2ms
memory: 14052kb

input:

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

output:

NO 4
NO 4
NO 4
NO 77
NO 6
NO 18
NO 13
NO 31

result:

ok 8 lines

Test #84:

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

input:

14 25 2
2 4 0 1 1 1
3 4 0 1 1 0
4 4 1 1 0 1
5 3 4 1 1
6 4 5 1 4 0
7 3 6 6 0
8 3 7 0 4
9 4 7 5 0 6
10 4 7 1 7 5
11 3 0 7 9
12 3 7 0 11
13 4 9 0 8 10
10 5 8 5 4 1 7
6 3 12 1 7
6 5 10 5 0 12 10
6 4 13 1 4 7
4 4 12 12 4 0
11 3 9 8 1
10 3 8 11 1
9 5 1 3 12 3 3
10 4 10 6 3 0
8 4 4 5 0 12
4 5 2 7 5 0 13
12...

output:

NO 4
NO 4
NO 4
NO 6
NO 12
NO 25
YES
YES
YES
YES
YES
YES

result:

ok 12 lines

Test #85:

score: 32
Accepted
time: 3ms
memory: 14292kb

input:

14 25 2
2 4 0 1 0 0
3 4 0 1 0 1
4 4 0 0 0 1
5 3 2 3 0
6 3 3 4 1
7 4 5 5 0 5
8 4 0 3 5 7
9 4 6 5 4 0
10 4 7 0 9 8
11 4 10 10 10 1
12 3 10 1 7
13 3 9 10 0
2 3 12 1 7
9 3 6 9 1
5 4 9 13 1 9
6 5 8 7 7 1 13
2 4 12 2 10 1
13 3 10 7 0
10 5 7 0 8 3 8
13 3 0 10 9
12 3 0 7 9
8 5 9 2 3 1 5
11 5 9 7 12 12 0
8 3...

output:

NO 4
NO 4
NO 4
NO 9
NO 245
NO 28
NO 42
NO 259
NO 117
NO 352
NO 146
NO 146

result:

ok 12 lines

Test #86:

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

input:

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

output:

NO 1
NO 5
NO 13
NO 29
NO 61
NO 125
NO 253
NO 509
NO 1021
NO 2045
NO 4093
NO 8189
NO 16381
NO 32765
NO 65533
NO 131069
NO 262141
NO 524285
NO 1048573
NO 2097149
NO 4194301
NO 8388605
NO 16777213
NO 33554429
NO 67108861
NO 134217725
NO 268435453
NO 536870909
NO 1073741821
NO 2147483645
NO 4294967293
N...

result:

ok 47 lines

Subtask #5:

score: 18
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Test #87:

score: 18
Accepted
time: 6ms
memory: 12724kb

input:

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

output:

NO 2
NO 3
NO 4
NO 6
NO 8
NO 10
NO 12
NO 17
NO 20
NO 24
NO 28
NO 38
NO 44
NO 52
NO 60
NO 80
NO 92
NO 108
NO 124
NO 164

result:

ok 20 lines

Test #88:

score: 18
Accepted
time: 1ms
memory: 7992kb

input:

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

output:

NO 1
NO 2
NO 3
YES
YES

result:

ok 5 lines

Test #89:

score: 18
Accepted
time: 1ms
memory: 5936kb

input:

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

output:

NO 1
NO 2
NO 3
NO 4
NO 5

result:

ok 5 lines

Test #90:

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

input:

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

output:

YES
YES
NO 4
YES
YES
YES
YES
YES
NO 9
YES
YES
YES
YES

result:

ok 13 lines

Test #91:

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

input:

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

output:

NO 1
NO 2
NO 4
NO 8
NO 16
NO 32
NO 64
NO 128
NO 256
NO 512
NO 1024
NO 2048
NO 4096
NO 8192
NO 16384
NO 32768
NO 65536
NO 131072
NO 262144
NO 524288
NO 1048576
NO 2097152
NO 4194304
NO 8388608
NO 16777216
NO 33554432
NO 67108864
NO 134217728
NO 268435456
NO 536870912
NO 1073741824
NO 2147483648
NO 42...

result:

ok 49 lines

Test #92:

score: 18
Accepted
time: 22ms
memory: 14244kb

input:

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

output:

NO 4
NO 4
NO 4
NO 10
NO 25
NO 30
NO 21

result:

ok 7 lines

Test #93:

score: 18
Accepted
time: 14ms
memory: 12756kb

input:

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

output:

NO 4
NO 3
NO 4
NO 14
NO 16
NO 8

result:

ok 6 lines

Test #94:

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

input:

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

output:

NO 3
NO 3
NO 4
NO 7
NO 12
YES
NO 13
YES
YES
NO 17
YES
YES
YES
YES

result:

ok 14 lines

Test #95:

score: 18
Accepted
time: 2ms
memory: 14088kb

input:

14 26 8
2 3 0 1 0
3 3 1 1 0
4 3 0 1 0
5 3 2 0 0
6 4 2 4 0 5
7 3 0 4 6
8 4 7 6 3 1
9 5 8 5 4 1 7
10 4 8 0 8 7
11 5 1 8 9 9 7
12 4 10 0 9 8
13 3 12 11 1
11 5 8 7 4 1 7
4 3 12 7 1
5 5 13 2 5 1 13
7 4 1 2 11 8
5 3 3 0 10
5 3 1 12 12
2 4 10 11 10 0
3 3 9 1 8
8 4 6 0 13 13
4 5 9 11 0 6 6
3 5 5 5 13 13 1
1...

output:

NO 3
NO 3
NO 3
NO 5
YES
YES
YES
YES
YES
YES
YES
YES

result:

ok 12 lines

Test #96:

score: 18
Accepted
time: 2ms
memory: 14472kb

input:

14 24 7
2 4 0 1 1 0
3 3 1 1 0
4 3 1 1 1
5 5 4 1 0 0 1
6 3 0 5 5
7 4 4 0 2 3
8 3 5 3 0
9 5 8 6 1 7 6
10 4 6 9 1 6
11 4 8 0 6 6
12 5 11 11 7 0 11
13 4 9 10 1 8
5 5 0 8 12 11 2
6 4 7 3 7 0
8 3 0 6 9
12 4 1 6 2 3
10 5 0 9 9 13 6
11 3 9 0 5
7 5 7 8 2 11 1
3 5 0 7 2 6 5
11 3 10 0 5
6 5 2 7 0 10 11
3 4 0 4...

output:

NO 4
NO 3
NO 3
NO 7
YES
YES
NO 11
YES
YES
YES
YES
YES

result:

ok 12 lines

Test #97:

score: 18
Accepted
time: 3ms
memory: 14448kb

input:

7 23 9
2 4 0 0 1 0
3 3 1 1 0
4 4 1 1 1 1
5 5 3 1 4 3 4
6 5 4 2 2 0 3
4 5 2 4 5 4 0
4 5 6 2 1 4 2
4 4 0 2 2 5
3 4 4 1 5 2
4 4 6 1 3 6
6 5 6 4 0 6 5
6 4 0 5 6 6
6 5 3 0 4 5 3
6 4 4 1 5 5
4 4 6 6 6 0
3 5 0 4 6 5 6
5 3 5 6 1
5 4 5 0 5 6
4 4 4 2 1 5
6 5 0 6 6 6 6
3 3 0 3 3
5 4 2 2 2 0
3 5 3 4 1 6 5
5 0 1...

output:

NO 4
NO 3
NO 22
NO 13
NO 49

result:

ok 5 lines

Test #98:

score: 18
Accepted
time: 3ms
memory: 16076kb

input:

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

output:

NO 4
NO 4
NO 3
NO 8
NO 16
NO 36
YES
YES
YES
YES
YES
YES
YES
YES
NO 25
NO 8

result:

ok 16 lines

Test #99:

score: 18
Accepted
time: 6ms
memory: 15044kb

input:

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

output:

NO 3
NO 3
NO 3
NO 6
NO 11
NO 22
NO 51
NO 58
NO 73
NO 11
NO 85
NO 85
NO 89
NO 97
NO 69
NO 240
NO 7

result:

ok 17 lines

Test #100:

score: 18
Accepted
time: 3ms
memory: 14580kb

input:

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

output:

NO 4
NO 3
NO 4
NO 11
NO 3
NO 31
YES
YES
YES
YES
YES

result:

ok 11 lines

Test #101:

score: 18
Accepted
time: 3ms
memory: 12216kb

input:

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

output:

NO 3
NO 3
NO 4
NO 3
NO 5
NO 7
NO 11
NO 20
NO 31
NO 49
NO 39
NO 54
NO 165
NO 51

result:

ok 14 lines

Test #102:

score: 18
Accepted
time: 32ms
memory: 14708kb

input:

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

output:

NO 3
NO 3
NO 3
NO 7
NO 5
NO 11
NO 14
NO 36
NO 87
NO 12

result:

ok 10 lines

Test #103:

score: 18
Accepted
time: 4ms
memory: 16840kb

input:

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

output:

NO 4
NO 4
NO 3
NO 7
NO 13
NO 24
NO 11
NO 28
NO 49
NO 30
NO 130
NO 142
NO 259
NO 50
NO 271
NO 674
NO 569

result:

ok 17 lines

Test #104:

score: 18
Accepted
time: 7ms
memory: 15204kb

input:

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

output:

NO 4
NO 3
NO 4
NO 9
NO 8
NO 20
NO 22
NO 60
NO 49
NO 121
NO 144
NO 375
NO 194
NO 339
NO 1103
NO 70

result:

ok 16 lines

Test #105:

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

input:

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

output:

NO 1
NO 10
NO 28
NO 64
NO 136
NO 280
NO 568
NO 1144
NO 2296
NO 4600
NO 9208
NO 18424
NO 36856
NO 73720
NO 147448
NO 294904
NO 589816
NO 1179640
NO 2359288
NO 4718584
NO 9437176
NO 18874360
NO 37748728
NO 75497464
NO 150994936
NO 301989880
NO 603979768
NO 1207959544
NO 2415919096
NO 4831838200
NO 966...

result:

ok 47 lines

Test #106:

score: 18
Accepted
time: 22ms
memory: 16856kb

input:

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

output:

NO 2
NO 3
NO 4
NO 7
NO 8
NO 9
NO 15
NO 23
NO 30
NO 33
NO 12
NO 7
NO 19
NO 23
NO 31
NO 62
NO 74
NO 82
NO 156
NO 179
NO 209
NO 232
NO 294
NO 301
NO 302
NO 596
NO 619
NO 295
NO 891
NO 892
NO 894
NO 917
NO 919
NO 1075
NO 1369
NO 2286
NO 2298
NO 2305
NO 2306
NO 2307

result:

ok 40 lines

Test #107:

score: 18
Accepted
time: 27ms
memory: 15016kb

input:

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

output:

NO 2
NO 3
NO 4
NO 5
NO 9
NO 10
NO 15
NO 24
NO 29
NO 53
NO 62
NO 124
NO 148
NO 150
NO 151
NO 151
NO 275
NO 279
NO 9793
NO 580
NO 633
NO 1213
NO 1364
NO 1379
NO 1658
NO 429
NO 453
NO 604
NO 657
NO 808
NO 932
NO 933
NO 1081
NO 1085
NO 2625
NO 2635
NO 4293
NO 4417
NO 5498
NO 9791

result:

ok 40 lines