QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#404566#5707. Viruseszhaohaikun100 ✓41ms9880kbC++204.9kb2024-05-04 08:49:292024-05-04 08:49:31

Judging History

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

  • [2024-05-04 08:49:31]
  • 评测
  • 测评结果:100
  • 用时:41ms
  • 内存:9880kb
  • [2024-05-04 08:49:29]
  • 提交

answer

#pragma GCC optimize(2)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline","fast-math","unroll-loops","no-stack-protector")
#pragma GCC diagnostic error "-fwhole-program"
#pragma GCC diagnostic error "-fcse-skip-blocks"
#pragma GCC diagnostic error "-funsafe-loop-optimizations"
// MagicDark
#include <bits/stdc++.h>
#define debug cerr << "\033[32m[" << __LINE__ << "]\033[0m "
#define SZ(x) ((int) x.size() - 1)
#define all(x) x.begin(), x.end()
#define ms(x, y) memset(x, y, sizeof x)
#define F(i, x, y) for (int i = (x); i <= (y); i++)
#define DF(i, x, y) for (int i = (x); i >= (y); i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template <typename T> T& chkmax(T& x, T y) {return x = max(x, y);}
template <typename T> T& chkmin(T& x, T y) {return x = min(x, y);}
// template <typename T> T& read(T &x) {
// 	x = 0; int f = 1; char c = getchar();
// 	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
// 	for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
// 	return x *= f;
// }
const int N = 110, M = 55;
int sg, n, m, x[N], y[N], t[N][N], s[N];
vector <int> p[N];
pair <int, int> u[N];
string o[N];
struct ACAM {
	int son[N][2], tot, link[N];
	bool vis[N];
	int ins(int num, int f) {
		if (!son[num][f]) son[num][f] = ++tot;
		return son[num][f];
	}
	void build() {
		queue <int> q;
		F(i, 0, 1)
			if (son[0][i]) q.push(son[0][i]);
		while (q.size()) {
			int x = q.front(); q.pop();
			F(i, 0, 1)
				if (son[x][i]) {
					link[son[x][i]] = son[link[x]][i];
					q.push(son[x][i]);
				} else son[x][i] = son[link[x]][i];
		}
	}
} AC;
ull f[N][M][M], g[N][M][M];
bool visf[N][M][M], visg[N][M][M];
signed main() {
	cin.tie(0) -> sync_with_stdio(0); // don't use puts
	ms(f, 127), ms(g, 127);
	ull inf = f[0][0][0];
	// debug << inf << endl;
	cin >> sg >> n >> m;
	F(i, 1, n) {
		cin >> x[i] >> y[i];
		s[i] = s[i - 1] + y[i];
		F(j, 1, y[i]) {
			cin >> t[i][j];
			u[s[i - 1] + j] = make_pair(i, j);
			p[t[i][j]].push_back(s[i - 1] + j);
		}
	}
	F(i, 1, m) {
		int k;
		cin >> k;
		F(j, 1, k) {
			char c;
			cin >> c;
			o[i] += c;
		}
	}
	sort(o + 1, o + m + 1, [&] (const string& x, const string& y) {
		return x.size() < y.size();
	});
	F(i, 1, m) {
		string st = "";
		int num = 0;
		bool flag = false;
		for (char j: o[i]) {
			st += j;
			F(k, 1, i - 1) {
				if (o[k].size() > st.size()) break;
				if (st.substr(SZ(st) - SZ(o[k]), o[k].size()) == o[k]) {
					flag = true;
					break;
				}
			}
			if (flag) break;
			num = AC.ins(num, j - '0');
		}
		if (!flag) AC.vis[num] = true;//, debug << i << " " << num << endl;
	}
	AC.build();
	priority_queue <tuple <ll, int, int, int>, vector <tuple <ll, int, int, int>>, greater <tuple <ll, int, int, int>>> q;
	F(i, 1, n)
		F(j, 0, AC.tot) g[s[i - 1]][j][j] = 0, visg[s[i - 1]][j][j] = true;
	F(i, 0, AC.tot) {
		if (AC.vis[i]) continue;
		if (!AC.vis[AC.son[i][0]]) q.emplace(f[0][i][AC.son[i][0]] = 1, 0, i, AC.son[i][0]);
		if (!AC.vis[AC.son[i][1]]) q.emplace(f[1][i][AC.son[i][1]] = 1, 1, i, AC.son[i][1]);
	}
	while (q.size()) {
		auto [v, x, y, z] = q.top(); q.pop();
		if (x >= 0) {
			if (visf[x][y][z]) continue;
			visf[x][y][z] = true;
			// debug << x << " " << y << " " << z << " " << f[x][y][z] << endl;
			for (int i: p[x]) {
				if (u[i].second == ::y[u[i].first]) {
					// debug << " -> " << ::x[u[i].first] << endl;
					F(j, 0, AC.tot)
						if (visg[i - 1][j][y] && f[x][y][z] + g[i - 1][j][y] < f[::x[u[i].first]][j][z])
							q.emplace(f[::x[u[i].first]][j][z] = f[x][y][z] + g[i - 1][j][y], ::x[u[i].first], j, z);
				} else {
					F(j, 0, AC.tot)
						if (visg[i - 1][j][y] && f[x][y][z] + g[i - 1][j][y] < g[i][j][z]) {
							// debug << i << " " << j << " " << z << " " << x << " " << y << " " << z << endl;
							q.emplace(g[i][j][z] = f[x][y][z] + g[i - 1][j][y], - i, j, z);
						}
				}
			}
		} else {
			x *= -1;
			if (visg[x][y][z]) continue;
			visg[x][y][z] = true;
			assert(u[x].second != ::y[u[x].first]);
			int i = t[u[x].first][u[x].second + 1];
			if (u[x].second + 1 == ::y[u[x].first]) {
				F(j, 0, AC.tot)
					if (visf[i][z][j] && g[x][y][z] + f[i][z][j] < f[::x[u[x].first]][y][j]) {
						// if (::x[u[x].first] == 5) debug << x << " " << u[x].first << " " << u[x].second << " " << y << " " << z << " " << j << endl;
						q.emplace(f[::x[u[x].first]][y][j] = g[x][y][z] + f[i][z][j], ::x[u[x].first], y, j);
					}
			} else {
				F(j, 0, AC.tot)
					if (visf[i][z][j] && g[x][y][z] + f[i][z][j] < g[x + 1][y][j])
						q.emplace(g[x + 1][y][j] = g[x][y][z] + f[i][z][j], - (x + 1), y, j);
			}
		}
	}
	F(i, 2, sg - 1) {
		ull ans = inf;
		F(j, 0, AC.tot) {
			// if (i == 5) debug << j << " " << f[i][0][j] << endl;
			chkmin(ans, f[i][0][j]);
		}
		if (ans == inf) cout << "YES\n";
		else cout << "NO " << ans << '\n';
	}
	return 0;
}
/* why?
*/

