""" NG """ n, m = [int(x) for x in input().split()] moves = list(input()) maps = [] for i in range(n+1): tmp = [] for j in range(n+1): tmp.append("1") maps.append(tmp) # print(maps) x = y = 0 maps[n-y][x] = "0" # maps[n-y][n-x] = "0" for move in moves: if move == "U": y = y + 1 elif move == "R": x = x + 1 elif move == "L": x = x - 1 elif move == "D": y = y - 1 maps[n-y][x] = "0" # print(maps) # maps = map(str, maps) for i in range(n+1): # print(map_row) print(" ".join(maps[i])) # for map_d in map_row: # # print(map_d) # print("".join(str(map_row)))