Problem: The sales department of Japanese Ancient Giant Corp. is visiting a hot spring resort for their recreational trip. For deepening their friendships, they are staying in one large room of a Japanese-style hotel called a ryokan.

In the ryokan, people sleep in Japanese-style beds called futons. They all have put their futons on the floor just as they like. Now they are ready for sleeping but they have one concern: they don’t like to go into their futons with their legs toward heads — this is regarded as a bad custom in Japanese tradition. However, it is not obvious whether they can follow a good custom. You are requested to write a program answering their question, as a talented programmer.

Here let's model the situation. The room is considered to be a grid on an xy-plane. As usual, x-axis points toward right and y-axis points toward up. Each futon occupies two adjacent cells. People put their pillows on either of the two cells. Their heads come to the pillows; their foots come to the other cells. If the cell of some person's foot becomes adjacent to the cell of another person's head, regardless their directions, then it is considered as a bad case. Otherwise people are all right.



Input

The input is a sequence of datasets. Each dataset is given in the following format:

n
x1 y1 dir1
...
xn yn dirn


n is the number of futons (1 ≤ n ≤ 20,000); (xi, yi) denotes the coordinates of the left-bottom corner of the i-th futon; diri is either 'x' or 'y' and denotes the direction of the i-th futon, where 'x' means the futon is put horizontally and 'y' means vertically. All coordinate values are non-negative integers not greater than 109 .

It is guaranteed that no two futons in the input overlap each other.

The input is terminated by a line with a single zero. This is not part of any dataset and thus should not be processed.

Output

For each dataset, print "Yes" in a line if it is possible to avoid a bad case, or "No" otherwise.

Example

Input

4
0 0 x
2 0 x
0 1 x
2 1 x
4
1 0 x
0 1 x
2 1 x
1 2 x
4
0 0 x
2 0 y
0 1 y
1 2 x
0


Output

Yes
No
Yes

Solution (in CPP):

Solution:
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

struct Huton {
	int x, y;
	char c;
	Huton() {

	}
	Huton(const int a, const int b, const  char cc) {
		y = a, x = b, c = cc;
	}
	bool operator<(const Huton&h)const {
		return make_pair(make_pair(y, x), c - 'a') < make_pair(make_pair(h.y, h.x), c - 'a');
	}
};

void push(vector<vector<int>>&edge, int a, int b) {
	edge[a].push_back(b);
	edge[b].push_back(a);
}

void in(map<Huton, int>&mp, vector<vector<int>>&edge, pair<Huton, int>h, int y, int x, char c, int aadd, int badd) {
	auto it = mp.find(Huton(y, x, c));
	if (it != mp.end()&&c==it->first.c) {
		push(edge, h.second * 2 + aadd, it->second * 2 + badd);
		if (h.first.c == c && aadd == badd) {
			push(edge, h.second * 2 + aadd + 1, it->second * 2 + badd + 1);
		}
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	while (cin >> N, N) {
		vector<vector<int>>same(N * 2);
		vector<vector<int>>tigau(N * 2);
		map<Huton, int>mp;
		for (int i = 0; i < N; i++) {
			Huton h;
			cin >> h.x >> h.y >> h.c;
			mp[h] = i;
		}
		for (int i = 0; i < N * 2; i += 2) {
			tigau[i].push_back(i + 1);
			tigau[i + 1].push_back(i);
		}
		for (auto i : mp) {
			if (i.first.c == 'x') {
				in(mp, same, i, i.first.y + 0, i.first.x + 2, 'y', 1, 0);
				in(mp, same, i, i.first.y + 1, i.first.x + 0, 'y', 0, 0);
				in(mp, same, i, i.first.y + 1, i.first.x + 1, 'y', 1, 0);
				in(mp, same, i, i.first.y + 0, i.first.x + 2, 'x', 1, 0);
				in(mp, same, i, i.first.y + 1, i.first.x - 1, 'x', 0, 1);
				in(mp, same, i, i.first.y + 1, i.first.x - 0, 'x', 0, 0);
				in(mp, same, i, i.first.y + 1, i.first.x + 1, 'x', 1, 0);
			}
			else {
				in(mp, same, i, i.first.y + 0, i.first.x + 1, 'y', 0, 0);
				in(mp, same, i, i.first.y + 1, i.first.x - 1, 'y', 1, 0);
				in(mp, same, i, i.first.y + 1, i.first.x + 1, 'y', 1, 0);
				in(mp, same, i, i.first.y + 2, i.first.x + 0, 'y', 1, 0);
				in(mp, same, i, i.first.y + 0, i.first.x + 1, 'x', 0, 0);
				in(mp, same, i, i.first.y + 1, i.first.x + 1, 'x', 1, 0);
				in(mp, same, i, i.first.y + 1, i.first.x - 2, 'x', 1, 1);
				in(mp, same, i, i.first.y + 2, i.first.x - 1, 'x', 1, 1);
				in(mp, same, i, i.first.y + 2, i.first.x - 0, 'x', 1, 0);
			}
		}
		bool flag = true;
		vector<int>node(N * 2, -1);
		queue<int>Q;
		for (int i = 0; i < N * 2; i++) {
			if (node[i] >= 0)continue;
			node[i] = 0;
			queue<int>Q;
			Q.push(i);
			while (!Q.empty()) {
				int cn = Q.front();
				Q.pop();
				for (auto j : same[cn]) {
					if (node[j] == -1) {
						node[j] = node[cn];
						Q.push(j);
					}
					if (node[j] != node[cn])flag = false;
				}
				for (auto j : tigau[cn]) {
					if (node[j] == -1) {
						node[j] = 1 - node[cn];
						Q.push(j);
					}
					if (node[j] + node[cn] != 1)flag = false;
				}
			}
		}
		if (flag)cout << "Yes\n";
		else cout << "No\n";
	}
}