/*
这道题最头痛的一点是输入的矩形和该怎么输出,那么你可以将题目要求的坐标反过来,那么就是我们正常的顺序
*/
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef pair<int,int> PII;
const int N = 110;
char str[N][N];
bool st[N][N];
PII q[N*N];
int n,m,p;
void bfs(int sx,int sy,char c) {
int hh = 0,tt = 0;
q[hh] = {sx,sy};
str[sx][sy] = c;
st[sx][sy] = true;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,1,0,-1};
while(hh <= tt) {
auto t = q[hh ++];
for(int i = 0;i < 4;i++) {
int x = t.x + dx[i],y = t.y + dy[i];
if(x < 0 || x >= m || y < 0 || y >= n) continue;
if(st[x][y]) continue;
if(str[x][y] == '-' || str[x][y] == '|' || str[x][y] == '+') continue;
str[x][y] = c;
st[x][y] = true;
q[++ tt] = {x,y};
}
}
}
int main (){
cin>>m>>n>>p;
for(int i = 0;i < m;i++) {
for(int j = 0;j < n;j++)
str[i][j] = '.';
}
while(p--) {
int a;
cin>>a;
if(a == 1) {
memset(st,false,sizeof st);
int x,y;
char c;
cin>>x>>y>>c;
if(str[x][y] != '|' && str[x][y] != '-' && str[x][y] != '+') {
bfs(x,y,c);
}
}else {
int x1,y1,x2,y2;
cin>>x1>>y1>>x2>>y2;
if (x1 > x2) swap(x1, x2);
if (y1 > y2) swap(y1, y2);
char c = '-',p = '|';
if(x1 == x2) swap(c,p);
for(int i = x1;i <= x2;i++) {
for(int j = y1;j <= y2;j++) {
// 这里要判断一下是否是等于 +
if(str[i][j] == p || str[i][j] == '+') str[i][j] = '+';
else str[i][j] = c;
}
}
}
}
for(int i = n-1;i >= 0;i--) {
for(int j = 0;j < m;j++)
cout<<str[j][i];
puts("");
}
return 0;
}