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 <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
//#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<P, P> PP;
typedef pair<P,int> PPI;

#define INF INT_MAX/3

#define MAX_N 1000

//// UnionFind
struct UnionFind{
	vector<int> v;
	UnionFind(int n) : v(n, -1) {}

	int find(int x) { return v[x] < 0 ? x : v[x] = find(v[x]); }
	bool unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return false;
		if (-v[x] < -v[y]) swap(x, y);
		v[x] += v[y]; v[y] = x;
		return true;
	}
	bool root(int x) { return v[x] < 0; }
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -v[find(x)]; }
};

int n;
vector<PP> edge;
vector<P> point;
int dd[]={-1,0,1,0,-1};

int idlast;
map<P,int> mp;
int id(P p){
	if(mp.count(p))return mp[p];
	mp[p]=idlast++;
	return mp[p];
}

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>n;
		if(n==0)break;
		UnionFind uf(4*n+100);
		idlast=0;
		edge.clear(); point.clear(); mp.clear();
		rep(i,n){
			ll a,b; char c;
			cin>>a>>b>>c;
			if(c=='x'){
				edge.pb(PP(P(a,b),P(a+1,b)));
				uf.unite(id(P(a,b))+2*n,id(P(a+1,b)));
				uf.unite(id(P(a,b)),id(P(a+1,b))+2*n);
				point.pb(P(a,b)); point.pb(P(a+1,b));
			}else{
				edge.pb(PP(P(a,b),P(a,b+1)));
				uf.unite(id(P(a,b))+2*n,id(P(a,b+1)));
				uf.unite(id(P(a,b)),id(P(a,b+1))+2*n);
				point.pb(P(a,b)); point.pb(P(a,b+1));
			}
		}
		rep(i,point.size()){
			P p=point[i];
			rep(j,4){
				ll nx=p.fi+dd[j], ny=p.se+dd[j+1];
				if(!mp.count(P(nx,ny))||P(nx,ny)==point[i+(i%2?-1:1)])continue;
				uf.unite(id(p),id(P(nx,ny)));
				uf.unite(id(p)+2*n,id(P(nx,ny))+2*n);
			}
		}
		bool ok=true;
		rep(i,edge.size()){
			if(uf.same(id(edge[i].fi),id(edge[i].se))||
				uf.same(id(edge[i].fi)+2*n,id(edge[i].se)+2*n))ok=false;
		}
		if(ok)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}