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.*;
import java.util.ArrayList;
import java.util.HashMap;
//import java.util.Map;
//import robot.RobotClass.Robot;
//package robot;
import java.util.Collections;
public class Main{
    public static void main(String[] args) throws IOException{
        ArrayList<Object> output = new ArrayList<Object>();
        BufferedReader keyb = new BufferedReader(new InputStreamReader(System.in));
        Integer q = Integer.parseInt(keyb.readLine());
        while(q > 0){
            String instruction = keyb.readLine();
            String solution = Handler.solveIt(instruction);
            output.add(solution.length());
            output.add(solution);
            q = q - 1;
        }
        for (Object object : output) {
            System.out.println(object);
            
        } 
    }
}
class Position{
    public Position(int x, int y){
        this.x = x;
        this.y = y;
    }
    public void increaseX(int increaseValue){
        this.x = this.x + increaseValue;
    }
    public void increaseY(int increaseValue){
        this.y = this.y + increaseValue;
    }

    public int getX(){
        return this.x;
    }
    public int getY(){
        return this.y;
    }

    private int x;
    private int y;
}

class Handler{
    public interface Robot{ //interfae para ambos tipos de robot
        public Position searchProblem(String instruction);
    }
    static class AlphaRobot implements Robot{ //this class will model the simple robot
        public AlphaRobot(){
            this.pos = new Position(0, 0); //todos parten en el inicio 0,0
            states = new ArrayList<Position>(); //acá almacenaré las posiciones por las que ha pasado el robot
            //states.add(pos); no la agregaré para que así poder usar la condición de updatePos
        }
        public Position searchProblem(String instruction){
            for(int i = 0; i < instruction.length(); i++){ //recorreré el string de instrucciones
                char order = instruction.charAt(i); //almacena una orden (char)
                if(order == 'U'){
                    pos.increaseY(1);
                }
                if(order == 'D'){
                    pos.increaseY(-1);
                }
                if(order == 'R'){
                    pos.increaseX(1);
                }
                if(order == 'L'){
                    pos.increaseX(-1);
                }
                //en este punto estáre en una nueva posición
                //if(pos.getX() == 0 && pos.getY() == 0){}
                if(!this.visited(pos)){ //si es que no la he visitado
                    states.add(new Position(pos.getX(), pos.getY())); //la agrego
                }
                else{
                    return pos; //de lo contrario, encontré la posición en la cual hay problema
                }
            }
            //si llego a este punto => no problemas en la ruta
            //como ya revisé si llegué al i
            return null; //esto significa que salió todo bien
        }
        public boolean visited(Position pos){
            for(Position position : states) {
                if((position.getX() == pos.getX()) && (position.getY() == pos.getY())){
                    return true;
                }  
            }
            return false;
        }
    
