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:
#define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> istream& operator>>(istream& is, vector<T>& v);
template<class T> ostream& operator<<(ostream& os, vector<T> const& v);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream&, const tuple<T...>&){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream& os, const tuple<T...>& t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream& operator<<(ostream& os, const tuple<T...>& t){ _ot<0>(os, t); return os; }
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _it(istream&, tuple<T...>&){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _it(istream& is, tuple<T...>& t){ is >> get<n>(t); _it<n+1>(is, t); }
template<class...T> istream& operator>>(istream& is, tuple<T...>& t){ _it<0>(is, t); return is; }
template<class T> istream& operator>>(istream& is, vector<T>& v){ rep(i,v.size()) is >> v[i]; return is; }
template<class T> ostream& operator<<(ostream& os, vector<T> const& v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif

typedef int Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src, int dst, Weight weight) :
        src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
        e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

Graph g;

int vis[40010];

bool dfs(int v, int c){
    vis[v] = c;
    for(Edge & e : g[v]){
        int d = e.dst;
        if(vis[d]!=-1){
            if(v/2==d/2 && vis[v]==vis[d]) return false;
            if(v/2!=d/2 && vis[v]!=vis[d]) return false;
        } else {
            if(v/2==d/2 && !dfs(d,1-c)) return false;
            if(v/2!=d/2 && !dfs(d,c)) return false;
        }
    }
    return true;
}

int main(){
    int n;
    while(cin>>n && n){
        vector<ll> v(n*2);
        g.assign(n*2,{});
        map<ll,int> id;
        rep(i,n){
            ll x,y; char c;
            cin >> x >> y >> c;
            ll xx=x, yy=y;
            if(c=='y')yy++;
            else xx++;
            v[i*2] = x<<32|y;
            v[i*2+1] = xx<<32|yy;
            id[x<<32|y] = i*2;
            id[xx<<32|yy] = i*2+1;
        }
        sort(all(v));
        rep(i,n*2-1){
            ll x,y;
            ll xx,yy;
            tie(x,y) = mt(v[i]>>32,v[i]&0xFFFFFFFF);
            tie(xx,yy) = mt(v[i+1]>>32,v[i+1]&0xFFFFFFFF);
            if(abs(x-xx)+abs(y-yy)==1){
                int a=id[v[i]], b=id[v[i+1]];
                g[a].eb(a,b,0);
                g[b].eb(b,a,0);
            }
        }
        sort(all(v), [](ll a, ll b){
                ll x,y;
                ll xx,yy;
                tie(x,y) = mt(a>>32, a&0xFFFFFFFF);
                tie(xx,yy) = mt(b>>32, b&0xFFFFFFFF);
                return y!=yy ? y<yy : x<xx;
            });
        rep(i,n*2-1){
            ll x,y;
            ll xx,yy;
            tie(x,y) = mt(v[i]>>32,v[i]&0xFFFFFFFF);
            tie(xx,yy) = mt(v[i+1]>>32,v[i+1]&0xFFFFFFFF);
            if(abs(x-xx)+abs(y-yy)==1){
                int a=id[v[i]], b=id[v[i+1]];
                g[a].eb(a,b,0);
                g[b].eb(b,a,0);
            }
        }
        memset(vis,-1,sizeof(vis));
        bool ok = true;
        rep(i,n*2) if(vis[i]==-1){
            ok &= dfs(i,0);
            if(!ok) break;
        }
        puts(ok ? "Yes" : "No");
    }
}