#include <iostream>
#include <fstream>
#include <vector>
#include <string>

using namespace std;

int modl(int a, int m) {
    a %= m;
    if (a < 0) return a + m;
    return a;
}

int main() {
    ifstream in("hack.in");
    vector<vector<long long> > a;
    vector<vector<string> > sol;
    vector<long long> b;
    string str;
    long long t, l, s, f, n;

    in >> t;

    while(t--) {
        in >> l >> s >> f >> n;
        s--;f--;
        a.resize(n);
        b.resize(n);
        sol.resize(n);
        for(size_t i = 0; i < a.size(); i++) {
            a[i].resize(l);
            sol[i].resize(l);
            for(size_t j = 0; j < a[i].size(); j++) {
                a[i][j] = 0;
                sol[i][j] = "";
            }
        }
        for(size_t i = 0; i < b.size(); i++)
            in >> b[i];

        a[0][modl(s + b[0], l)] = 1;
        sol[0][modl(s + b[0], l)] = "U";
        a[0][modl(s - b[0], l)] = 1;
        sol[0][modl(s - b[0], l)] = "D";

        for(size_t i = 1; i < a.size(); i++) {
            for(size_t j = 0; j < a[i].size(); j++) {
                str = sol[i-1][modl(j + b[i], l)] + "D";
                a[i][j] += a[i-1][modl(j + b[i], l)];
                if (a[i-1][modl(j + b[i], l)] > 0 && (sol[i][j] == "" || str < sol[i][j]))
                    sol[i][j] = str;

                str = sol[i-1][modl(j - b[i], l)] + "U";
                a[i][j] += a[i-1][modl(j - b[i], l)];
                if (a[i-1][modl(j - b[i], l)] > 0 && (sol[i][j] == "" || str < sol[i][j]))
                    sol[i][j] = str;
            }
        }
        /*for(size_t i = 0; i < a[0].size(); i++) {
            std::cout << i + 1 << '\t';
        }
        std::cout << std::endl;
        for(size_t i = 0; i < a.size(); i++) {
            for(size_t j = 0; j < a[i].size(); j++)
                std::cout << sol[i][j] << '\t';
            std::cout << std::endl;
        }
        std::cout << std::endl;*/

        std::cout << a[a.size() - 1][f] << ' ' << sol[a.size() - 1][f] << std::endl;
    }
    return 0;
}
