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 <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
typedef pair<int, int> P;
typedef pair<P, char> S;
int N;
map<P, int> m;
S s[20000];
bool h_used[40000];
bool l_used[40000];
int dfs(int idx){
  if(idx == N) return true;
  int x = s[idx].first.first, y = s[idx].first.second;
  int x2 = x, y2 = y;
  if(s[idx].second == 'x') x2++;
  else y2++;
  vector<int> useidx1;
  REP(r, 4){
    int nx = x + dx[r], ny = y + dy[r];
    if(m.count(P(nx, ny))){
      useidx1.push_back(m[P(nx, ny)]);
    }
  }
  vector<int> useidx2;
  REP(r, 4){
    int nx = x2 + dx[r], ny = y2 + dy[r];
    if(m.count(P(nx, ny))){
      useidx2.push_back(m[P(nx, ny)]);
    }
  }
  REP(iter, 2){
    if(!h_used[m[P(x, y)]] && !l_used[m[P(x2, y2)]]){
      //printf("put (%d, %d) idx = %d\n", x, y, idx);
      //printf("leg is (%d, %d)\n", x2, y2);
      bool mem1[4] = {};
      bool mem2[4] = {};
      REP(i, useidx1.size()) {mem1[i] = l_used[useidx1[i]]; l_used[useidx1[i]] = true;}
      REP(i, useidx2.size()) {mem2[i] = h_used[useidx2[i]]; h_used[useidx2[i]] = true;}
      if(dfs(idx + 1)) return true;
      REP(i, useidx1.size()) l_used[useidx1[i]] = mem1[i];
      REP(i, useidx2.size()) h_used[useidx2[i]] = mem2[i];
    }
    if(iter == 0){
      swap(x, x2); swap(y, y2); swap(useidx1, useidx2);
    }
  }
  return false;
}
int main(){
  while(cin>>N && N){
    m.clear();
    int ID = 0;
    REP(i, N) scanf("%d %d %c", &s[i].first.first, &s[i].first.second, &s[i].second);
    sort(s, s + N);
    REP(i, N){
      int x = s[i].first.first, y = s[i].first.second;
      m[P(x, y)] = ID++;
      if(s[i].second == 'x'){
        m[P(x + 1, y)] = ID++;
      }else{
        m[P(x, y + 1)] = ID++;
      }
    }
    memset(h_used, 0, sizeof(h_used));
    memset(l_used, 0, sizeof(l_used));
    if(dfs(0)){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }
  return 0;
}