m, n, q =map(int,input().split())
canvas =[['.']* m for i inrange(n)]
emoj =['-','|','+']deffill(x, y, c):if x == m or y == n or x ==-1or y ==-1:return
row = n -1- y
direct =[(-1,0),(1,0),(0,-1),(0,1)]if canvas[row][x]notin emoj and(x, y)notin list2:
list2.append((x, y))
canvas[row][x]= c
for i in direct:
fill(x + i[0], y + i[1], c)
list2.append((x, y))for i inrange(q):
data =input().split()if data[0]=='0':
x1, y1, x2, y2 =map(int, data[1:])if x1 == x2:for j inrange(n -1-max(y1, y2), n -min(y1, y2)):if canvas[j][x1]=='-'or canvas[j][x1]=='+':# 未考虑原来是+
canvas[j][x1]='+'else:
canvas[j][x1]='|'else:
row = n -1- y1
for j inrange(min(x1, x2),max(x1, x2)+1):if canvas[row][j]=='|'or canvas[row][j]=='+':
canvas[row][j]='+'else:
canvas[row][j]='-'else:
x, y =map(int, data[1:3])
c = data[3]
list2 =[]
fill(x, y, c)for i inrange(n):for j inrange(m):print(canvas[i][j], end="")print()