
var t : text;
    n,num,st1, i,l,j,k,col, start, finish,x : integer;
    dyn,dyn2 : array[1..50] of integer;
    way,way2 : array[1..50] of integer;
    strway, strway2 : array[1..50] of string;
begin
  assign(t,'hack.in');
  reset(t);
  readln(t,n);
  for i := 1 to n do begin
    readln(t,col, start, finish, num);
    for j := 1 to col do begin
    dyn[j] := 0;
    way[j] := 0;
    strway[j] := '';
    end;

    dyn[start] := 1;
    way[start] := 1;

    for j := 1 to num do begin
      read(t,x);


      for k := 1 to col do
      if dyn[k] = 1 then
      begin

       st1 := k-x;
       repeat
       if (st1 <= 0) then st1 := st1+col;
       until st1 >0;






if ((dyn2[st1] = 0) or (strway2[st1] > strway[k]+'D')) then strway2[st1] := strway[k]+'D';


                  dyn2[st1] := 1;
           inc(way2[st1],way[k]);

       st1 := k+x;
       repeat
       if (st1 > col) then st1 := st1-col;
       until st1 <= col;





if ((dyn2[st1] = 0) or (strway2[st1] > strway[k]+'U')) then strway2[st1] := strway[k]+'U';



         dyn2[st1] := 1;

         inc(way2[st1],way[k]);
       end;






      dyn := dyn2;
       way := way2;
       strway := strway2;
                 {
writeln(j,':');
   for k := 1 to col do
      if dyn2[k] = 1 then writeln(k,' ',way2[k],' ',strway[k]);
                  }
      for k := 1 to col
      do dyn2[k] := 0;

      for k := 1 to col
      do way2[k] := 0;


    end;

  if dyn[finish] = 1 then writeln(way[finish],' ',strway[finish]) else writeln(0);
  end;
  close(t);

end.