#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 ex = 0, ey = 0; set st_x, st_y; if(d[2*i] == 'U' || d[2*i] == 'D') { ex = x[2*i]; st_x.insert(ex); } if(d[2*i] == 'L' || d[2*i] == 'R') { ey = y[2*i]; st_y.insert(ey); } if(d[2*i+1] == 'U' || d[2*i+1] == 'D') { ex = x[2*i+1]; st_x.insert(ex); } if(d[2*i+1] == 'L' || d[2*i+1] == 'R') { ey = y[2*i+1]; st_y.insert(ey); } if(st_x.size() > 1 || st_y.size() > 1) { cout << "No" << endl; } else if(st_x.size() == 0 || st_y.size() == 0) { if(d[2*i] != d[2*i+1]) { cout << "Yes" << endl; } else { cout << "No" << endl; } } else { ll t1 = abs(x[2*i]-ex) + abs(y[2*i]-ey); ll t2 = abs(x[2*i+1]-ex) + abs(y[2*i+1]-ey); if(t1 == t2) { if(d[2*i] == 'R' && ex < x[2*i]) { cout << "No" << endl; } else if(d[2*i] == 'L' && ex > x[2*i]) { cout << "No" << endl; } else if(d[2*i] == 'U' && ey < y[2*i]) { cout << "No" << endl; } else if(d[2*i] == 'D' && ey > y[2*i]) { cout << "No" << endl; } else if(d[2*i+1] == 'R' && ex < x[2*i+1]) { cout << "No" << endl; } else if(d[2*i+1] == 'L' && ex > x[2*i+1]) { cout << "No" << endl; } else if(d[2*i+1] == 'U' && ey < y[2*i+1]) { cout << "No" << endl; } else if(d[2*i+1] == 'D' && ey > y[2*i+1]) { cout << "No" << endl; } else { cout << "Yes" << endl; } } else { cout << "No" << endl; } } } return 0; }