Problem: Recently you have bought a snow walking robot and brought it home. Suppose your home is a cell (0, 0) on an infinite grid.

You also have the sequence of instructions of this robot. It is written as the string s consisting of characters 'L', 'R', 'U' and 'D'. If the robot is in the cell (x, y) right now, he can move to one of the adjacent cells (depending on the current instruction).

  * If the current instruction is 'L', then the robot can move to the left to (x - 1, y); 
  * if the current instruction is 'R', then the robot can move to the right to (x + 1, y); 
  * if the current instruction is 'U', then the robot can move to the top to (x, y + 1); 
  * if the current instruction is 'D', then the robot can move to the bottom to (x, y - 1). 



You've noticed the warning on the last page of the manual: if the robot visits some cell (except (0, 0)) twice then it breaks.

So the sequence of instructions is valid if the robot starts in the cell (0, 0), performs the given instructions, visits no cell other than (0, 0) two or more times and ends the path in the cell (0, 0). Also cell (0, 0) should be visited at most two times: at the beginning and at the end (if the path is empty then it is visited only once). For example, the following sequences of instructions are considered valid: "UD", "RL", "UUURULLDDDDLDDRRUU", and the following are considered invalid: "U" (the endpoint is not (0, 0)) and "UUDD" (the cell (0, 1) is visited twice).

The initial sequence of instructions, however, might be not valid. You don't want your robot to break so you decided to reprogram it in the following way: you will remove some (possibly, all or none) instructions from the initial sequence of instructions, then rearrange the remaining instructions as you wish and turn on your robot to move. 

Your task is to remove as few instructions from the initial sequence as possible and rearrange the remaining ones so that the sequence is valid. Report the valid sequence of the maximum length you can obtain.

