def solve(H, W, R, C, world):
visited = [False] * (WIDTH * HEIGHT)
stack = {WIDTH * R + C}
while len(stack) > 0:
pos = stack.pop()
visited[pos] = True
next = pos - 1
if not visited[next]:
if world[next] == 1 or world[next] == 2:
stack.add(next)
next = pos + 1
if not visited[next]:
if world[next] == 1 or world[next] == 3:
stack.add(next)
next = pos + WIDTH
if not visited[next]:
if world[next] == 1 or world[next] == 4:
stack.add(next)
next = pos - WIDTH
if not visited[next]:
if world[next] == 1 or world[next] == 5:
stack.add(next)
for y in range(ORIGINAL_HEIGHT):
line = []
for x in range(ORIGINAL_WIDTH):
pos = WIDTH + 1 + WIDTH * y + x
if world[pos] == 0:
line.append("#")
elif visited[pos]:
line.append("o")
else:
line.append("x")
print("".join(line))