#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define sz size()
#define ff first
#define ss second
#define mod 1000000007
#define pie 3.14159265359
#define minheap priority_queue<int , vector<int> , greater<int> > 
#define maxheap priority_queue<int> 	
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;
int main()			
{
	fast;
	ll t;
	cin>>t;
	while(t--)
	{
		string s;
		cin>>s;
		bool con=false;
		ll x=0,y=0;
		ll curx=0,cury=0;
		ll i,j,n;
		n=s.length();
		for(i=0;i<n;i++)
		{
			if(s[i]=='L')
			{
				curx--;
			}
			if(s[i]=='R')
			{
				curx++;
			}
			if(s[i]=='D')
			{
				cury--;
			}
			if(s[i]=='U')
			{
				cury++;
			}
			x=curx;
			y=cury;
			if(x==0 && y==0)
			continue;
			ll tx=0,ty=0;
			ll fx=0,fy=0;
			for(j=0;j<n;j++)
			{
				fx=tx,fy=ty;
			if(s[j]=='L')
			{
				fx--;
			}
			if(s[j]=='R')
			{
				fx++;
			}
			if(s[j]=='D')
			{
				fy--;
			}
			if(s[j]=='U')
			{
				fy++;
			}
			if(fx==x && fy==y)
			{
				continue;
			}
			tx=fx;
			ty=fy;
			}
			if(tx==0 && ty==0)
			{
				con=true;
				break;
			}
		}
		if(con)
		{
			cout<<x<<" "<<y<<"\n";
		}
		else
		{
			cout<<"0 0 \n";
		}
	}
}