import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * User: student
 * Date: 10.11.13
 * Time: 10:06
 * To change this template use File | Settings | File Templates.
 */
public class Main {
    public static void main(String[] args) throws Exception {
        solveE();
    }

//    static void solveC() throws Exception {
//        in = new BufferedReader(new FileReader(new File("FLOAT.IN")));
//        int t = F.nextInt();
//        for (int tt = 0 ; tt < t ; tt++) {
//            int p = F.nextInt(), q = F.nextInt();
//            println(q - p + 1);
//        }
//    }
    static int abs(int n, int k) { if (n < 0) n += k; return n % k == 0 ? k : n % k; }
    static void solveE() throws Exception {
        in = new BufferedReader(new FileReader(new File("HACK.IN")));
        int t = F.nextInt();
        for (int tt = 0 ; tt < t ; tt++) {
            int l = F.nextInt(), s = F.nextInt(), f = F.nextInt(), n = F.nextInt();
            int[] data = new int[n];

            for (int i = 0 ; i < n ; i++) {
                data[i] = F.nextInt();
            }

            List<Pair> A = new ArrayList<Pair>();
            int i1 = abs(data[0] + s, l), i2 = abs(s - data[0], l);

            if (i1 == i2) {
                Pair p = new Pair(i1, "D", 2);
                A.add(p);
            } else {
                Pair p1 = new Pair(abs(data[0] + s, l), "U");
                A.add(p1);

                Pair p2 = new Pair(abs(s - data[0], l), "D");
                A.add(p2);
            }

            for (int i = 1 ; i < n ; i++) {
                List<Pair> nextA = new ArrayList<Pair>();

                for (int j = 0 ; j < A.size() ; j++) {
                    Pair curr = A.get(j);

                    int nextU = abs(curr.x + data[i], l);
                    boolean exists = false;
                    for (Pair p : nextA) {
                        if (p.x == nextU) {
                            exists = true;
                            p.setMin(curr.min + "U");
                            p.count += curr.count;
                            break;
                        }
                    }
                    if (!exists) {
                        Pair p = new Pair(nextU, curr.min + "U", curr.count);
                        nextA.add(p);
                    }

                    int nextD = abs(curr.x - data[i], l);
                    exists = false;
                    for (Pair p : nextA) {
                        if (p.x == nextD) {
                            exists = true;
                            p.setMin(curr.min + "D");
                            p.count += curr.count;
                            break;
                        }
                    }
                    if (!exists) {
                        Pair p = new Pair(nextD, curr.min + "D", curr.count);
                        nextA.add(p);
                    }
                }

                //println(nextA);
                A = nextA;
            }

            long answer1 = 0;
            String answer = null;

            for (Pair p : A) {
                if (p.x == f) {
                    answer1 = p.count;
                    answer = p.min;
                    break;
                }
            }

            //println(A);
            if (answer == null) {
                println(0);
            } else {
                println(answer1 + " " + answer);
            }
        }
    }
    static void solveJ() throws Exception {
        in = new BufferedReader(new FileReader(new File("TOWER.IN")));
        int t = F.nextInt();

        for (int tt = 0 ; tt < t ; tt++) {
            int h = F.nextInt(), l = F.nextInt();
            List<Triple> A = new ArrayList<Triple>();

            for (int i = 0 ; i < h ; i++) {

                for (int j = 0 ; j < l ; j++) {
                    int curr = F.nextInt();
                    if (curr > -1) {
                        Triple tr = new Triple();
                        tr.x = curr;
                        tr.y = i;
                        tr.z = j;

                        A.add(tr);
                    }
                }
            }

            Collections.sort(A, new Comparator<Triple>() {
                public int compare(Triple o1, Triple o2) {
                    if (o1.x < o2.x) return -1;
                    else if (o1.x == o2.x) return 0;
                    else return 1;
                }
            });

            int result = 0;
            for (Triple curr : A) {
                result += curr.y * 2 * 10 + (curr.z + 1) * 2 * 5;
                println(result);
            }

            System.out.println("x " + result);
        }
    }

    static class Pair {
        int x;
        String min;
        public Pair(int x, String min) {
            this.x = x;
            this.min = min;
        }
        public Pair(int x, String min, long count) {
            this.x = x;
            this.min = min;
            this.count = count;
        }
        long count = 1;
        public String toString() {return x + " " + min + " " + count;}
        public void setMin(String s) {
            if (s.compareTo(min) < 0 || min == null) min = s;
        }
    }
    static class Triple {
        int x, y, z;
        public String toString() {return x + " " + y + " " + z;}
    }
    static void println(Object o) {
        System.out.println(o);
    }
    static BufferedReader in;
    static class F {
        static StringTokenizer st;
        static String nextToken() throws Exception {
            if (st == null || !st.hasMoreTokens()) st = new StringTokenizer(in.readLine());
            return st.nextToken();
        }
        static Integer nextInt() throws Exception {
            return Integer.parseInt(nextToken());
        }
    }
}
