/* Codeforces Round 986 (Div. 2) Problem : https://codeforces.com/contest/2028/problem/A Solution: https://aruljohn.com/blog/alice-adventures-in-chess-problem/ */ #include #include using namespace std; // Return YES or NO string do_it(int a, int b, string s) { int x, y; x = y = 0; for (int i=0; i < 50; i++) { for (int j=0; j < s.length(); j++) { switch(s[j]) { case 'N': y++; break; case 'S': y--; break; case 'E': x++; break; case 'W': x--; break; default: break; } // Check if they are on the same coordinate if (x == a && y == b) { return "YES"; } } } return "NO"; } // Main function int main() { int t; cin >> t; for (int i=0; i < t; i++) { int n, a, b; string s; cin >> n >> a >> b; cin >> s; cout << do_it(a, b, s) << "\n"; } }