n, m = [int(x) for x in input().split()]
board = [''] * (n+1)
board[0] = [''] * (m+1)
for i in range(n):
  row = input()
  board[i+1] = [''] * (m+1)
  for j in range(m):
    board[i+1][j+1] = row[j]
moves = []
flag = True
while flag:
  start = len(moves)
  for i in range(1,n+1):
    if board[i][0] == "#":
      break
    txt = "".join(board[i][1:])
    txt = "".join([c for c in txt if c != "#"])
    if len(txt) == 0:
      board[i][0] = "#"
    if len(txt) > 0 and txt == len(txt) * txt[0]:
      moves.append("R " + str(i) + " " + txt[0])
      for ii in range (1,m+1):
        board[i][ii] = "#"
  for j in range(1,m+1):
    if board[0][j] == "#":
      break
    txt = ""
    for i in range(1,n+1):
      txt += board[i][j]
    txt = "".join([c for c in txt if c != "#"])
    if len(txt) == 0:
      board[0][j] = "#"
    if len(txt) > 0 and txt == len(txt) * txt[0]:
      moves.append("K " + str(j) + " " + txt[0])
      for jj in range (1,n+1):
        board[jj][j] = "#"
  end = len(moves)
  if start == end:
    flag = False
print(len(moves))
for p in moves[::-1]:
  print(p)
        1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46  | n, m = [int(x) for x in input().split()] board = [''] * (n+1) board[0] = [''] * (m+1) for i in range(n): row = input() board[i+1] = [''] * (m+1) for j in range(m): board[i+1][j+1] = row[j] moves = [] flag = True while flag: start = len(moves) for i in range(1,n+1): if board[i][0] == "#": break txt = "".join(board[i][1:]) txt = "".join([c for c in txt if c != "#"]) if len(txt) == 0: board[i][0] = "#" if len(txt) > 0 and txt == len(txt) * txt[0]: moves.append("R " + str(i) + " " + txt[0]) for ii in range (1,m+1): board[i][ii] = "#" for j in range(1,m+1): if board[0][j] == "#": break txt = "" for i in range(1,n+1): txt += board[i][j] txt = "".join([c for c in txt if c != "#"]) if len(txt) == 0: board[0][j] = "#" if len(txt) > 0 and txt == len(txt) * txt[0]: moves.append("K " + str(j) + " " + txt[0]) for jj in range (1,n+1): board[jj][j] = "#" end = len(moves) if start == end: flag = False print(len(moves)) for p in moves[::-1]: print(p)  | 
            
        
                    English