#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

int main()
{
	freopen("hack.in","r", stdin);
	freopen("hack.out","w", stdout);
		
	int test;
	scanf("%d", &test);
		
	for(int t = 0; t < test; t++)
	{		
		int l, n, s, f;
		long long map[64][64]={0};
		int turn[64];
		
		cin >> l >> s >> f >> n;

		for(int i=0; i<n; i++)
			cin >> turn[i];

		map[n][f-1] = 1;

		for(int step=n-1; step>=0; step--)
		{
			for(int digit=0; digit<l; digit++)
			{
				if (map[step+1][digit] == 0) continue;

				int up = (digit+turn[step])%l;
				int down = (digit-turn[step])%l;
				if (down < 0) down +=l;

				map[step][up] += map[step+1][digit];
				map[step][down] += map[step+1][digit];
			}
		}

		cout << map[0][s-1];

		if (map[0][s-1] > 0)
		{
			int cur = s-1;
			string ans;
			for(int i=1; i<=n; i++)
			{
				int up = (cur + turn[i-1]) % l;
				int down = (cur - turn[i-1]) % l;
				if (down < 0) down += l;

				if (map[i][down] != 0)
				{
					ans = ans + "D";
					cur = down;
				}
				else
				{
					ans = ans + "U";
					cur = up;
				}
			}

			cout << " " << ans;			
		}

		cout << endl;
	}

	return 0;
}

