QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#460496#8688. QuartetskarunaAC ✓3ms3872kbC++205.1kb2024-07-01 18:17:482024-07-01 18:17:49

Judging History

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

  • [2024-07-01 18:17:49]
  • 评测
  • 测评结果:AC
  • 用时:3ms
  • 内存:3872kb
  • [2024-07-01 18:17:48]
  • 提交

answer

#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#define ff first
#define ss second
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int SZ = 100;
namespace dinic {
	struct edge {
		int v, c, d;
	};
	vector<edge> g[SZ];

	int src, snk, fsrc, fsnk;
	void init_lrflow(int _src, int _snk, int _fsrc, int _fsnk) {
		for (int i = 0; i < SZ; i++) {
			g[i].clear();
		}
		src = _src; snk = _snk; fsrc = _fsrc, fsnk = _fsnk;

		g[snk].push_back({src, (int)1e9, (int)g[src].size()});
		g[src].push_back({snk, 0, (int)g[snk].size() - 1});
	}

	void add_edge(int u, int v, int l, int r) {
		if (l != r) {
			g[u].push_back({v, r - l, (int)g[v].size()});
			g[v].push_back({u, 0, (int)g[u].size() - 1});
		}
		if (l != 0) {
			g[fsrc].push_back({v, l, (int)g[v].size()});
			g[v].push_back({v, 0, (int)g[fsrc].size() - 1});
		
			g[u].push_back({fsnk, l, (int)g[fsnk].size()});
			g[fsnk].push_back({u, 0, (int)g[u].size() - 1});
		}
	}

	int ds[SZ];
	void bfs() {
		fill(ds, ds + SZ, -1);
		queue<int> Q;
		Q.push(fsrc);

		while (!Q.empty()) {
			int v = Q.front();
			Q.pop();

			for (auto &e : g[v]) if (e.c > 0) {
				if (ds[e.v] == -1) {
					ds[e.v] = ds[v] + 1;
					Q.push(e.v);
				}
			}
		}
	}

	int sp[SZ];
	int dfs(int v, int f) {
		if (v == fsnk) {
			return f;
		}

		while (sp[v] < g[v].size()) {
			auto &e = g[v][sp[v]++];

			if (e.c == 0 || ds[e.v] != ds[v] + 1) continue;
			int h = dfs(e.v, min(f, e.c));

			if (h > 0) {
				e.c -= h;
				g[e.v][e.d].c += h;
				return h;
			}
		}
		return 0;
	}

	bool run_lrflow() {
		while (true) {
			bfs();

			int f = 0;
			fill(sp, sp + SZ, 0);
			while (true) {
				int g = dfs(fsrc, 1e9);
				if (g == 0) break;

				f += g;
			}
			if (f == 0) break;
		}

		for (auto &e : g[fsrc]) {
			if (e.c != 0) {
				return false;
			}
		}
		return true;
	}
}