        private Position pos;
        private ArrayList<Position> states;
    }
    public static String solveIt(String instruction){
        AlphaRobot robot = new AlphaRobot();
        HashMap<String, Integer> info = getInfo(instruction);
        if(endsCorrectly(info)){
            Position problem = robot.searchProblem(instruction);
            if(problem == null){ //es decir, no hay problema
                return instruction;
            }
            else{
                //en este caso consto de correcta cantidad de ordenes, pero hay al menos un error del tipo dos movimientos de x o dos de y consecutivos
                //System.out.println("The conflicting position is: (" + problem.getX() + "." + problem.getY() + ")");
                String new_instruction = "";
                if(info.get("U") == 0 && info.get("D") == 0){
                    return "LR";
                }
                else if(info.get("L") == 0 && info.get("R") == 0){
                    return "UD";

                }
                else{
                    new_instruction += String.join("", Collections.nCopies(info.get("U"), "U"));
                    new_instruction += String.join("", Collections.nCopies(info.get("R"), "R"));
                    new_instruction += String.join("", Collections.nCopies(info.get("D"), "D"));
                    new_instruction += String.join("", Collections.nCopies(info.get("L"), "L"));
                    /*while(info.get("U") > 0){
                        int currentValue = info.get("U");
                        info.replace("U", currentValue, currentValue - 1);
                        new_instruction = new_instruction + "U";
                    }
                    while(info.get("R") > 0){
                        int currentValue = info.get("R");
                        info.replace("R", currentValue, currentValue - 1);
                        new_instruction = new_instruction + "R";
                    }
                    while(info.get("D") > 0){
                        int currentValue = info.get("D");
                        info.replace("D", currentValue, currentValue - 1);
                        new_instruction = new_instruction + "D";
                    }
                    while(info.get("L") > 0){
                        int currentValue = info.get("L");
                        info.replace("L", currentValue, currentValue - 1);
                        new_instruction = new_instruction + "L";
                    }*/
                    //System.out.println(new_instruction.length());
                    //System.out.println(new_instruction);
                    return new_instruction;
                }
            }
        }
        else{
            //System.out.println("The final position isn't (0,0) in: " + instruction);
            //igualo la cantidad de U y D, y de L y R
            if(info.get("U") > info.get("D")){
                int dif = info.get("U") - info.get("D");
                int currentValue = info.get("U");
                info.replace("U", currentValue, currentValue - dif);
            }
            if(info.get("D") > info.get("U")){
                int dif = info.get("D") - info.get("U");
                int currentValue = info.get("D");
                info.replace("D", currentValue, currentValue - dif);
            }
            if(info.get("L") > info.get("R")){
                int dif = info.get("L") - info.get("R");
                int currentValue = info.get("L");
                info.replace("L", currentValue, currentValue - dif);
            }
            if(info.get("R") > info.get("L")){
                int dif = info.get("R") - info.get("L");
                int currentValue = info.get("R");
                info.replace("R", currentValue, currentValue - dif);
            }
            String new_instruction = "";
            if(info.get("U") == 0 && info.get("D") == 0 && info.get("L") == 0 && info.get("R") == 0){
                return "";
            }
            if(info.get("U") == 0){
                return "LR";
            }
            if(info.get("L") == 0){
                return "UD";
            }
            new_instruction += String.join("", Collections.nCopies(info.get("U"), "U"));
            new_instruction += String.join("", Collections.nCopies(info.get("R"), "R"));
            new_instruction += String.join("", Collections.nCopies(info.get("D"), "D"));
            new_instruction += String.join("", Collections.nCopies(info.get("L"), "L"));
            //info = Handler.getInfo(new_instruction);
            /*while(info.get("U") > 0){
                int currentValue = info.get("U");
                info.replace("U", currentValue, currentValue - 1);
                new_instruction = new_instruction + "U";
            }
            while(info.get("R") > 0){
                int currentValue = info.get("R");
                info.replace("R", currentValue, currentValue - 1);
                new_instruction = new_instruction + "R";
            }
            while(info.get("D") > 0){
                int currentValue = info.get("D");
                info.replace("D", currentValue, currentValue - 1);
                new_instruction = new_instruction + "D";
            }
            while(info.get("L") > 0){
                int currentValue = info.get("L");
                info.replace("L", currentValue, currentValue - 1);
                new_instruction = new_instruction + "L";
            }*/
            return new_instruction;
            //return Handler.solveIt(new_instruction); //ya no entrará acá pues ya hice que tuviera igual cantidad de L que de R y que de U que de D
        }

    }
    public static String read()throws IOException{
        String instruction = keyb.readLine();
        return instruction;
    }
    public static boolean endsCorrectly(HashMap<String, Integer> info){
        if(info.get("U") == info.get("D")){
            if(info.get("R") == info.get("L")){
                return true;
            }
        }
        return false;
    }

    public static HashMap<String, Integer> getInfo(String instruction){
        HashMap<String, Integer> info = new HashMap<>();
        info.put("U", 0);
        info.put("D", 0);
        info.put("R", 0);
        info.put("L", 0);
        for(int i = 0; i < instruction.length(); i++){
            String order = String.valueOf(instruction.charAt(i));
            int currentValue = info.get(order);
            info.replace(order, currentValue, currentValue + 1);   
        }
        return info;

    }
	static private BufferedReader keyb = new BufferedReader(new InputStreamReader(System.in));
}