#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>

using namespace std;

int l, s, fin, n;
int c[59];

void ReadData()
{
  scanf("%d %d %d %d", &l, &s, &fin, &n);
  for(int i = 0; i < n; i++)
  {
    scanf("%d", &c[i]);
    c[i] %= l;
  }
}

int answer;
int dp1[59][59];
int dp2[59][59];

int f(int st_n, int current)
{
  if(st_n == n)
  {
    if(current == fin)
    {
      return 1;
    }
    return 0;
  }
  if(dp1[st_n][current] != -1)
  {
    return dp1[st_n][current];
  }
  //D
  int nxt = current - c[st_n];
  if(nxt <= 0)
  {
    nxt = l + nxt;
  }
  int r1 = f(st_n + 1, nxt);
  dp2[st_n][current] += r1;
  //U
  nxt = current + c[st_n];
  if(nxt > l)
  {
    nxt %= l;
  }
  int r2 = f(st_n + 1, nxt);
  if(r2 != 0)
  {
    dp2[st_n][current] += 5;
  }
  int result = r1 + r2 > 0 ? 1 : 0;
  dp1[st_n][current] = result;
  return result;
}

void Solve()
{
  memset(dp1, 0xFF, sizeof(dp1));
  memset(dp2, 0, sizeof(dp2));
  answer = f(0, s);
}

__int64 checker;
vector<__int64> ans2;

void g(int st_n, int current)
{
  if(st_n == n)
  {
    ans2.push_back(checker);
    return;
  }
  if(dp2[st_n][current] == 1)
  {
    checker <<= 1;
    //checker[st_n] = 'D';
    int nxt = current - c[st_n];
    if(nxt <= 0)
    {
      nxt = l + nxt;
    }
    g(st_n + 1, nxt);
    checker >>= 1;
  }
  else if(dp2[st_n][current] == 5)
  {
    //checker[st_n] = 'U';
    checker <<= 1;
    checker |= 1;
    int nxt = current + c[st_n];
    if(nxt > l)
    {
      nxt %= l;
    }
    g(st_n + 1, nxt);
    checker >>= 1;
  }
  else if(dp2[st_n][current] == 6)
  {
    //checker[st_n] = 'D';
    checker <<= 1;
    int nxt = current - c[st_n];
    if(nxt <= 0)
    {
      nxt = l + nxt;
    }
    g(st_n + 1, nxt);
    //checker[st_n] = 'U';
    checker |= 1;
    nxt = current + c[st_n];
    if(nxt > l)
    {
      nxt %= l;
    }
    g(st_n + 1, nxt);
    checker >>= 1;
  }
}

void g2(__int64 val, int st)
{
  if(st == n)
  {
    return;
  }
  g2(val >> 1, st + 1);
  if((val & 1LL) == 0)
  {
    printf("D");
  }
  else
  {
    printf("U");
  }
}

void WriteData()
{
  checker = 0;
  ans2.clear();
  //printf("%d", answer);
  if(answer == 0)
  {
    printf("0");
  }
  else
  {
    g(0, s);
    int len = ans2.size();
    printf("%d ", len);
    __int64 minimal = 1LL << 60;
    for(int i = 0; i < len; i++)
    {
      if(minimal > ans2[i])
      {
        minimal = ans2[i];
      }
    }
    g2(minimal, 0);
  }
  printf("\n");
}

int main()
{
  int QWE = 1;
  freopen("HACK.IN", "r", stdin);
  scanf("%d", &QWE);
  for(int T = 0; T < QWE; T++)
  {
    ReadData();
    Solve();
    WriteData();
  }
  return 0;
}