#include <iostream>
#include <cstring>
using namespace std;
int dir[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
const int N = 100+5;
char Map[N+1][N+1];
void fill(int x, int y, char c, int m, int n) {
int nx, ny;
Map[y][x] = c;
for(int i=0; i<4; i++) {
ny = y + dir[i][1];
nx = x + dir[i][0];
if(nx <0 || nx >=m || ny<0 || ny >=n || Map[ny][nx] == '|' || Map[ny][nx] == '-' || Map[ny][nx] == '+' || Map[ny][nx] == c)continue;
fill(nx, ny, c, m, n);
}
}
int main() {
int m, n, q, op;
int x1, y1, x2, y2;
char c;
memset(Map, '.', sizeof(Map));
cin >> m >> n >> q;
for(int i=1; i<=q; i++) {
cin >> op;
if(op == 0) {
cin >> x1 >> y1 >> x2 >> y2;
int start, end;
if(x1 == x2) {
start = min(y1, y2);
end = max(y1, y2);
for(int j=start; j<=end; j++)
if(Map[j][x1] == '-' || Map[j][x1] == '+')
Map[j][x1] = '+';
else
Map[j][x1] = '|';
} else if(y1 == y2) {
start = min(x1, x2);
end = max(x1, x2);
for(int j=start; j<=end; j++)
if(Map[y1][j] == '|' || Map[y1][j] == '+')
Map[y1][j] = '+';
else
Map[y1][j] = '-';
}
} else if(op == 1) {
cin >> x1 >> y1 >> c;
fill(x1, y1, c, m, n);
}
}
for(int i=n-1; i>=0; i--) {
for(int j=0; j<m; j++)
cout << Map[i][j];
cout << endl;
}
return 0;
}