#include using namespace std; #define rep(i,n) for (int i = 0; i < (n); i++) template inline bool chmax(T &a, T b) {return ((a < b) ? (a = b, true) : (false));} template inline bool chmin(T &a, T b) {return ((a > b) ? (a = b, true) : (false));} typedef long long ll; typedef pair P; int main() { ll t; cin >> t; vector x(2*t), y(2*t); vector d(2*t); rep(i,2*t) cin >> x[i] >> y[i] >> d[i]; rep(i,t) { ll p1 = 2*i, p2 = 2*i+1; if(d[p1] == 'R') { if(d[p2] == 'R') { cout << "No" << endl; } if(d[p2] == 'L') { if(x[p1] < x[p2] && y[p1] == y[p2]) { cout << "Yes" << endl; } else { cout << "No" << endl; } } if(d[p2] == 'U') { ll dx = x[p2]-x[p1], dy = y[p1]-y[p2]; if(dx > 0 && dx == dy) { cout << "Yes" << endl; } else { cout << "No" << endl; } } if(d[p2] == 'D') { ll dx = x[p2]-x[p1], dy = y[p2]-x[p1]; if(dx > 0 && dx == dy) { cout << "Yes" << endl; } else { cout << "No" << endl; } } } if(d[p1] == 'L') { if(d[p2] == 'R') { if(x[p1] > x[p2] && y[p1] == y[p2]) { cout << "Yes" << endl; } else { cout << "No" << endl; } } if(d[p2] == 'L') { cout << "No" << endl; } if(d[p2] == 'U') { ll dx = x[p1]-x[p2], dy = y[p1]-y[p2]; if(dx > 0 && dx == dy) { cout << "Yes" << endl; } else { cout << "No" << endl; } } if(d[p2] == 'D') { ll dx = x[p1]-x[p2], dy = y[p2]-y[p1]; if(dx > 0 && dx == dy) { cout << "Yes" << endl; } else { cout << "No" << endl; } } } if(d[p1] == 'U') { if(d[p2] == 'R') { ll dx = x[p1]-x[p2], dy = y[p2]-y[p1]; if(dx > 0 && dx == dy) { cout << "Yes" << endl; } else { cout << "No" << endl; } } if(d[p2] == 'L') { ll dx = x[p2]-x[p1], dy = y[p2]-y[p1]; if(dx > 0 && dx == dy) { cout << "Yes" << endl; } else { cout << "No" << endl; } } if(d[p2] == 'U') { cout << "No" << endl; } if(d[p2] == 'D') { if(x[p1] == x[p2] && y[p1] < y[p2]) { cout << "Yes" << endl; } else { cout << "No" << endl; } } } if(d[p1] == 'D') { if(d[p2] == 'R') { ll dx = x[p1]-x[p2], dy = y[p1]-y[p2]; if(dx > 0 && dx == dy) { cout << "Yes" << endl; } else { cout << "No" << endl; } } if(d[p2] == 'L') { ll dx = x[p2]-x[p1], dy = y[p1]-y[p2]; if(dx > 0 && dx == dy) { cout << "Yes" << endl; } else { cout << "No" << endl; } } if(d[p2] == 'U') { if(x[p1] == x[p2] && y[p1] > y[p2]) { cout << "Yes" << endl; } else { cout << "No" << endl; } } if(d[p2] == 'D') { cout << "No" << endl; } } } return 0; }