Note that you can choose any order of remaining instructions (you don't need to minimize the number of swaps or any other similar metric).

You have to answer q independent test cases.

Input

The first line of the input contains one integer q (1 ≤ q ≤ 2 ⋅ 10^4) — the number of test cases.

The next q lines contain test cases. The i-th test case is given as the string s consisting of at least 1 and no more than 10^5 characters 'L', 'R', 'U' and 'D' — the initial sequence of instructions.

It is guaranteed that the sum of |s| (where |s| is the length of s) does not exceed 10^5 over all test cases (∑ |s| ≤ 10^5).

Output

For each test case print the answer on it. In the first line print the maximum number of remaining instructions. In the second line print the valid sequence of remaining instructions t the robot has to perform. The moves are performed from left to right in the order of the printed sequence. If there are several answers, you can print any. If the answer is 0, you are allowed to print an empty line (but you can don't print it).

Example

Input


6
LRU
DURLDRUDRULRDURDDL
LRUDDLRUDRUL
LLLLRRRR
URDUR
LLL


Output


2
LR
14
RUURDDDDLLLUUR
12
ULDDDRRRUULL
2
LR
2
UD
0

Note

There are only two possible answers in the first test case: "LR" and "RL".

The picture corresponding to the second test case:

<image> Note that the direction of traverse does not matter 

Another correct answer to the third test case: "URDDLLLUURDR".

Solution (in PYTHON3):

Solution:
"""n=int(input())
f=input().split(' ')
v=list()
max=0
for i in range(0,n):
    if int(f[i])>max:
        max=int(f[i])
    v.append(int(f[i]))

ans=0
#dp={i:0 for i in range(0,max+1)}
dp=dict()

for el in v:
    if el-1 not in dp:
        dp[el-1]=0
    dp[el]=dp[el-1]+1
    if dp[el]>ans:
        ans=dp[el]
        pred=el
sol=list()
i=n-1
for el in v[::-1]:
    if el==pred:
        sol.append(i+1)
        pred-=1
    i-=1
print(ans)
for i in sol[::-1]:
    print(i,end=' ')
"""

"""n=int(input())
f=input().split(' ')
f=[int(x) for x in f]

def deg3(x):
    y=0
    while x%3==0:
        y+=1
        x/=3
    return y

def comp(x,y):
    if x[0]!=y[0]:
        return x[0]>y[0]
    else:
        return x[1]<y[1]

v=[(-deg3(x),x) for x in f]
v=sorted(v)
sol=[x[1] for x in v]
for i in sol:
    print(i,end=' ')  """
"""import random

f = input().split(' ')
n = int(f[0])
k = int(f[1])
c = input().replace('\n','').split(' ')
f = [int(c[i]) for i in range(0,n)]

def quicksel(L, k):
    piv = random.choice(L)
    ls = [x for x in L if x < piv]
    eq = [x for x in L if x == piv]
    gr = [x for x in L if x > piv]
    if k <= len(ls):
        return quicksel(ls, k)
    elif k <= len(ls) + len(eq):
        return eq[0]
    else:
        return quicksel(gr, k - len(ls) - len(eq))


if k!=0:
    x = quicksel(f, k)
else:
    x = quicksel(f, 1)-1


cnt = 0
for i in f:
    if i <= x:
        cnt += 1


if (cnt != k) or x < 1 or x > 10 ** 9:
    print(-1)
else:
    print(x)"""

"""n=int(input())
sir=str(input())

def hashcode(s):
    return 31*(ord(s[0])-65)+ord(s[1])-65

def decode(cod):
    return (chr(cod//31+65),chr(cod%31+65))

v=dict()
maxsub=1
index=(sir[0],sir[1])
v[hashcode(index)]=1
for i in range(1,len(sir)-1):
    t=(sir[i],sir[i+1])
    cod=hashcode(t)
    if cod not in v:
        v[cod]=1
    else:
        v[cod]+=1
        if v[cod]>maxsub:
            maxsub=v[cod]
            index=decode(cod)
sol=''.join(index)
print(sol)"""
"""import queue
from collections import defaultdict
f = input().split(' ')
n = int(f[0])
m = int(f[1])
g={i:list() for i in range(1,n+1)}
deg={i:0 for i in range(1,n+1)}
for i in range(0,m):
    c = input().replace('\n','').split(' ')
    x=int(c[0])
    y=int(c[1])
    g[x].append(y)
    g[y].append(x)
    deg[x]+=1
    deg[y]+=1

viz=[0]*(n+1)
comp=list()

def bfs(x):
    vef=True
    q=queue.Queue(n)
    q.put(x)
    if deg[x]!=2:
        vef = False
    comp.append(x)
    viz[x]=1
    while q.empty()==False:
        u=q.get()
        for i in g[u]:
            if viz[i]==0:
                if deg[i]!=2:
                    vef=False
                q.put(i)
                viz[i]=1
                comp.append(i)
    return vef==True

def dfs(x):
    viz[x]=1
    comp.append(x)
    for u in g[x]:
        if viz[u]==0:
            dfs(u)

sol=0
for i in range(1,n+1):
    if viz[i]==0:
        comp.clear()
        sol+=bfs(i)
        #dfs(i)
        '''for j in comp:
            vef=(vef and deg[j]==2)
            if vef==False:
                break'''

print(sol)"""


"""def lisa(arr,n):
    m = 1
    l = 1
    for i in range(1, n):
        if (arr[i] > arr[i - 1]) :
            l = l + 1
        else:
            if (m < l):
                m = l
            l = 1
    if (m < l):
        m = l
    return m

n=int(input())
f=input().split(' ')
a=[int(f[i]) for i in range(0,n)]
ans=0
for i in range(0,n):
    arr=[]
    for j in range(0,i):
        arr.append(a[j])
    for j in range(i+1,n):
        arr.append(a[j])
    ans=max(ans,lisa(arr,n-1))
ans=max(ans,lisa(a,n))
print(ans,end='')"""

#print(lisa(a,n))

"""n=int(input())
f=input().split(' ')
a=[int(f[i]) for i in range(0,n)]
pred=[0]*n
suc=[0]*n
ans=0
pred[0]=1
for i in range(1,n):
    if a[i]>a[i-1]:
        pred[i]=pred[i-1]+1
    else:
        pred[i]=1
    ans=max(ans,pred[i])
suc[n-1]=1
i=n-2
while i>=0:
    if a[i+1]>a[i]:
        suc[i]=suc[i+1]+1
    else:
        suc[i]=1
    i-=1

for i in range(1,n-1):
    if a[i-1]<a[i+1]:
        ans=max(ans,pred[i-1]+suc[i+1])
print(ans,end='')"""

'''f=input().split(' ')
n=int(f[0])
k=int(f[1])
s=str(input().replace('\n',''))
c=input().split(' ')
sol=0
sp=0
for ch in s:
    if ch in c:
        sp+=1
        sol+=sp
    else:
        sp=0
print(sol)'''

"""from collections import defaultdict
import queue
n=int(input())
f=input().split(' ')
a=[int(f[i]) for i in range(0,n)]
par=[]
mar=[]
ans=[-1]*n
gt={i:[] for i in range(0,n)}

for i in range(0,n):
    if a[i]%2==0:
        par.append(i)
    else:
        mar.append(i)
    if i-a[i]>=0:
        gt[i-a[i]].append(i)
    if i+a[i]<n:
        gt[i+a[i]].append(i)

def bfs(s,parity):
    q1=[]
    for i in s:
        q1.append(i)
    d=[0 if i in s else -1 for i in range(0,n)]
    f=0
    while f<len(q1):
        u=q1[f]
        f+=1
        for i in gt[u]:
            if d[i]==-1:
                d[i]=d[u]+1
                q1.append(i)
    for i in parity:
        ans[i]=d[i]

bfs(par,mar)
bfs(mar,par)
print(*ans)"""

q=int(input())
for i in range(0,q):
    s=str(input())
    m={c:0 for c in ['L','U','D','R']}
    #for c in ['L', 'U', 'D', 'R']:
        #m[c]=s.count(c)
    for c in s:
        m[c]+=1
    a=min(m['L'],m['R'])
    b=min(m['U'],m['D'])
    if a == 0 and b == 0:
        print("0")
        print("")
    elif a==0 or b==0:
        if a==0:
            print(str(2*min(b,1)))
            print('UD')
        else:
            print(str(2*min(a,1)))
            print('LR')
    else:
        s=2*(a+b)
        print(str(s))
        ans=str()
        for i in range(0,a):
            ans+='L'
        for i in range(0,b):
            ans+='U'
        for i in range(0,a):
            ans+='R'
        for i in range(0,b):
            ans+='D'
        print(ans)