import random

random.seed('windowshopping')

def rand(a,b):
  return random.randint(a,b)

MAX_RC = 99

dirs = [[-1,0], [1,0], [0,1], [0,-1]]
def dfs(i, j, R, C, G, v):
  v[i][j] = True
  for d in range(4):
    ni, nj = i + dirs[d][0], j + dirs[d][1]
    if ni < 0 or ni >= R or nj < 0 or nj >= C or v[ni][nj] or G[ni][nj] == '#': continue
    dfs(ni, nj, R, C, G, v) 
  
def valid(G):
  R, C = len(G), len(G[0])
  vu = [[False] * C for _ in range(R)]
  vd = [[False] * C for _ in range(R)]
  for i in range(R):
    for j in range(C):
      if G[i][j] == 'U': dfs(i, j, R, C, G, vu)
      if G[i][j] == 'D': dfs(i, j, R, C, G, vd)
  for i in range(R):
    for j in range(C):
      if G[i][j] != '#':
        if not vu[i][j] or not vd[i][j]: return False
  return True
  
def print_case(G):
  R, C = len(G), len(G[0])
  res = '%d %d\n' % (R, C)
  for i in range(R):
    res += ''.join(G[i]) + '\n'
  return res

def random_case(args):
  R, C = int(args['R']), int(args['C'])
  P, U, D = int(args['P']), int(args['U']), int(args['D'])
  assert U == 1 and D == 1

  while True:
    G = [['.'] * C for _ in range(R)]
    for _ in range(P):
      i = rand(0, R - 1)
      j = rand(0, C - 1)
      G[i][j] = '#'
  
    for _ in range(U):  
      i, j = rand(0, R - 1), rand(0, C - 1)
      G[i][j] = 'U'
    for _ in range(D):
      i, j = rand(0, R - 1), rand(0, C - 1)
      G[i][j] = 'D'
    if valid(G): break
  return print_case(G)
