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

int main()
{
    ios::sync_with_stdio(0),cin.tie();
    int t;
    cin >> t;
    while(t--)
    {
        string s;
        cin >> s;
        int x = 0,y = 0,idx = -1;
        pair<int,int> res;
        res = {0, 0};
        for(int i = 0; i < s.size(); i++)
        {
            x = y = 0;
            for (int j = 0; j <= i; j++)
            {
                x += (s[j] == 'R');
                x -= (s[j] == 'L');
                y += (s[j] == 'U');
                y -= (s[j] == 'D');
            }
            int curx = x, cury = y;
            x = y = 0;
            for (int j = 0; j < s.size(); j++)
            {
                int x1 = x, y1 = y;
                x1 += (s[j] == 'R');
                x1 -= (s[j] == 'L');
                y1 += (s[j] == 'U');
                y1 -= (s[j] == 'D');
                if (x1 != curx || y1 != cury)
                {
                    x = x1;
                    y = y1;
                }
            }
            if (x == 0 && y == 0)
            {
                res = {curx, cury};
                break;
            }
        }
        cout << res.first << " " << res.second << endl;

    }

    return 0;
}
