//412_4
#include <iostream>
#include <algorithm>
#include <stdio.h>

#define min(a, b) (((a)<(b))?(a):(b))
#define max(a, b) (((a)>(b))?(a):(b))

using namespace std;

const int N = 53;
long long d[N][N];
int c[N], l, stackDown[N];

int up(int i, int c)
{
    return (i+c)%l;
}

int down(int i, int c)
{
    if(stackDown[i] == -1)
    {
        int j = i;
        j -= c;
        while(j<0)
            j+=l;

        stackDown[i] = j;
    }
    return stackDown[i];
}

void answer()
{
    int n, s, f, i, j, k;

    for(i=0; i<N; ++i)
        stackDown[i] = -1;

    scanf("%d %d %d %d", &l, &s, &f, &n);
    --s; --f;
    for(i=0; i<n; ++i)
        scanf("%d", &c[i]);

    for(i=0; i<N; ++i)
        for(j=0; j<N; ++j)
            d[i][j] = 0;

    d[n][f] = 1;

    for(i=n-1; i>=0; --i)
    {
        for(j=0; j<l; ++j)
        {
            d[i][j] += d[i+1][up(j, c[i])];
            d[i][j] += d[i+1][down(j, c[i])];
        }
    }

    cout << d[0][s] ;
    if(!d[0][s])
    {
        printf("\n");
        return;
    }

    printf(" ");
    for(i=0; i<n; ++i)
    {
        if(d[i+1][down(s, c[i])])
        {
            printf("D");
            s = down(s, c[i]);
        }
        else
        {
            printf("U");
            s = up(s, c[i]);
        }
    }
    printf("\n");
}
int main()
{
    freopen("HACK.IN","r", stdin);
    //freopen("input.txt", "r", stdin);
/*
    freopen("input1.txt", "w", stdout);
    printf("1 1 1 50\n");
    for(int i=0; i<50 ;++i)
        printf("1 ");

*/
    int t;
    scanf("%d", &t);
    while(t--)
        answer();

    return 0;
}

