import java.io.File;
import java.io.FileNotFoundException;
import java.sql.SQLOutput;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * User: student
 * Date: 10.11.13
 * Time: 11:33
 * To change this template use File | Settings | File Templates.
 */
public class E {

    static boolean set = false;
    static String PATH;

    static int L;
    static int S;
    static int F;
    static int N;

    static int ns[];

    static long count = 0;

    static Map<Integer, Solution> map = new HashMap<Integer, Solution>();

    static class Solution
    {
        Solution(long c, String p)
        {
            count = c;
            path = p;
        }
        long count;
        String path;
    }
    static Solution solve(int n, int s) {
        Integer idx = n*1000 + s;
        if (map.containsKey(idx)) {
            return map.get(idx);
        }

        Solution solution;

        //System.out.println(" n " + n + " " + s);
        if (n == N && s == F) {
            solution = new Solution(1, "");
        } else if (n == N) {
            solution= new Solution(0, "");
        } else {
            int cur = ns[n];
            int down = s  - cur;
            if (down <= 0) {
                down = L + down % L;
            }

            int up = s + cur;
            if (up > L) {
                up = (up-1) % L + 1;
            }

            Solution solD = solve(n+1, down);
            Solution solU = solve(n+1, up);
            //System.out.println(" d " + solD.path + " " + solD.count);
            //System.out.println(" u " + solU.path + " " + solU.count);
            if (solD.count > 0) solution =new  Solution(solD.count + solU.count, "D" + solD.path);
            else if (solU.count > 0) solution=  new Solution(solD.count + solU.count, "U" + solU.path);
            else solution = new Solution(0, "");
        }

        map.put(idx, solution);

        return solution;
    }

    public static void main(String[] args) throws FileNotFoundException {
        Scanner scanner = new Scanner(new File("HACK.IN"));

        int T = scanner.nextInt();

        for (int i = 0; i < T; i++) {
            map = new HashMap<Integer, Solution>();

            L = scanner.nextInt();
            S = scanner.nextInt();
            F = scanner.nextInt();
            N = scanner.nextInt();

            ns = new int[N];
            set = false;
            count = 0;
            PATH = "";

            for (int j = 0; j < N; j++) {
               ns[j] = scanner.nextInt();
            }

            Solution solve = solve(0, S);

            System.out.println(solve.count + " " +solve.path);

            //System.out.println(-5 %1);
        }
    }

}