詳細信息

Subtask #1:

score: 11
Accepted

Test #1:

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

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: 0ms
memory: 9028kb

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: 2ms
memory: 9108kb

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: 2ms
memory: 9420kb

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: 2ms
memory: 9292kb

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: 2ms
memory: 9096kb

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: 9308kb

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: 2ms
memory: 9400kb

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: 0ms
memory: 9164kb

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: 9284kb

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: 9164kb

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: 9108kb

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: 9076kb

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: 9160kb

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: 9076kb

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: 2ms
memory: 9164kb

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: 2ms
memory: 9112kb

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: 0ms
memory: 9148kb

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: 2ms
memory: 9116kb

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: 0ms
memory: 9552kb

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: 9360kb

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: 2ms
memory: 9228kb

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: 2ms
memory: 9180kb

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: 9468kb

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: 2ms
memory: 9428kb

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: 9024kb

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: 0ms
memory: 9152kb

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: 9024kb

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: 9136kb

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: 2ms
memory: 8896kb

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: 9424kb

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: 0ms
memory: 9136kb

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: 2ms
memory: 8984kb

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: 8976kb

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: 0ms
memory: 8948kb

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: 2ms
memory: 9456kb

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: 2ms
memory: 9208kb

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: 0ms
memory: 9164kb

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: 8852kb

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: 9072kb

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: 2ms
memory: 9216kb

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: 0ms
memory: 8860kb

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: 0ms
memory: 9388kb

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: 0ms
memory: 9048kb

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: 9432kb

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: 2ms
memory: 8996kb

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: 41ms
memory: 9400kb

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: 9228kb

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: 9188kb

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: 2ms
memory: 8960kb

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: 9332kb

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: 2ms
memory: 9032kb

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: 0ms
memory: 9016kb

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: 2ms
memory: 9160kb

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: 9428kb

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: 3ms
memory: 9148kb

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: 9096kb

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: 9420kb

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: 0ms
memory: 9120kb

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: 31ms
memory: 9472kb

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: 37ms
memory: 9740kb

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: 8992kb

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: 9016kb

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: 3ms
memory: 9224kb

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: 9060kb

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: 4ms
memory: 9192kb

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: 3ms
memory: 9304kb

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: 9340kb

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: 31ms
memory: 9188kb

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: 2ms
memory: 9032kb

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: 2ms
memory: 9316kb

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: 2ms
memory: 9344kb

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: 9332kb

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: 9020kb

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: 9264kb

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: 9000kb

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: 9076kb

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: 9472kb

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: 9164kb

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: 0ms
memory: 9272kb

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: 2ms
memory: 9040kb

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: 0ms
memory: 8988kb

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: 0ms
memory: 9148kb

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: 2ms
memory: 8984kb

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: 2ms
memory: 9176kb

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: 9212kb

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: 5ms
memory: 9448kb

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: 2ms
memory: 8888kb

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: 0ms
memory: 9104kb

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: 9620kb

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: 2ms
memory: 9500kb

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: 15ms
memory: 9588kb

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: 8ms
memory: 9244kb

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: 2ms
memory: 9080kb

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: 8972kb

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: 9020kb

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: 5ms
memory: 9444kb

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: 2ms
memory: 9576kb

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: 3ms
memory: 9436kb

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: 0ms
memory: 9396kb

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: 0ms
memory: 9124kb

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: 31ms
memory: 9816kb

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: 0ms
memory: 9672kb

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: 4ms
memory: 9224kb

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: 9288kb

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: 10ms
memory: 9344kb

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: 18ms
memory: 9880kb

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