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<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
struct StronglyConnectedComponents{
    vector<int> used,cmp,vs;
    vector<vector<int>> v,rv;
    StronglyConnectedComponents(int n):used(n),cmp(n,-1),v(n),rv(n){}

    void add_edge(int x,int y){
        v[x].push_back(y);
        rv[y].push_back(x);
    }
    void dfs(int x){
        used[x]=true;
        for(auto to:v[x])if(!used[to])dfs(to);
        vs.push_back(x);
    }

    void rdfs(int x,int k){
        cmp[x]=k;
        for(auto to:rv[x])if(cmp[to]==-1)rdfs(to,k);
    }

    int scc(){
        rep(i,used.size())if(!used[i])dfs(i);
        reverse(vs.begin(),vs.end());
        int k=0;
        for(auto x:vs)if(cmp[x]==-1)rdfs(x,k++);
        return k;
    }
    void build(vector<vector<int>> &g){
        int k=scc();
        g.resize(k);
        set<pair<int,int>> used;
        rep(i,v.size()){
            for(auto& to:v[i]){
                int x=cmp[i],y=cmp[to];
                if(x==y||used.count({x,y}))continue;
                g[x].push_back(y);
                used.emplace(x,y);
            }
        }
    }
};

void solve(int n){
    map<pair<int,int>,int> mp;
    StronglyConnectedComponents scc(2*n);
    int d[]{1,0,-1,0,1};
    rep(i,n){
        int x,y;
        cin>>x>>y;
        char dir;
        cin>>dir;
        int nx=x,ny=y;
        if(dir=='x')++nx;
        else ++ny;
        rep(j,4){
            if(mp.count({x+d[j],y+d[j+1]})){
                scc.add_edge(2*i, mp[{x+d[j],y+d[j+1]}]);
                scc.add_edge(mp[{x+d[j],y+d[j+1]}],2*i);
                scc.add_edge(2*i+1, mp[{x+d[j],y+d[j+1]}]^1);
                scc.add_edge(mp[{x+d[j],y+d[j+1]}]^1,2*i+1);
            }
            if(mp.count({nx+d[j],ny+d[j+1]})){
                scc.add_edge(2*i+1, mp[{nx+d[j],ny+d[j+1]}]);
                scc.add_edge(mp[{nx+d[j],ny+d[j+1]}],2*i+1);
                scc.add_edge(2*i, mp[{nx+d[j],ny+d[j+1]}]^1);
                scc.add_edge(mp[{nx+d[j],ny+d[j+1]}]^1,2*i);
            }
        }
        mp[{x,y}]=2*i;
        mp[{nx,ny}]=2*i+1;
    }
    scc.scc();
    rep(i,n){
        if(scc.cmp[2*i]==scc.cmp[2*i+1]){
            cout<<"No"<<endl;
            return ;
        }
    }
    cout<<"Yes"<<endl;
    return ;
}
int main(){
    int n;
    while(cin>>n,n)solve(n);
    return 0;
}