int main() {
	cin.tie(0); ios_base::sync_with_stdio(0);
	
	int n;
	cin >> n;

	int t[n], x[n], y[n], sk[n], res[n];

	for (int i = 0; i < n; i++) {
		int a; string S;
		cin >> a >> S;

		if (S == "A") {
			int b; string C, T;
			cin >> b >> C >> T;
			
			t[i] = 0; x[i] = a - 1; y[i] = b - 1;
			sk[i] = 4 * (C[0] - '1') + (C[1] - 'A');
			res[i] = (T == "yes");
		}
		else {
			int b; cin >> b;

			t[i] = 1; x[i] = a - 1; y[i] = b - 1;
		}
	}

	int pos[32][n + 1];
	bool grp[4][8];
	bool dont[4][32];

	int ss = 1, ee = n + 1;
	while (ss < ee) {
		int k = (ss + ee) / 2;

		for (int g = 0; g < 32; g++) pos[g][0] = -1;
		for (int p = 0; p < 4; p++) for (int s = 0; s < 8; s++) grp[p][s] = false;
		for (int p = 0; p < 4; p++) for (int g = 0; g < 32; g++) dont[p][g] = false;

		bool flag = true;
		for (int i = 0; i < k; i++) {
			for (int g = 0; g < 32; g++) pos[g][i + 1] = pos[g][i];

			if (t[i] == 0 && res[i]) {
				int g = sk[i];
				if (pos[g][i + 1] == -1) { // first discovered
					for (int j = 0; j <= i; j++) pos[g][j] = y[i];
					pos[g][i + 1] = x[i];
				}
				else { // already discovered
					if (pos[g][i] != y[i]) {
						flag = false;
						break;
					}
					else pos[g][i + 1] = x[i];
				}
			}
			else if (t[i] == 1) {
				for (int g = 4 * y[i]; g < 4 * y[i] + 4; g++) {
					if (pos[g][i] == -1) {
						for (int j = 0; j <= i + 1; j++) pos[g][j] = x[i];
					}
					else {
						if (pos[g][i] != x[i]) {
							flag = false;
							break;
						}
					}
				}
			}
		}
		if (!flag) {
			ee = k; continue;
		}

		for (int i = 0; i < k; i++) {
			if (t[i] == 0) {
				bool has = false;
				for (int g = 4 * (sk[i] / 4); g < 4 * (sk[i] / 4) + 4; g++) if (pos[g][i] == x[i]) has = true;
				if (!has) grp[x[i]][sk[i] / 4] = true;

				if (!res[i]) {
					int g = sk[i];
					if (pos[g][i] == -1) dont[y[i]][g] = true;
					else {
						if (pos[g][i] == y[i]) {
							flag = false;
							break;
						}
					}
				}
			}
		}
		if (!flag) {
			ee = k; continue;
		}

		dinic::init_lrflow(0, 69, 70, 71);

		int cnt[4] = {};
		for (int g = 0; g < 32; g++) {
			if (pos[g][0] != -1) {
				cnt[pos[g][0]]++;
			}
		}
		for (int p = 0; p < 4; p++) {
			if (cnt[p] > 8) {
				flag = false;
				break;
			}
		}
		if (!flag) {
			ee = k; continue;
		}

		for (int g = 0; g < 32; g++) {
			if (pos[g][0] == -1) {
				dinic::add_edge(0, 1 + g, 1, 1);
			}
		}
		for (int s = 0; s < 8; s++) {
			for (int p = 0; p < 4; p++) {
				for (int k = 0; k < 4; k++) {
					if (!dont[p][4 * s + k]) dinic::add_edge(1 + (4 * s + k), 33 + (4 * s + p), 0, 1);
				}
			}
		}

		for (int p = 0; p < 4; p++) {
			for (int s = 0; s < 8; s++) {
				if (grp[p][s]) {
					dinic::add_edge(33 + (4 * s + p), 65 + p, 1, 8);
				}
				else {
					dinic::add_edge(33 + (4 * s + p), 65 + p, 0, 8);
				}
			}
			dinic::add_edge(65 + p, 69, 8 - cnt[p], 8 - cnt[p]);
		}

		flag = dinic::run_lrflow();
		if (flag) {
			ss = k + 1;
		}
		else {
			ee = k;
		}
	}
	if (ss == n + 1) {
		cout << "yes\n";
	}
	else {
		cout << "no\n";
		cout << ss << '\n';
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

27
1 A 2 7A yes
1 Q 7
1 A 2 1A no
2 A 1 3A no
1 A 2 1B no
2 A 1 3A no
1 A 2 1C no
2 A 1 3A no
1 A 2 1D no
2 A 1 3A no
1 A 2 2A no
2 A 1 3A no
1 A 2 2B no
2 A 1 3A no
1 A 2 2C no
2 A 1 3A no
1 A 2 2D no
2 A 1 3A no
1 A 3 2A no
3 A 2 3A yes
3 Q 3
3 Q 4
3 A 4 1A no
4 A 2 5A yes
4 Q 5
4 Q 6
4 A 3 2A no

output:

no
26

result:

ok 2 lines

Test #2:

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

input:

10
1 A 2 1A no
2 A 1 1A no
1 A 2 2A no
2 A 1 1A no
1 A 2 3A no
2 A 1 1A no
1 A 2 4A no
2 A 1 1A no
1 Q 5
1 A 2 6A no

output:

no
10

result:

ok 2 lines

Test #3:

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

input:

11
1 A 2 1A no
2 A 1 1A no
1 A 2 2A no
2 A 1 1A no
1 A 2 3A no
2 A 1 1A no
1 A 2 4A no
2 A 1 1A no
1 A 2 5A no
2 A 1 1A no
1 Q 6

output:

no
11

result:

ok 2 lines

Test #4:

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

input:

7
1 A 2 1A no
2 A 1 1A no
1 A 2 1B no
2 A 1 1A no
1 A 2 1C no
2 A 1 1A no
1 A 2 1D no

output:

no
7

result:

ok 2 lines

Test #5:

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

input:

10
1 A 2 1A no
2 A 1 1A no
1 A 2 2A no
2 A 1 1A no
1 A 2 3A no
2 A 1 1A no
1 A 2 4A no
2 A 1 1A no
1 Q 5
1 A 2 6A yes

output:

no
10

result:

ok 2 lines

Test #6:

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

input:

14
1 A 2 1A no
2 A 1 1A no
1 A 2 2A yes
1 A 2 2B no
2 A 1 1A no
1 A 2 3A yes
1 A 2 3B no
2 A 1 1A no
1 A 2 4A yes
1 A 2 4B no
2 A 1 1A no
1 A 2 5A no
2 A 1 1A no
1 Q 6

output:

no
14

result:

ok 2 lines

Test #7:

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

input:

4
1 A 2 1A no
2 A 1 1A no
1 Q 1
1 A 3 3A yes

output:

no
3

result:

ok 2 lines

Test #8:

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

input:

11
1 Q 8
1 A 2 1A no
2 A 1 1A no
1 A 2 2A no
2 A 1 1A no
1 A 2 3A no
2 A 1 1A no
1 A 2 4A no
2 A 1 1B yes
2 A 1 1C yes
2 A 1 1D yes

output:

no
10

result:

ok 2 lines

Test #9:

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

input:

5
1 A 2 1A yes
1 A 2 1B no
2 A 3 1B no
3 A 4 1B no
4 A 1 1C no

output:

no
5

result:

ok 2 lines

Test #10:

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

input:

4
1 A 2 1A no
2 A 3 1A no
3 A 4 1A no
4 A 1 1A no

output:

no
4

result:

ok 2 lines

Test #11:

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

input:

5
1 A 2 1A no
2 A 3 1A no
3 A 1 1A no
1 A 4 1A yes
1 A 4 1B yes

output:

no
5

result:

ok 2 lines

Test #12:

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

input:

7
1 A 2 1A no
2 A 1 1A no
1 A 4 1A yes
1 A 4 1B yes
1 A 2 1A no
2 A 3 1A no
3 A 1 1A no

output:

no
7

result:

ok 2 lines

Test #13:

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

input:

4
1 A 2 1A yes
1 A 2 1B yes
1 A 2 1C yes
1 A 2 1D yes

output:

no
4

result:

ok 2 lines

Test #14:

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

input:

3
1 A 2 1A no
2 Q 1
2 A 3 3A yes

output:

no
2

result:

ok 2 lines

Test #15:

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

input:

4
1 A 2 4A yes
1 A 3 4B yes
1 A 2 4D yes
1 A 4 4C yes

output:

no
4

result:

ok 2 lines

Test #16:

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

input:

5
1 A 2 4A yes
1 A 3 4B yes
1 A 2 4D yes
1 A 4 4C no
4 A 1 4C no

output:

no
5

result:

ok 2 lines

Test #17:

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

input:

17
1 A 2 5C no
2 A 3 5C no
3 A 1 5C no
1 A 2 2A no
2 A 3 2A no
3 A 1 2A no
1 A 2 3B no
2 A 3 3B no
3 A 1 3B no
1 A 2 1D no
2 A 3 1D no
3 A 1 1D no
1 A 2 8A no
2 A 3 8A no
3 A 1 8A no
1 A 4 6A no
4 Q 7

output:

no
17

result:

ok 2 lines

Test #18:

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

input:

5
1 A 2 8A yes
1 A 3 8B yes
1 A 2 8D yes
1 A 4 8C no
4 A 1 8C no

output:

no
5

result:

ok 2 lines

Test #19:

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

input:

3
1 A 2 1A no
2 A 1 1A no
1 A 2 1A yes

output:

no
3

result:

ok 2 lines

Test #20:

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

input:

5
1 A 4 4D no
4 A 1 6C yes
4 A 3 1B no
3 A 4 1D yes
3 Q 1

output:

no
5

result:

ok 2 lines

Test #21:

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

input:

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

output:

yes

result:

ok single line: 'yes'

Test #22:

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

input:

1000
1 A 4 1D yes
1 A 3 8B no
3 A 1 4D no
1 A 2 8B no
2 A 1 3D no
1 A 4 7A yes
1 A 4 6D yes
1 A 2 7B no
2 A 4 2A no
4 A 2 5D no
2 A 4 2B no
4 A 2 5C yes
4 A 1 1D yes
4 A 1 8C no
1 A 4 6D no
4 A 2 1D no
2 A 1 3D no
1 A 3 4D yes
1 A 2 2B yes
1 A 4 4B no
4 A 2 8A no
2 A 3 4C no
3 A 1 7A yes
3 A 4 2D no...

output:

yes

result:

ok single line: 'yes'

Test #23:

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

input:

1000
1 A 4 1C yes
1 A 3 7C no
3 A 1 4A no
1 A 2 7C no
2 A 1 6A no
1 A 4 6D yes
1 A 4 5A yes
1 A 2 6D no
2 A 4 3A no
4 A 2 3B no
2 A 4 3D no
4 A 2 8D yes
4 A 1 1D yes
4 A 2 3A yes
4 A 1 2B no
1 A 3 2C yes
1 A 3 5B yes
1 A 2 6B yes
1 A 2 6B no
2 A 4 3A yes
2 A 3 4A yes
2 A 4 6A no
4 A 2 8C no
2 A 3 7A...

output:

yes

result:

ok single line: 'yes'

Test #24:

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

input:

1000
1 A 4 1D yes
1 A 3 8D no
3 A 1 5B no
1 A 2 8D no
2 A 1 5A no
1 A 4 4C yes
1 A 4 3D yes
1 A 2 7D no
2 A 4 1B no
4 A 2 3B no
2 A 4 4A no
4 A 2 1B yes
4 A 2 8C no
2 A 1 5D yes
2 A 1 6B no
1 A 3 4C no
3 A 4 2D no
4 A 2 8C no
2 A 1 6C no
1 A 3 6A yes
1 A 2 3A no
2 A 1 4B yes
2 A 3 5A no
3 A 2 7C yes...

output:

yes

result:

ok single line: 'yes'

Test #25:

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

input:

1000
1 A 4 1C yes
1 A 3 8C no
3 A 1 4C no
1 A 2 8C no
2 A 1 5B no
1 A 4 6D yes
1 A 4 8A yes
1 A 2 4A yes
1 A 4 8A no
4 A 2 3B yes
4 A 2 7C no
2 A 1 5A yes
2 A 1 3C no
1 A 3 2A no
3 A 4 3D no
4 A 2 7C no
2 A 1 5D no
1 A 3 4C yes
1 A 4 1B yes
1 A 4 6D no
4 A 1 3A no
1 A 2 6B no
2 A 4 8D no
4 A 3 7D ye...

output:

yes

result:

ok single line: 'yes'

Test #26:

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

input:

1000
1 A 4 3D yes
1 A 3 2A yes
1 A 2 2B no
2 A 4 5D yes
2 A 1 5B no
1 A 2 1D yes
1 A 2 5D yes
1 A 2 3D no
2 A 1 5C yes
2 A 1 5A no
1 A 3 2A no
3 A 4 2C no
4 A 2 7D no
2 A 1 5B no
1 A 3 7C yes
1 A 2 5C yes
1 A 4 3D no
4 A 2 4A no
2 A 3 5B no
3 A 1 3A yes
3 A 4 8B no
4 A 3 4B yes
4 A 3 4D no
3 A 4 6D ...

output:

yes

result:

ok single line: 'yes'

Test #27:

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

input:

77
1 A 4 5B yes
1 A 2 8D no
2 A 1 4B no
1 A 4 5D yes
1 A 4 3D no
4 A 2 7B yes
4 A 1 6D no
1 A 3 5A yes
1 Q 5
1 A 2 1A yes
1 A 2 8A no
2 A 4 2A yes
2 A 3 6A yes
2 A 4 6C no
4 A 2 4B yes
4 A 2 6D no
2 A 3 2C no
3 A 2 1C no
2 A 3 7C no
3 A 1 1B yes
3 A 4 6B no
4 A 3 2B yes
4 A 3 2D no
3 A 4 4C yes
3 A ...

output:

yes

result:

ok single line: 'yes'

Test #28:

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

input:

61
1 A 4 2C yes
1 A 3 5B no
3 A 4 8C yes
3 A 2 8C no
2 A 4 1D yes
2 A 1 6B no
1 A 2 2B yes
1 A 2 6B yes
1 A 4 6D no
4 A 1 5B yes
4 A 1 6B yes
4 A 2 1C yes
4 A 1 5B no
1 A 3 2D yes
1 Q 2
1 A 2 4A no
2 A 3 3A yes
2 A 3 8B yes
2 A 4 8A no
4 A 2 5D yes
4 A 3 7B no
3 A 2 1B no
2 A 3 8B no
3 A 1 7C yes
3 ...

output:

yes

result:

ok single line: 'yes'

Test #29:

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

input:

81
1 A 4 2D yes
1 A 3 1B yes
1 A 2 1C no
2 A 4 6A yes
2 A 4 3A yes
2 A 1 5D yes
2 A 3 1D no
3 A 2 6A yes
3 A 4 7A yes
3 A 1 2D yes
3 A 2 6B yes
3 A 1 2D no
1 A 3 2D yes
1 A 3 4A yes
1 A 2 1D yes
1 Q 1
1 A 2 8B no
2 A 4 3C yes
2 Q 3
2 A 4 6D no
4 A 3 4B no
3 A 1 2C yes
3 A 4 7B no
4 A 3 7B yes
4 A 3 ...

output:

yes

result:

ok single line: 'yes'

Test #30:

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

input:

49
1 A 4 4D yes
1 Q 4
1 A 2 1A no
2 A 1 3D no
1 A 4 5B yes
1 A 4 5B no
4 A 2 2C yes
4 Q 2
4 A 3 7D no
3 A 4 3C no
4 A 2 7D no
2 A 1 6B no
1 A 3 5C yes
1 A 2 1C yes
1 A 2 8C yes
1 A 2 8D yes
1 Q 8
1 A 4 1A no
4 A 2 7A no
2 A 3 3D no
3 A 1 5A yes
3 A 4 3B no
4 A 3 7B yes
4 Q 7
1 A 2 1B no
2 A 3 3D no
...

output:

yes

result:

ok single line: 'yes'

Test #31:

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

input:

71
1 A 4 1C yes
1 A 3 7B no
3 A 1 3C no
1 A 2 7B no
2 A 1 4D no
1 A 4 7C yes
1 A 4 6B yes
1 A 2 7B no
2 A 4 2A no
4 A 2 6A no
2 A 4 2C no
4 A 2 5B yes
4 A 1 1D yes
4 A 2 5A yes
4 A 3 1B yes
4 A 1 5A no
1 A 3 7D yes
1 Q 7
1 A 3 3C yes
1 A 2 4D yes
1 A 2 6B no
2 A 4 6A yes
2 A 3 2B yes
2 Q 2
2 A 4 6A ...

output:

yes

result:

ok single line: 'yes'

Test #32:

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

input:

82
1 A 4 2B yes
1 A 3 8D no
3 A 1 3C no
1 A 2 8D no
2 A 1 5B no
1 A 4 6A yes
1 A 4 8C yes
1 A 2 2C yes
1 A 4 1A yes
1 A 2 5A yes
1 A 2 6D yes
1 Q 6
1 A 3 1D yes
1 Q 1
1 A 2 5B yes
1 A 2 8B yes
1 Q 8
1 A 3 5D no
3 A 2 5C no
2 A 3 4B no
3 A 1 5A yes
3 A 4 3B no
4 A 3 3B no
3 A 4 7D yes
3 A 4 7C no
4 A...

output:

no
30

result:

ok 2 lines

Test #33:

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

input:

107
1 A 4 4C yes
1 A 4 5B yes
1 A 2 5A no
2 A 4 1B no
4 A 2 2C no
2 A 4 1C no
4 A 2 1B yes
4 A 2 2B no
2 A 1 5D yes
2 A 1 6C no
1 A 3 8A no
3 A 4 3B no
4 A 2 1B no
2 A 1 7D no
1 A 3 6A yes
1 A 2 5B no
2 A 1 8A yes
2 A 4 1C no
4 A 2 1C yes
4 A 3 2B no
3 A 2 7A no
2 A 3 5C no
3 A 1 4B no
1 A 4 5A no
4...

output:

no
54

result:

ok 2 lines

Test #34:

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

input:

100
1 A 4 2B yes
1 A 3 7A no
3 A 1 3B no
1 A 2 7A no
2 A 1 5B no
1 A 4 4B yes
1 A 2 3C no
2 A 4 1A no
4 Q 6
4 A 2 1B no
2 A 4 2D no
4 A 2 8C yes
4 A 1 8D no
1 A 3 3A yes
1 A 3 5D yes
1 A 2 1A yes
1 A 2 4C no
2 A 4 8C yes
2 A 4 8C no
4 A 2 1B no
2 A 3 8A no
3 A 1 3A no
1 A 4 3C no
4 A 3 1D yes
4 A 1 ...

output:

no
22

result:

ok 2 lines

Test #35:

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

input:

91
1 A 4 2B yes
1 A 3 8B no
3 A 1 4B no
1 A 2 8B no
2 A 1 3A no
1 A 4 5C yes
1 A 4 6D yes
1 A 2 6C yes
1 A 4 3B yes
1 A 4 5C no
4 A 2 4C yes
4 A 1 5A yes
4 A 2 4A no
2 A 3 2C yes
2 A 1 1A no
1 A 3 7A no
3 A 4 1B no
4 A 2 5D no
2 A 1 2D no
1 A 3 8A yes
1 A 2 6B yes
1 Q 6
1 A 2 2D no
2 A 3 3D yes
2 A ...

output:

no
23

result:

ok 2 lines

Test #36:

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

input:

81
1 A 4 3A yes
1 A 3 6D no
3 A 4 8B yes
3 A 2 8B no
2 A 4 1B yes
2 A 1 4D no
1 A 2 4A yes
1 A 2 7B yes
1 A 4 3D yes
1 A 4 7B no
4 A 2 1B yes
4 A 2 1A no
2 A 1 4C yes
2 A 1 4B no
1 A 3 8A yes
1 A 3 6B yes
1 A 2 5B no
2 A 3 8B yes
2 A 3 1D yes
2 A 4 1C no
4 A 2 1C yes
4 A 3 7D no
3 A 2 3B no
2 A 3 2A...

output:

no
68

result:

ok 2 lines

Test #37:

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

input:

1000
1 A 4 2A yes
1 A 3 5B no
3 A 4 8C yes
3 A 1 1B no
1 A 4 3A yes
1 A 4 7B no
4 A 2 6C no
2 A 4 2B no
4 A 2 6B no
2 A 4 3B no
4 A 3 1C yes
4 A 1 1C no
1 A 3 4C yes
1 A 2 3A no
2 A 1 2C yes
2 A 3 5A yes
2 A 1 5C yes
2 A 4 6C yes
2 A 3 7D no
3 A 1 2A yes
3 A 1 7B yes
3 A 4 2A no
4 A 3 1B yes
4 A 1 4...

output:

no
196

result:

ok 2 lines

Test #38:

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

input:

1000
1 A 4 1A yes
1 A 3 6C yes
1 A 2 1D no
2 A 4 4A yes
2 A 1 7A no
1 A 2 8C yes
1 A 2 1A no
2 A 4 3A no
4 A 2 7D yes
4 A 2 4B no
2 A 1 6D yes
2 A 1 5D no
1 A 3 6C no
3 A 4 1C no
4 A 2 2D no
2 A 1 6B no
1 A 2 6B yes
1 A 2 1B no
2 A 3 3A no
3 A 2 7C no
2 A 3 6D no
3 A 1 1B yes
3 A 1 8C yes
3 A 2 5A n...

output:

no
391

result:

ok 2 lines

Test #39:

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

input:

1000
1 A 4 4A yes
1 A 3 6B no
3 A 4 8B yes
3 A 1 1A no
1 A 4 7B yes
1 A 4 7D no
4 A 2 7A no
2 A 4 1B no
4 A 2 6A no
2 A 4 2B no
4 A 2 5D yes
4 A 1 6B yes
4 A 2 6B no
2 A 3 8C yes
2 A 1 5B no
1 A 3 7D no
3 A 4 2A no
4 A 2 5C no
2 A 1 6C no
1 A 3 1C yes
1 A 4 4B no
4 A 2 8C yes
4 A 2 5A yes
4 A 1 7B y...

output:

no
82

result:

ok 2 lines

Test #40:

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

input:

1000
1 A 4 3A yes
1 A 3 6C no
3 A 4 7B yes
3 A 1 2C no
1 A 4 3B yes
1 A 4 8C no
4 A 2 6A no
2 A 4 1B no
4 A 2 4D no
2 A 4 1D no
4 A 2 1B yes
4 A 1 4B yes
4 A 3 6D yes
4 A 1 4D no
1 A 2 1C no
2 A 4 7C no
4 A 1 4D no
1 A 2 2A no
2 A 4 7C no
4 A 3 4B no
3 A 2 7B no
2 A 4 1A yes
2 A 3 5C yes
2 A 1 5A no...

output:

no
399

result:

ok 2 lines

Test #41:

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

input:

1000
1 A 4 3A yes
1 A 3 5D yes
1 A 2 4B no
2 A 4 3B yes
2 A 1 5C no
1 A 2 3B yes
1 A 4 5A no
4 A 2 6B no
2 A 4 1D no
4 A 2 7C yes
4 A 2 6B no
2 A 1 6C yes
2 A 1 3D no
1 A 3 5D no
3 A 4 2B no
4 A 2 1C no
2 A 1 5C no
1 A 3 4D yes
1 A 3 3B no
3 A 1 4C yes
3 A 2 2D yes
3 A 4 4C no
4 A 1 8B yes
4 A 1 8A ...

output:

no
355

result:

ok 2 lines

Test #42:

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

input:

120
1 A 2 1A no
2 A 1 1B no
1 A 3 1A no
3 A 1 1C no
1 A 4 1A no
4 A 1 1D no
1 A 2 1A no
2 A 3 1B no
3 A 2 1C no
2 A 4 1B no
4 A 2 1D no
2 A 3 1B no
3 A 4 1C no
4 A 3 1D no
3 A 1 1C no
1 A 2 2A no
2 A 1 2B no
1 A 3 2A no
3 A 1 2C no
1 A 4 2A no
4 A 1 2D no
1 A 2 2A no
2 A 3 2B no
3 A 2 2C no
2 A 4 2B...

output:

yes

result:

ok single line: 'yes'

Test #43:

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

input:

120
1 A 2 3C no
2 A 1 4C no
1 A 3 3C no
3 A 1 8B no
1 A 4 3C no
4 A 1 4A no
1 A 2 3C no
2 A 3 4C no
3 A 2 8B no
2 A 4 4C no
4 A 2 4A no
2 A 3 4C no
3 A 4 8B no
4 A 3 4A no
3 A 1 8B no
1 A 2 1D no
2 A 1 2B no
1 A 3 1D no
3 A 1 5A no
1 A 4 1D no
4 A 1 8D no
1 A 2 1D no
2 A 3 2B no
3 A 2 5A no
2 A 4 2B...

output:

yes

result:

ok single line: 'yes'

Test #44:

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

input:

120
1 A 2 2D no
2 A 1 8A no
1 A 3 2D no
3 A 1 1A no
1 A 4 2D no
4 A 1 5D no
1 A 2 2D no
2 A 3 8A no
3 A 2 1A no
2 A 4 8A no
4 A 2 5D no
2 A 3 8A no
3 A 4 1A no
4 A 3 5D no
3 A 1 1A no
1 A 2 7B no
2 A 1 7D no
1 A 3 7B no
3 A 1 3C no
1 A 4 7B no
4 A 1 7A no
1 A 2 7B no
2 A 3 7D no
3 A 2 3C no
2 A 4 7D...

output:

yes

result:

ok single line: 'yes'

Test #45:

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

input:

120
1 A 2 3C no
2 A 1 4C no
1 A 3 3C no
3 A 1 6D no
1 A 4 3C no
4 A 1 5D no
1 A 2 3C no
2 A 3 4C no
3 A 2 6D no
2 A 4 4C no
4 A 2 5D no
2 A 3 4C no
3 A 4 6D no
4 A 3 5D no
3 A 1 6D no
1 A 2 4D no
2 A 1 2A no
1 A 3 4D no
3 A 1 1D no
1 A 4 4D no
4 A 1 1B no
1 A 2 4D no
2 A 3 2A no
3 A 2 1D no
2 A 4 2A...

output:

yes

result:

ok single line: 'yes'

Test #46:

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

input:

120
1 A 2 8C no
2 A 1 7B no
1 A 3 8C no
3 A 1 7C no
1 A 4 8C no
4 A 1 4C no
1 A 2 8C no
2 A 3 7B no
3 A 2 7C no
2 A 4 7B no
4 A 2 4C no
2 A 3 7B no
3 A 4 7C no
4 A 3 4C no
3 A 1 7C no
1 A 2 1D no
2 A 1 1C no
1 A 3 1D no
3 A 1 5C no
1 A 4 1D no
4 A 1 7A no
1 A 2 1D no
2 A 3 1C no
3 A 2 5C no
2 A 4 1C...

output:

yes

result:

ok single line: 'yes'

Test #47:

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

input:

995
1 A 4 1D yes
1 A 3 7B yes
1 A 2 3C no
2 A 4 3A yes
2 A 1 7A no
1 A 2 3A yes
1 A 2 8B yes
1 A 4 3B yes
1 A 4 4D no
4 A 2 2C yes
4 A 3 2C no
3 A 4 1C no
4 A 2 5B no
2 A 1 3D no
1 A 3 7D yes
1 A 2 6A no
2 A 1 8D yes
2 A 4 5B yes
2 A 3 8C no
3 A 1 8B yes
3 A 2 8D yes
3 A 2 2D no
2 A 3 5B no
3 A 4 8D...

output:

yes

result:

ok single line: 'yes'

Test #48:

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

input:

995
1 A 4 7D yes
1 A 2 7D no
2 A 1 3D no
1 A 4 5C yes
1 A 4 4A yes
1 A 2 2B yes
1 A 4 6D no
4 A 2 8A yes
4 A 1 5C yes
4 A 2 8C yes
4 A 1 3B no
1 A 3 6B yes
1 A 2 6D no
2 A 1 5B no
1 A 3 7A yes
1 A 2 4C no
2 A 3 5B no
3 A 2 1A no
2 A 3 3D no
3 A 1 4B yes
3 A 1 2D yes
3 A 2 1A no
2 A 4 8D yes
2 A 3 3A...

output:

yes

result:

ok single line: 'yes'

Test #49:

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

input:

996
1 A 3 6D yes
1 A 2 1D no
2 A 4 7B yes
2 A 1 6D yes
2 A 1 3A yes
2 A 4 7A yes
2 A 1 8A yes
2 A 4 3A no
4 A 2 7D yes
4 A 3 7D no
3 A 1 1D yes
3 A 1 4D no
1 A 3 1C yes
1 A 4 8D no
4 A 2 8A yes
4 A 2 8C yes
4 A 2 8A no
2 A 3 6D no
3 A 1 1C yes
3 A 1 6A no
1 A 2 3D yes
1 A 3 1A yes
1 A 2 8D no
2 A 4 ...

output:

yes

result:

ok single line: 'yes'

Test #50:

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

input:

996
1 A 4 6C yes
1 A 2 7B no
2 A 1 4B no
1 A 4 3C yes
1 A 4 3A no
4 A 2 8C yes
4 A 2 2C no
2 A 1 3C yes
2 A 1 4B no
1 A 3 7B no
3 A 4 5C no
4 A 2 2B no
2 A 1 5B no
1 A 3 5D yes
1 A 2 3A no
2 A 1 7B yes
2 A 3 3D yes
2 A 4 4C yes
2 A 3 3B no
3 A 1 5D yes
3 A 2 4A yes
3 A 2 4C yes
3 A 4 7D no
4 A 1 2A ...

output:

yes

result:

ok single line: 'yes'

Test #51:

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

input:

996
1 A 4 2A yes
1 A 3 7B no
3 A 4 8D yes
3 A 1 1D no
1 A 4 2C yes
1 A 4 8C no
4 A 2 5A no
2 A 4 1B no
4 A 2 4A no
2 A 4 2B no
4 A 2 5D yes
4 A 1 6C yes
4 A 2 5D no
2 A 3 8D yes
2 A 1 5B no
1 A 3 8C no
3 A 4 4B no
4 A 2 3D no
2 A 1 7D no
1 A 3 6A yes
1 A 3 7A yes
1 A 2 8A yes
1 A 2 3C yes
1 A 3 8C n...

output:

yes

result:

ok single line: 'yes'

Test #52:

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

input:

1000
1 A 3 8C no
3 A 1 5B no
1 A 4 8C no
4 A 2 4B no
2 A 4 5C no
4 A 2 4B no
2 A 1 5C no
1 A 3 8C no
3 A 1 5B no
1 A 3 8C no
3 A 2 5B no
2 A 4 5C no
4 A 2 4B no
2 A 4 5C no
4 A 3 4B no
3 A 1 5B no
1 A 3 2B no
3 A 1 4C no
1 A 4 2B no
4 A 2 7B no
2 A 4 4A no
4 A 2 7B no
2 A 1 4A no
1 A 3 2B no
3 A 1 4...

output:

yes

result:

ok single line: 'yes'

Test #53:

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

input:

1000
1 A 3 6B no
3 A 1 3A no
1 A 4 6B no
4 A 2 1B no
2 A 4 1C no
4 A 2 1B no
2 A 1 1C no
1 A 3 6B no
3 A 1 3A no
1 A 3 6B no
3 A 2 3A no
2 A 4 1C no
4 A 2 1B no
2 A 4 1C no
4 A 3 1B no
3 A 1 3A no
1 A 3 3D no
3 A 1 4D no
1 A 4 3D no
4 A 2 4A no
2 A 4 5B no
4 A 2 4A no
2 A 1 5B no
1 A 3 3D no
3 A 1 4...

output:

yes

result:

ok single line: 'yes'

Test #54:

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

input:

1000
1 A 3 4A no
3 A 1 3B no
1 A 4 4A no
4 A 2 7C no
2 A 4 8C no
4 A 2 7C no
2 A 1 8C no
1 A 3 4A no
3 A 1 3B no
1 A 3 4A no
3 A 2 3B no
2 A 4 8C no
4 A 2 7C no
2 A 4 8C no
4 A 3 7C no
3 A 1 3B no
1 A 3 8B no
3 A 1 4D no
1 A 4 8B no
4 A 2 1D no
2 A 4 8A no
4 A 2 1D no
2 A 1 8A no
1 A 3 8B no
3 A 1 4...

output:

yes

result:

ok single line: 'yes'

Test #55:

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

input:

1000
1 A 3 3C no
3 A 1 7A no
1 A 4 3C no
4 A 2 8C no
2 A 4 8B no
4 A 2 8C no
2 A 1 8B no
1 A 3 3C no
3 A 1 7A no
1 A 3 3C no
3 A 2 7A no
2 A 4 8B no
4 A 2 8C no
2 A 4 8B no
4 A 3 8C no
3 A 1 7A no
1 A 3 3B no
3 A 1 6C no
1 A 4 3B no
4 A 2 6A no
2 A 4 6B no
4 A 2 6A no
2 A 1 6B no
1 A 3 3B no
3 A 1 6...

output:

yes

result:

ok single line: 'yes'

Test #56:

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

input:

1000
1 A 3 4C no
3 A 1 1A no
1 A 4 4C no
4 A 2 1C no
2 A 4 7D no
4 A 2 1C no
2 A 1 7D no
1 A 3 4C no
3 A 1 1A no
1 A 3 4C no
3 A 2 1A no
2 A 4 7D no
4 A 2 1C no
2 A 4 7D no
4 A 3 1C no
3 A 1 1A no
1 A 3 2A no
3 A 1 2C no
1 A 4 2A no
4 A 2 8A no
2 A 4 2B no
4 A 2 8A no
2 A 1 2B no
1 A 3 2A no
3 A 1 2...

output:

yes

result:

ok single line: 'yes'

Test #57:

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

input:

1000
1 A 4 1D no
4 A 3 4B no
3 A 2 4A no
2 A 1 6B no
1 A 4 1C no
4 A 3 6A no
3 A 2 3A no
2 A 1 5D no
1 A 4 8D no
4 A 3 5A no
3 A 2 6C no
2 A 1 3D no
1 A 4 6D no
4 A 3 3C no
3 A 2 3B no
2 A 1 4D no
1 A 4 8C no
4 A 3 7A no
3 A 2 1A no
2 A 1 8A no
1 A 4 2B no
4 A 3 8B no
3 A 2 5C no
2 A 1 2C no
1 A 4 7...

output:

yes

result:

ok single line: 'yes'

Test #58:

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

input:

1000
1 A 4 8B no
4 A 3 5C no
3 A 2 5D no
2 A 1 3D no
1 A 4 2C no
4 A 3 3B no
3 A 2 6B no
2 A 1 3A no
1 A 4 4A no
4 A 3 3C no
3 A 2 7C no
2 A 1 2A no
1 A 4 1A no
4 A 3 6C no
3 A 2 8C no
2 A 1 7A no
1 A 4 7B no
4 A 3 4B no
3 A 2 1D no
2 A 1 6D no
1 A 4 5B no
4 A 3 2B no
3 A 2 1C no
2 A 1 5A no
1 A 4 2...

output:

yes

result:

ok single line: 'yes'

Test #59:

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

input:

1000
1 A 4 3D no
4 A 3 6B no
3 A 2 2B no
2 A 1 7A no
1 A 4 4D no
4 A 3 4C no
3 A 2 2D no
2 A 1 6C no
1 A 4 7B no
4 A 3 3B no
3 A 2 5C no
2 A 1 8C no
1 A 4 8B no
4 A 3 5A no
3 A 2 4B no
2 A 1 5B no
1 A 4 6D no
4 A 3 2A no
3 A 2 1C no
2 A 1 1B no
1 A 4 7D no
4 A 3 8D no
3 A 2 7C no
2 A 1 4A no
1 A 4 5...

output:

yes

result:

ok single line: 'yes'

Test #60:

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

input:

1000
1 A 4 3D no
4 A 3 5C no
3 A 2 6C no
2 A 1 3B no
1 A 4 7B no
4 A 3 6A no
3 A 2 7C no
2 A 1 3C no
1 A 4 1C no
4 A 3 6D no
3 A 2 4C no
2 A 1 5A no
1 A 4 2B no
4 A 3 4D no
3 A 2 5B no
2 A 1 7D no
1 A 4 1B no
4 A 3 4A no
3 A 2 2D no
2 A 1 5D no
1 A 4 8A no
4 A 3 8D no
3 A 2 6B no
2 A 1 1A no
1 A 4 2...

output:

yes

result:

ok single line: 'yes'

Test #61:

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

input:

1000
1 A 4 7A no
4 A 3 8D no
3 A 2 3C no
2 A 1 5D no
1 A 4 5C no
4 A 3 8B no
3 A 2 4A no
2 A 1 5A no
1 A 4 3A no
4 A 3 7B no
3 A 2 4C no
2 A 1 8A no
1 A 4 1D no
4 A 3 4B no
3 A 2 4D no
2 A 1 2D no
1 A 4 2B no
4 A 3 2A no
3 A 2 6B no
2 A 1 6C no
1 A 4 1B no
4 A 3 6D no
3 A 2 2C no
2 A 1 3B no
1 A 4 3...

output:

yes

result:

ok single line: 'yes'

Test #62:

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

input:

1000
1 A 4 8A no
4 A 3 2A no
3 A 2 5D no
2 A 1 6D no
1 A 4 4A no
4 A 3 6A no
3 A 2 3C no
2 A 1 8C no
1 A 4 4D no
4 A 3 5C no
3 A 2 1C no
2 A 1 1D no
1 A 4 6B no
4 A 3 2D no
3 A 2 6C no
2 A 1 4B no
1 A 3 5B no
3 A 1 7D no
1 A 4 5B no
4 A 2 8D no
2 A 4 4C no
4 A 2 8D no
2 A 1 4C no
1 A 3 5B no
3 A 1 7...

output:

yes

result:

ok single line: 'yes'

Test #63:

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

input:

1000
1 A 4 7B no
4 A 3 3D no
3 A 2 7A no
2 A 1 2D no
1 A 4 3C no
4 A 3 1B no
3 A 2 8B no
2 A 1 8A no
1 A 4 3A no
4 A 3 1A no
3 A 2 2B no
2 A 1 7D no
1 A 4 5C no
4 A 3 4C no
3 A 2 3B no
2 A 1 6C no
1 A 3 8D no
3 A 1 5D no
1 A 4 8D no
4 A 2 6B no
2 A 4 7C no
4 A 2 6B no
2 A 1 7C no
1 A 3 8D no
3 A 1 5...

output:

yes

result:

ok single line: 'yes'

Test #64:

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

input:

1000
1 A 4 3B no
4 A 3 3C no
3 A 2 8D no
2 A 1 5C no
1 A 4 7B no
4 A 3 3A no
3 A 2 2C no
2 A 1 6B no
1 A 4 8B no
4 A 3 2B no
3 A 2 4D no
2 A 1 1C no
1 A 4 7D no
4 A 3 3D no
3 A 2 7C no
2 A 1 1D no
1 A 3 6A no
3 A 1 4C no
1 A 4 6A no
4 A 2 5A no
2 A 4 1B no
4 A 2 5A no
2 A 1 1B no
1 A 3 6A no
3 A 1 4...

output:

yes

result:

ok single line: 'yes'

Test #65:

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

input:

1000
1 A 4 4A no
4 A 3 4C no
3 A 2 1A no
2 A 1 8D no
1 A 4 2C no
4 A 3 8A no
3 A 2 4B no
2 A 1 6B no
1 A 4 3C no
4 A 3 5A no
3 A 2 6C no
2 A 1 2A no
1 A 4 3A no
4 A 3 7A no
3 A 2 7D no
2 A 1 8B no
1 A 3 1C no
3 A 1 2B no
1 A 4 1C no
4 A 2 5D no
2 A 4 6A no
4 A 2 5D no
2 A 1 6A no
1 A 3 1C no
3 A 1 2...

output:

yes

result:

ok single line: 'yes'

Test #66:

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

input:

1000
1 A 4 6B no
4 A 3 5C no
3 A 2 7B no
2 A 1 4D no
1 A 4 7D no
4 A 3 6C no
3 A 2 5D no
2 A 1 8B no
1 A 4 7A no
4 A 3 2C no
3 A 2 2D no
2 A 1 1B no
1 A 4 1C no
4 A 3 5B no
3 A 2 4B no
2 A 1 8C no
1 A 3 1D no
3 A 1 8D no
1 A 4 1D no
4 A 2 3C no
2 A 4 3D no
4 A 2 3C no
2 A 1 3D no
1 A 3 1D no
3 A 1 8...

output:

yes

result:

ok single line: 'yes'

Test #67:

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

input:

33
1 A 4 2C no
4 A 2 5B yes
4 A 2 6D yes
4 A 3 6C yes
4 A 3 7C no
3 A 1 7D no
1 A 4 1C yes
1 A 4 7C yes
1 A 3 7C no
3 A 2 2B yes
3 A 1 2C yes
3 A 2 7A yes
3 A 1 2D yes
3 Q 2
3 A 4 7D no
4 A 3 5A yes
4 Q 5
4 A 1 3A yes
4 Q 3
4 A 1 6D no
1 A 3 8A yes
1 A 3 4C no
3 A 2 1D no
2 A 4 4A no
4 A 2 6B yes
4 ...

output:

no
27

result:

ok 2 lines

Test #68:

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

input:

198
1 A 4 2A no
4 A 2 3C yes
4 A 1 2D no
1 A 2 1A no
2 A 1 1B no
1 A 3 1A no
3 A 1 1C no
1 A 4 1A no
4 A 1 2D no
1 A 2 2A no
2 A 1 1B no
1 A 3 2A no
3 A 1 1C no
1 A 4 2A no
4 A 1 2D no
1 A 2 4B no
2 A 1 1B no
1 A 3 4B no
3 A 1 1C no
1 A 4 4B no
4 A 1 2D no
1 A 2 6A no
2 A 1 1B no
1 A 3 6A no
3 A 1 1...

output:

yes

result:

ok single line: 'yes'

Test #69:

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

input:

90
1 A 4 3A no
4 A 2 2D yes
4 A 1 4A yes
4 A 3 4B yes
4 A 3 7D no
3 A 1 5B no
1 A 4 4A yes
1 A 3 4A no
3 A 4 7D yes
3 A 2 5C yes
3 A 2 6C yes
3 A 4 7B no
4 A 3 2C no
3 A 2 3B no
2 A 1 8C no
1 A 3 4C no
3 A 2 8D yes
3 A 4 8A no
4 A 3 2B yes
4 Q 2
4 A 3 6C yes
4 A 3 4D no
3 A 4 7D no
4 A 3 6C no
3 A 4...

output:

no
49

result:

ok 2 lines

Test #70:

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

input:

256
1 A 4 7B no
4 A 2 7C no
2 A 3 6D no
3 A 2 4A no
2 A 3 1A no
3 A 1 3C no
1 A 2 8C no
2 A 1 4A no
1 A 3 8C no
3 A 4 8C no
4 A 2 3D no
2 A 3 5C no
3 A 2 3A no
2 A 3 8A no
3 A 4 2D no
4 A 2 3A no
2 A 4 8A no
4 A 1 3C no
1 A 4 2C no
4 A 1 1D no
1 A 3 5D no
3 A 4 2D no
4 A 1 4C no
1 A 3 6A no
3 A 2 8A...

output:

yes

result:

ok single line: 'yes'

Test #71:

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

input:

925
1 A 3 2D no
3 A 2 6A no
2 A 1 3A no
1 A 2 1C no
2 A 3 8C no
3 A 4 6D yes
3 A 2 3B no
2 A 1 5D no
1 A 3 8C no
3 A 4 7B no
4 A 3 6C no
3 A 2 7A no
2 A 3 8B no
3 A 4 8C no
4 A 2 3D no
2 A 3 1D yes
2 A 4 4A no
4 A 2 6B no
2 A 1 8D no
1 A 3 8C no
3 A 4 3C no
4 A 2 2A no
2 A 3 5D no
3 A 4 3C no
4 A 1 ...

output:

no
917

result:

ok 2 lines

Test #72:

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

input:

279
1 A 4 7D no
4 A 3 6D no
3 A 2 7A no
2 A 4 7C no
4 A 3 2A no
3 A 1 7B no
1 A 4 8D no
4 A 3 1B no
3 A 1 6A no
1 A 4 1D no
4 A 3 1B no
3 A 1 4D no
1 A 2 6A no
2 A 4 3B no
4 A 3 1D no
3 A 4 6D no
4 A 2 5D no
2 A 1 3D no
1 A 4 5A no
4 A 1 6B no
1 A 2 5D no
2 A 3 7B no
3 A 1 4B no
1 A 3 5B no
3 A 4 6B...

output:

yes

result:

ok single line: 'yes'

Test #73:

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

input:

100
1 A 4 1B no
4 A 2 2B yes
4 A 2 5D yes
4 A 3 7B no
3 A 1 4C no
1 A 4 4B yes
1 A 3 4C yes
1 A 2 2A no
2 A 3 3D yes
2 A 1 1B yes
2 A 1 4C yes
2 A 4 1D no
4 A 3 7A yes
4 A 3 5D no
3 A 4 7D no
4 A 3 8C no
3 A 1 6D no
1 A 4 2B yes
1 A 4 6C no
4 A 3 5C no
3 A 4 7D no
4 A 3 5D no
3 A 2 6B no
2 A 1 1D no...

output:

no
79

result:

ok 2 lines

Test #74:

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

input:

198
1 A 4 3C no
4 A 2 2B yes
4 A 1 1A no
1 A 2 1D no
2 A 1 1B no
1 A 3 1D no
3 A 1 3B no
1 A 4 1D no
4 A 1 1A no
1 A 2 3C no
2 A 1 1B no
1 A 3 3C no
3 A 1 3B no
1 A 4 3C no
4 A 1 1A no
1 A 2 4B no
2 A 1 1B no
1 A 3 4B no
3 A 1 3B no
1 A 4 4B no
4 A 1 1A no
1 A 2 4C no
2 A 1 1B no
1 A 3 4C no
3 A 1 3...

output:

yes

result:

ok single line: 'yes'

Test #75:

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

input:

231
1 A 2 4D no
2 A 1 8D no
1 A 2 2B no
2 A 1 8A no
1 A 4 2B no
4 A 3 8B no
3 A 2 8B no
2 A 3 8D no
3 A 2 6D no
2 A 1 1C no
1 A 3 5D no
3 A 4 5C no
4 A 2 6D no
2 A 1 1B no
1 A 4 2B no
4 A 3 6D no
3 A 1 3B no
1 A 2 1B no
2 A 3 5B no
3 A 4 5C no
4 A 2 4D no
2 A 3 1D no
3 A 2 5C no
2 A 3 5B no
3 A 1 5A...

output:

yes

result:

ok single line: 'yes'

Test #76:

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

input:

334
1 A 4 7B no
4 A 2 5B no
2 A 3 5A no
3 A 2 8B no
2 A 4 4A no
4 A 1 4D no
1 A 2 7B no
2 A 1 2B no
1 A 3 2B no
3 A 4 4A no
4 A 3 1A no
3 A 2 7D no
2 A 1 8A no
1 A 4 7C no
4 A 2 2D no
2 A 3 6A no
3 A 1 3D no
1 A 4 1D no
4 A 2 4B no
2 A 1 8B no
1 A 2 1D no
2 A 4 4D no
4 A 3 2B no
3 A 2 7A no
2 A 4 4C...

output:

no
297

result:

ok 2 lines

Test #77:

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

input:

56
1 A 4 1D no
4 A 2 8D no
2 A 4 1C no
4 A 3 8D no
3 A 4 1B no
4 A 2 8D no
2 A 3 1D no
3 A 1 8C no
1 A 4 2D no
4 A 2 8D no
2 A 4 2C no
4 A 3 8D no
3 A 4 2B no
4 A 2 8D no
2 A 3 2D no
3 A 1 8C no
1 A 4 3D no
4 A 2 8D no
2 A 4 3C no
4 A 3 8D no
3 A 4 3B no
4 A 2 8D no
2 A 3 3D no
3 A 1 8C no
1 A 4 4D ...

output:

yes

result:

ok single line: 'yes'

Test #78:

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

input:

960
1 A 4 1D no
4 A 2 8D no
2 A 4 1C no
4 A 3 8D no
3 A 4 1B no
4 A 2 8D no
2 A 3 1D no
3 A 1 8C no
1 A 4 2D no
4 A 2 8D no
2 A 4 2C no
4 A 3 8D no
3 A 4 2B no
4 A 2 8D no
2 A 3 2D no
3 A 1 8C no
1 A 4 3D no
4 A 2 8D no
2 A 4 3C no
4 A 3 8D no
3 A 4 3B no
4 A 2 8D no
2 A 3 3D no
3 A 1 8C no
1 A 4 4D...

output:

yes

result:

ok single line: 'yes'

Test #79:

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

input:

1000
1 A 2 4B no
2 A 4 3D no
4 A 2 6A no
2 A 4 3B no
4 A 1 1B no
1 A 2 6A no
2 A 3 4A no
3 A 2 8D no
2 A 1 1D no
1 A 3 6A no
3 A 1 7A no
1 A 2 7D no
2 A 1 8C no
1 A 2 2D no
2 A 3 8C no
3 A 1 2A no
1 A 4 6A no
4 A 2 2A no
2 A 1 1B no
1 A 3 7D no
3 A 1 7C no
1 A 3 1B no
3 A 4 7A no
4 A 3 4C no
3 A 1 3...

output:

no
44

result:

ok 2 lines

Test #80:

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

input:

999
1 A 3 1B no
3 A 4 4C no
4 A 2 1C no
2 A 1 6B no
1 A 3 5A no
3 A 4 4B no
4 A 1 3D no
1 A 3 4A no
3 A 4 4B no
4 A 2 5A no
2 A 1 2A no
1 A 2 5B no
2 A 3 3D no
3 A 4 2D no
4 A 1 3A no
1 A 4 1C no
4 A 3 3A no
3 A 1 2B no
1 A 2 7B no
2 A 4 3C no
4 A 1 5D no
1 A 2 4C no
2 A 4 6B no
4 A 3 7A no
3 A 2 2C...

output:

no
83

result:

ok 2 lines

Extra Test:

score: 0
Extra Test Passed