/*--------------------------------------------------------------*/
/* ACM ICPC 2009-2010, NEERC                                    */
/* Northern Subregional Contest                                 */
/* St Petersburg, October 17, 2009                              */
/*--------------------------------------------------------------*/
/* Problem I. Image Recognition                                 */
/*                                                              */
/* Original idea         Mikhail Dvorkin                        */
/* Problem statement     Mikhail Dvorkin                        */
/* Testset               Mikhail Dvorkin                        */
/*--------------------------------------------------------------*/
/* Solution                                                     */
/*                                                              */
/* Author                Sergey Kopeliovich                     */
/*--------------------------------------------------------------*/
 
#include <cstdio>
#include <cstring>

#include <algorithm>

using namespace std;

#define forn(i, n) for (int i = 0; i < (int)(n); i++)

const int maxn = 10;
const int maxs = 20;

int n, W, H;
char s[maxs + 1];

int p[2][maxs][maxs];
int f[1 << maxn][maxs][maxs];
int cx[1 << maxn][maxs][maxs];
int cy[1 << maxn][maxs][maxs];

int calc( int pr, int x, int y )
{
  if ((pr & (pr - 1)) == 0)
    return 0;
  int &res = f[pr][y][x];
  if (res != -1)
    return res;

  #define IS(a, b) (((a) & (b)) == (b))
  res = (int)1e9;
  forn(x1, W)
    forn(y1, H)
      if (!IS(p[0][y1][x1], pr) && !IS(p[1][y1][x1], pr))
      {
        int tmp = max(calc(pr & p[0][y][x], x1, y1), calc(pr & p[1][y][x], x1, y1)) + abs(x1 - x) + abs(y1 - y);
        if (tmp < res)
          res = tmp, cx[pr][y][x] = x1, cy[pr][y][x] = y1;
      }
  return res;
}

void out( int pr, int x, int y )
{
  if ((pr & (pr - 1)) == 0)
  {
    int k = 0;
    while ((1 << k) != pr)
      k++;
    printf("%d", k);
    return;
  }

  int x1 = cx[pr][y][x];
  int y1 = cy[pr][y][x];
  while (x < x1) printf("R"), x++;
  while (x > x1) printf("L"), x--;
  while (y < y1) printf("D"), y++;
  while (y > y1) printf("U"), y--;

  printf("(");
  out(pr & p[0][y][x], x, y);
  printf(":");
  out(pr & p[1][y][x], x, y);
  printf(")");
}

int main()
{
//  freopen("image.in", "r", stdin);
//  freopen("image.out", "w", stdout);

  scanf("%d%d%d", &n, &H, &W);
  forn(k, n)
    forn(i, H)
    {
      scanf("%s", s);
      forn(j, W)
        p[s[j] == 'B'][i][j] |= 1 << k;
    }

  memset(f, -1, sizeof(f));
  calc((1 << n) - 1, 0, 0);
  out((1 << n) - 1, 0, 0);
  return 0;
}
