#include <iostream>
#include <string>

using namespace std;
int l,s,f,n,a[100];
string code[100000];
int codenum = 0;

int rec(int i,int ts,string str)
{
	if (i==n || i > n)
	{
		if (ts == f)
		{
			code[codenum++] = str;
			return 1;
		}
		else
			return 0;
	}
	rec(i+1, (ts+a[i])%l , str + 'u');
	rec(i+1, (ts+l-a[i])%l , str + 'd');
	return 2;
}

int com(string a,string b)
{
	if(a.length()<b.length())return 1;
	if(a.length()>b.length())return -1;
	int yy=a.length();
	for(int i=0;i<yy;i++){
		if(a[i]<b[i])return 1;
		if(a[i]>b[i])return -1;
	}
	return 0;
}

int main()
{
	freopen("HACK.IN","r",stdin);
	//freopen("output.txt","w",stdout);
	int t;
	cin >> t;
	for (int i=0;i<t;i++)
	{
		codenum = 0;
		cin >> l >> s >> f >> n;
		for (int j=0;j<n;j++)
		{
			cin >> a[j];
		}
		rec(0, s, "");
		if(codenum == 0){
			cout << "0" << endl;
			continue;
		}
		int min = 0;
		for (int j=0;j<codenum;j++)
		{
			if (com(code[j],code[min]) == 1)
				min = j;
		}
		cout << codenum << " " << code[min] << endl;
	}
	return 0;
}