#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t;
    cin >> t;

    while (t--) {
        int n;
        string s;
        cin >> n >> s;

        int x = 0, y = 0;
        for (char move : s) {
            if (move == 'U') y++;
            else if (move == 'D') y--;
            else if (move == 'L') x--;
            else x++;
        }

        if ((abs(x) == 2 && y == 0) || (abs(y) == 2 && x == 0))  cout << "YES\n";
        else  cout << "NO\n";
    }
}
