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 \le q \le 2 \cdot 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 ($\sum |s| \le 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".

Difficulty: introductory

Starter code:

Solutions:
n = int(input())
for _ in range(n):
    s = input()
    l,r,u,d = [s.count(i) for i in 'LRUD']
    lr = min(l, r)
    ud = min(u, d)
    res = ""
    if lr == 0 and ud == 0:
        res = ""
    elif lr == 0:
        res = "UD"
    elif ud == 0:
        res = 'LR'
    else:
        res = 'R' * lr + 'U' * ud + 'L' * lr + 'D' * ud
    print(len(res))
    print(res)

for _ in range(int(input())):
	s=input()
	cnt=[0,0,0,0]
	for i in s:
		if i=='L':
			cnt[0]+=1
		elif i=='R':
			cnt[1]+=1
		elif i=='U':
			cnt[2]+=1
		else:
			cnt[3]+=1
	x=min(cnt[0],cnt[1])
	y=min(cnt[2],cnt[3])
	if x==0:
		if y==0:
			print("0")
		else:
			print("2\nDU")
	elif y==0:
		print("2\nLR")
	else:
		print(2*(x+y))
		print("L"*x  + "D"*y + "R"*x + "U"*y)

import collections
t = int(input())
for i in range(t):
    s = list(input())
    c = collections.Counter(s)
    L, R, U, D = c['L'], c['R'], c['U'], c['D']
    if (L == 0 or R == 0) and (U == 0 or D == 0):
        print(0)
    elif L == 0 or R == 0:
        print(2)
        print('UD')
    elif U == 0 or D == 0:
        print(2)
        print('LR')
    else:
        p, q = min(L, R), min(U, D)
        print(2 * p + 2 * q)
        print(p * 'L' + q * 'U' + p * 'R' + q * 'D')


def main():
    buf = input()
    q = int(buf)
    s = []
    n = []
    for t in range(q):
        buf = input()
        s.append(buf)
        n.append(len(s[t]))

    ans = []
    for t in range(q):
        c = {'L':0, 'R':0, 'U':0, 'D':0}
        for i in range(n[t]):
            c[s[t][i]] += 1
        lr_min = min(c['L'], c['R'])
        ud_min = min(c['U'], c['D'])
        if lr_min == 0 and ud_min > 1:
            ud_min = 1
        if ud_min == 0 and lr_min > 1:
            lr_min = 1
        c['L'] = lr_min
        c['R'] = lr_min
        c['U'] = ud_min
        c['D'] = ud_min
        move = ''
        move += 'L' * lr_min
        move += 'U' * ud_min
        move += 'R' * lr_min
        move += 'D' * ud_min
        ans.append(move)
    for t in range(q):
        print(len(ans[t]))
        print(ans[t])

def __starting_point():
    main()

__starting_point()

q = int(input())
while q:
    s = input()
    m = {}
    m['D'] = 0
    m['U'] = 0
    m['L'] = 0
    m['R'] = 0
    for i in s:
        m[i] += 1
    k = min(m['D'], m['U'])
    m['D'] = k
    m['U'] = k
    k1 = min(m['L'], m['R'])
    m['L'] = k1
    m['R'] = k1
    if m['D'] == 0:
        m['L'] = min(1, m['L'])
        m['R'] = m['L']
    if m['L'] == 0:
        m['D'] = min(m['D'], 1)
        m['U'] = m['D']

    print(m['L'] + m['D'] + m['R'] + m["U"])
    print('L' * m['L'], end='')
    print('U' * m['U'], end='')
    print('R' * m['R'], end='')
    print('D' * m['D'])
    q -= 1

#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	Q = int(input())
	for i in range(Q):
		s = input()
		L = 0; R = 0; U = 0; D = 0;
		for j in s:
			if j == "L":
				L += 1
			elif j == "R":
				R += 1
			elif j == "U":
				U += 1
			else:
				D += 1
		a = min(L, R)
		b = min(U, D)
		if a == 0 and b == 0:
			print(0)
			print("")
		elif a == 0:
			print(2)
			print("UD")
		elif b == 0:
			print(2)
			print("LR")
		else:
			ans = (a + b) * 2
			print(ans)
			seq = "L" * a + "D" * b + "R" * a + "U" * b
			print(seq)

def __starting_point():
	main()
__starting_point()

for _ in range(int(input())):
    l, r, u, d = 0, 0, 0, 0
    s = list(input())
    for i in s:
        if i == 'L':
            l += 1
        elif i == 'R':
            r += 1
        elif i == 'U':
            u += 1
        else:
            d += 1
    d = min(d, u)
    r = min(r, l)
    if d == 0 and r == 0:
        print(0)
    elif d != 0 and r != 0:
        print(2*(d + r))
        print(d*'U'+r*'R'+d*'D'+r*'L')
    else:
        print(2)
        if d == 0:
            print('LR')
        else:
            print('UD')

from collections import Counter
test = int(input())
for _ in range(test):
    s=input()
    c = Counter(s)
    vertical = min(c['U'],c['D'])
    horizontal = min(c['L'],c['R'])
    if vertical==0 and horizontal==0:
        print(0)
    elif horizontal==0:
        print(2)
        print('UD')
    elif vertical==0:
        print(2)
        print('LR')
    else:
        print(2*(vertical+horizontal))
        print('L'*horizontal+'U'*vertical+'R'*horizontal+'D'*vertical)

t=int(input())
for nt in range(t):
	s=input()
	l,r,u,d=0,0,0,0
	for i in s:
		if i=="L":
			l+=1
		elif i=="R":
			r+=1
		elif i=="U":
			u+=1
		else:
			d+=1
	if l!=0 and r!=0 and u!=0 and d!=0:
		if l==r and u==d:
			print (len(s))
			for i in range(l):
				print ("L",end="")
			for i in range(u):
				print ("U",end="")
			for i in range(l):
				print ("R",end="")
			for i in range(d):
				print ("D",end="")
		else:
			if l==r:
				print (len(s)-abs(u-d))
				for i in range(l):
					print ("L",end="")
				for i in range(min(d,u)):
					print ("U",end="")
				for i in range(l):
					print ("R",end="")
				for i in range(min(d,u)):
					print ("D",end="")
			else:
				print (len(s)-(abs(u-d)+abs(l-r)))
				for i in range(min(l,r)):
					print ("L",end="")
				for i in range(min(d,u)):
					print ("U",end="")
				for i in range(min(l,r)):
					print ("R",end="")
				for i in range(min(d,u)):
					print ("D",end="")
		print ()
	else:
		if (l==0 or r==0) and (u!=0 and d!=0):
			print (2)
			print ("UD")
		elif (u==0 or d==0) and (l!=0 and r!=0):
			print (2)
			print ("LR")
		else:
			print (0)
			print ()

q = int(input());
for test in range(0,q):
    s = str(input());
    L = s.count('L');
    R = s.count('R');
    U = s.count('U');
    D = s.count('D');
    x = min(L, R);
    y = min(U, D);
    if x==0 and y==0:
        print("0");
    elif x==0:
        print("2");
        print("UD");
    elif y==0:
        print("2");
        print("LR");
    else:
        print((str(2*x+2*y)));
        ans = "";
        for i in range(0,y):
            ans+="U";
        for i in range(0,x):
            ans+="R";
        for i in range(0,y):
            ans+="D";
        for i in range(0,x):
            ans+="L";
        print(ans);


for _ in range(int(input())):
    s = input()
    l, r, d, u = s.count('L'), s.count('R'), s.count('D'), s.count('U')
    if max(min(d, u), min(l, r)) == 0:
        print(0)
        print()
        continue
    if min(d, u) == 0:
        print(2)
        print('LR')
        continue
    if min(l, r) == 0:
        print(2)
        print('DU')
        continue

    ans = 'L'*min(l, r) + 'D'*min(u, d) + 'R'*min(l, r) + 'U'*min(u, d)
    print(len(ans))
    print(ans)


import sys
input = sys.stdin.readline

q=int(input())

from collections import Counter

for test in range(q):
    S=input().strip()

    C=Counter(S)

    L=C["L"]
    R=C["R"]
    U=C["U"]
    D=C["D"]

    if U==0 or D==0:
        if L>0 and R>0:
            print(2)
            print("LR")
            continue
        else:
            print(0)
            continue

    elif L==0 or R==0:
        if U>0 and D>0:
            print(2)
            print("UD")
            continue
        else:
            print(0)
            continue

    else:
        MU=min(U,D)
        ML=min(L,R)

        ANS="U"*MU+"R"*ML+"D"*MU+"L"*ML

        print(len(ANS))
        print(ANS)
        

    


from math import *
import os, sys
from io import BytesIO

#input = BytesIO(os.read(0, os.fstat(0).st_size)).readline
for i in range(int(input())):
    s = input()
    d = {}
    d["L"] = 0
    d["R"] = 0
    d["U"] = 0
    d["D"] = 0
    for c in s:
        d[c] += 1
    if d["U"] == 0 or d["D"] == 0:
        d["U"] = 0 
        d["D"] = 0
    if d["R"] == 0 or d["L"] == 0:
        d["R"] = 0 
        d["L"] = 0
    
    if d["R"] == 0 or d["L"] == 0:
        if d["U"] != 0 and d["D"] != 0:
            print(2)
            print("UD")
            continue
        else:
            print(0)
            continue
    if d["U"] == 0 or d["D"] == 0:
        if d["L"] != 0 and d["R"] != 0:
            print(2)
            print("LR")
            continue
        else:
            print(0)
            continue
    else:
        x = min(d["U"], d["D"])
        y = min(d["L"], d["R"])
        print(2 * x + 2 * y)
        print("U" * x + "L" * y + "D" * x + "R" * y)


a = int(input())
for i in range(a):
    b = input()
    l = [0, 0, 0, 0]
    for i in b:
        if i == 'U':
            l[0] += 1
        elif i == 'D':
            l[1] += 1
        elif i == 'R':
            l[2] += 1
        else:
            l[3] += 1
    ans1 = min(l[0], l[1])
    ans2 = min(l[2], l[3])
    if ans1 != 0 and ans2 != 0:
        print(2*ans1 + 2*ans2)
        k = 'U' * ans1 + "R" * ans2 + "D" * ans1 + "L" * ans2
        print(k)
        
    else:
        if ans2 > 0:
            print(2)
            print('RL')
        elif ans1 > 0:
            print(2)
            print('UD')
        else:
            print(0)

from collections import Counter
T = int(input())
for t in range(T):
    C = Counter(input())
    left_right_min = min(C["L"], C["R"])
    up_down_min = min(C["U"], C["D"])
    if left_right_min == 0 and up_down_min == 0:
        print(0)
        print()
    elif left_right_min == 0:
        print(2)
        print("UD")
    elif up_down_min == 0:
        print(2)
        print("LR")
    else:
        print((left_right_min+up_down_min)*2)
        print(("L"*left_right_min+"D"*up_down_min +
              "R"*left_right_min+"U"*up_down_min))


from collections import Counter
T = int(input())
for t in range(T):
    C = Counter(input())
    left_right_min = min(C["L"], C["R"])
    up_down_min = min(C["U"], C["D"])
    if left_right_min == 0 and up_down_min == 0:
        print(0)
        print()
    elif left_right_min == 0:
        print(2)
        print("UD")
    elif up_down_min == 0:
        print(2)
        print("LR")
    else:
        print((left_right_min+up_down_min)*2)
        print(("L"*left_right_min+"D"*up_down_min +
              "R"*left_right_min+"U"*up_down_min))


q=int(input())
for _ in range(q):
	s=input()
	u,r,d,l=0,0,0,0
	for i in s:
		if i=='U':
			u+=1
		elif i=='R':
			r+=1
		elif i=='D':
			d+=1
		else:
			l+=1
	if min(l,r)==0:
		u=min(1,u)
		d=min(1,d)
	if min(u,d)==0:
		l=min(1,l)
		r=min(1,r)
	ans = 'L'*min(l,r)+'U'*min(u,d)+'R'*min(l,r) +'D'*min(u,d)
	print(len(ans))
	print(ans)
	


q=int(input())
for i in range(q):
    s=str(input())
    l,r,u,d=0,0,0,0
    for t in s:
        if t=='L':l+=1
        elif t=='U':u+=1
        elif t=='D':d+=1
        else:r+=1
    k=min(l,r);d=min(u,d)
    if d==0:
        if k!=0:
            print(2)
            print('LR')
        else:
            print(0)
    elif k==0:
        if d!=0:
            print(2)
            print('UD')
        else:
            print(0)
    else:
        print(k*2+d*2)
        print('L'*k+'U'*d+'R'*k+'D'*d)