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 <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s); sin>>v; return v;}
template<class T> inline string toString(T x) {ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI = acos(-1.0);


typedef vector<pii> vp;


int dx[]={-1,0,1,0},dy[]={0,-1,0,1};
int main(){
	int n;
	while(cin>>n,n){
		map<pii,vp> g;
		map<pii,vi> type;
		map<pii,int> hf;
		REP(i,n){
			int x,y;
			char d;
			cin>>x>>y>>d;
			int dir=(d=='x'?2:3);
			pii c=make_pair(y,x);
			pii n=make_pair(y+dy[dir],x+dx[dir]);

			g[c]=vp();
			type[c]=vi();
			g[c].push_back(n);
			type[c].push_back(1);
			hf[c]=-1;

			g[n]=vp();
			type[n]=vi();
			g[n].push_back(c);
			type[n].push_back(1);
			hf[n]=-1;

			REP(j,2){
				REP(k,4){
					pii base=(j==0?c:n);
					pii neighbor=make_pair(base.first+dy[k],base.second+dx[k]);
					if(EXIST(g,neighbor)&&find(ALL(g[base]),neighbor)==g[base].end()){
						g[base].push_back(neighbor);
						type[base].push_back(0);
						g[neighbor].push_back(base);
						type[neighbor].push_back(0);
					}
				}
			}
		}

		bool ok=true;
		queue<pii> q;
		for(map<pii,vp>::iterator it=g.begin();it!=g.end();it++){
			if(hf[(*it).first]==-1){
				q.push((*it).first);
				hf[(*it).first]=0;
				while(!q.empty()){
					pii cur=q.front();q.pop();
					int cur_hf=hf[cur];
					REP(i,g[cur].size()){
						pii next=g[cur][i];
						int next_hf=(cur_hf+type[cur][i])%2;
						if(hf[next]==-1){
							hf[next]=next_hf;
							q.push(next);
						}else if(hf[next]==next_hf){
						}else{
							ok=false;
							goto end;
						}
					}
				}
			}
		}
end:
		cout<<(ok?"Yes":"No")<<endl;
	}
}