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 JAVA):

Solution:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.ArrayList;
import java.util.List;

public class Final{
    public static void main(String[] args){
        Handler hd = new Handler();
        System.out.print(hd.getFinalIns());
    }
}

interface Robot{
    public void repairQuantity();
    public void correctPath();
    public int getStringSize();
    public String getModPath();
}

class Handler{
    private static final String mod_robot = "([UDLR][12])+";
    private static final String normal_robot = "[UDLR]+";
    private String final_instructions;
    

    public Handler(){
        StringBuilder ret = new StringBuilder();
        Reader input = new Reader();
        String line_buffer;
        Robot robot_buffer;

        int queries = input.nextInt();
        for(int i=0; i<queries; i++){
            line_buffer = input.nextLine();
            if(line_buffer.matches(normal_robot)){
                robot_buffer = new SimpleRobot(line_buffer);
            } else if(line_buffer.matches(mod_robot)){
                robot_buffer = new JumpRobot(line_buffer);
            } else{
                continue;
            }
            robot_buffer.repairQuantity();
            robot_buffer.correctPath();
            ret.append(robot_buffer.getStringSize()).append("\n");
            ret.append(robot_buffer.getModPath()).append("\n");
        }

        this.final_instructions = ret.toString();
    }

    public String getFinalIns(){
        return this.final_instructions;
    }

    class Reader{
        BufferedReader br;
        StringTokenizer st;
    
        public Reader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }
    
        String next(){
            while(st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                } catch(IOException e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
    
        int nextInt(){
            return Integer.parseInt(next());
        }
    
        String nextLine(){
            String str = "";
            try{
                str = br.readLine();
            } catch(IOException e){
                e.printStackTrace();
            }
            return str;
        }
    }
}

class SimpleRobot implements Robot{
    private int u, d, l, r;
    private char[] moves;
    private String modified_instructions;

    public SimpleRobot(String movement){
        this.moves = movement.toCharArray();
        this.u = 0; this.d = 0;
        this.l = 0; this.r = 0;

        for(char c : this.moves){
            if(c == 'U') this.u += 1;
            else if(c == 'D') this.d += 1;
            else if(c == 'L') this.l += 1;
            else if(c == 'R') this.r += 1;
            else System.out.println("Char not available");
        }
    }

    public void repairQuantity(){
        int ud_diff = this.u-this.d;
        int lr_diff = this.l-this.r;

        if(ud_diff > 0) this.u -= ud_diff;
        else this.d += ud_diff;

        if(lr_diff > 0) this.l -= lr_diff;
        else this.r += lr_diff;

        if(this.r > 1 && this.d == 0){
            //if not U and D options in the final result, unique case is L+R+, so the unique options is RL or LR
            this.r = 1; this.l = 1;
        } else if(this.u > 1 && this.l == 0){
            //same the last, but with UD or DU
            this.u = 1; this.d = 1;
        }
    }

    public void correctPath(){
        StringBuilder str = new StringBuilder();
        for(int i=0; i<this.u; i++) str.append("U");
        for(int i=0; i<this.r; i++) str.append("R");
        for(int i=0; i<this.d; i++) str.append("D");
        for(int i=0; i<this.l; i++) str.append("L");
        
        this.modified_instructions = str.toString();
    }

    public int getStringSize(){
        return this.modified_instructions.length();
    }
    public String getModPath(){
        return this.modified_instructions;
    }
}

class JumpRobot implements Robot{
    private List<String> u_list, d_list, l_list, r_list;
    private int u, d, l, r;
    private String modified_instructions;

    public JumpRobot(String movement){
        final int STR_SIZE = movement.length();
        final char[] moves = movement.toCharArray();

        u_list = new ArrayList<>();
        d_list = new ArrayList<>();
        l_list = new ArrayList<>();
        r_list = new ArrayList<>();
        u = 0; d = 0;
        l = 0; r = 0;

        char[] b = new char[2];
        for(int i=0; i<STR_SIZE; i+=2){
            b[0] = moves[i]; b[1] = moves[i+1];
            
            if(b[0] == 'U'){
                u_list.add(String.valueOf(b));
                u += Character.getNumericValue(b[1]);
            } else if(b[0] == 'D'){
                d_list.add(String.valueOf(b));
                d += Character.getNumericValue(b[1]);
            } else if(b[0] == 'L'){
                l_list.add(String.valueOf(b));
                l += Character.getNumericValue(b[1]);
            } else if(b[0] == 'R'){
                r_list.add(String.valueOf(b));
                r += Character.getNumericValue(b[1]);
            }
        }
    }

    public void repairQuantity(){
        int ud_diff = this.u-this.d;
        int lr_diff = this.l-this.r;

        while(Math.abs(ud_diff) > 0){
            if(ud_diff > 0){
                if(ud_diff % 2 == 0){
                    if(!u_list.remove("U2")){
                        u_list.remove("U1");
                        u_list.remove("U1");
                    }
                    this.u -= 2;
                } else{
                    if(!u_list.remove("U1")){
                        this.u -= 2;
                        u_list.remove("U2");
                    } else{
                        this.u -= 1;
                    }
                }
            } else{
                if(ud_diff % 2 == 0){
                    if(!d_list.remove("D2")){
                        d_list.remove("D1");
                        d_list.remove("D1");
                    }
                    this.d -= 2;
                } else{
                    if(!d_list.remove("D1")){
                        this.d -= 2;
                        d_list.remove("D2");
                    } else{
                        this.d -= 1;
                    }
                }
            }
            ud_diff = this.u-this.d;
        }

        while(Math.abs(lr_diff) > 0){
            if(lr_diff > 0){
                if(lr_diff % 2 == 0){
                    if(!l_list.remove("L2")){
                        l_list.remove("L1");
                        l_list.remove("L1");
                    }
                    this.l -= 2;
                } else{
                    if(!l_list.remove("L1")){
                        this.l -= 2;
                        l_list.remove("L2");
                    } else{
                        this.l -= 1;
                    }
                }
            } else{
                if(lr_diff % 2 == 0){
                    if(!r_list.remove("R2")){
                        r_list.remove("R1");
                        r_list.remove("R1");
                    }
                    this.r -= 2;
                } else{
                    if(!r_list.remove("R1")){
                        this.r -= 2;
                        r_list.remove("R2");
                    } else{
                        this.r -= 1;
                    }
                }
            }
            lr_diff = this.l-this.r;
        }

        if(this.r > 1 && this.d <= 0){
            //if not U and D options in the final result, unique case is L+R+, so the unique options is R1L1 or L1R1
            while(r_list.remove("R2")){
                l_list.remove("L2");

                this.r -= 2;
                this.l -= 2;
            }
            while(this.r > 1){
                r_list.remove("R1");
                l_list.remove("L1");

                this.r -= 1;
                this.l -= 1;
            }
        } else if(this.u > 1 && this.l <= 0){
            //same the last, but with U1D1 or D1U1
            while(u_list.remove("U2")){
                d_list.remove("U2");

                this.u -= 2;
                this.d -= 2;
            }
            while(this.u > 1){
                u_list.remove("U1");
                d_list.remove("D1");

                this.r -= 1;
                this.l -= 1;
            }
        }
    }

    public void correctPath(){
        StringBuilder str = new StringBuilder();
        for(String m : this.u_list) str.append(m);
        for(String m : this.r_list) str.append(m);
        for(String m : this.d_list) str.append(m);
        for(String m : this.l_list) str.append(m);
        
        this.modified_instructions = str.toString();
    }

    public int getStringSize(){
        return this.modified_instructions.length()/2;
    }
    public String getModPath(){
        return this.modified_instructions;
    }
}