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 <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

struct before_main{before_main(){cin.tie(0); ios::sync_with_stdio(false);}} before_main;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int const OppoSide = 0;
int const SameSide = 1;

int N;
vector<pair<int, int>> G[44444];
map<pair<int, int>, int> MP;
map<int, pair<int, int>> CD;
int vis[44444];

bool dfs(int curr, int col) {
  for(auto& e: G[curr]) {
    int next, dir; tie(next, dir) = e;
    int nextCol = dir == OppoSide ? col ^ 1 : col;
    if(vis[next] + 1) {
      if(vis[next] != nextCol) return false;
    } else {
      vis[next] = nextCol;
      if(!dfs(next, nextCol)) return false;
    }
  }
  return true;
}

int main() {

  for(int M; cin >> M && M;) {
    vector<int> xs, ys;
    vector<int> X, Y; vector<char> D;
    rep(i, M) {
      int x, y; char d; cin >> x >> y >> d;
      X.push_back(x), Y.push_back(y), D.push_back(d);

      xs.push_back(x-1),  ys.push_back(y-1);
      xs.push_back(x),    ys.push_back(y);
      xs.push_back(x+1),  ys.push_back(y+1);

      if(d == 'x') {
        xs.push_back(x+2);
      } else {
        ys.push_back(y+2);
      }

    }

    sort(all(xs)); xs.erase(unique(all(xs)), xs.end());
    sort(all(ys)); ys.erase(unique(all(ys)), ys.end());

    vector<int> NX, NY;
    rep(i, X.size()) {
      NX.push_back(lower_bound(all(xs), X[i]) - X.begin());
    }
    rep(i, Y.size()) {
      NY.push_back(lower_bound(all(ys), Y[i]) - Y.begin());
    }
    X = NX, Y = NY;

    MP.clear(), CD.clear();
    rep(i, 44444) G[i].clear();
    N = 0;

    rep(i, X.size()) {
      MP[make_pair(Y[i], X[i])] = N;
      CD[N++] = make_pair(Y[i], X[i]);
      if(D[i] == 'x') {
        MP[make_pair(Y[i], X[i]+1)] = N;
        CD[N] = make_pair(Y[i], X[i]+1);
        G[N-1].emplace_back(N, OppoSide), G[N].emplace_back(N-1, OppoSide);
        N++;
      } else {
        MP[make_pair(Y[i]+1, X[i])] = N;
        CD[N] = make_pair(Y[i]+1, X[i]);
        G[N-1].emplace_back(N, OppoSide), G[N].emplace_back(N-1, OppoSide);
        N++;
      }
    }

    rep(i, N) {
      auto curr = CD[i];
      rep(k, 4) {
        auto next = make_pair(CD[i].first + dy[k], CD[i].second + dx[k]);
        if(MP.find(next) == MP.end()) continue; // テ・ツクツε・ツ崢」テ」ツ??」ツ?妥ィツェツソテ」ツ?ケテ」ツつ古」ツ?ーOK
        if(find(all(G[i]), make_pair(MP[next], OppoSide)) != G[i].end()) continue;  // テ・ツ按・テ」ツ?ョテ・ツクツε・ツ崢」テ」ツ?ッSameSideテ」ツ?療」ツ?凝・ツ?・テ」ツつ古」ツつ暗」ツ??」ツ?ィテ」ツ?療」ツ?ェテ」ツ??」ツ?凝」ツつ碓K
        G[i].emplace_back(MP[next], SameSide);
      }
    }

    minus(vis);

    bool ok = 1;

    rep(i, N) {
      if(vis[i] < 0) {
        vis[i] = 0;
        if(!dfs(i, 0)) {
          ok = 0;
          break;
        }
      }
    }

    cout << (ok ? "Yes" : "No") << endl;

  }
  return 0;
}