#include<bits/stdc++.h>
using namespace std;
const int N = 150;
int n, m, Q;
char g[N][N];
bool st[N][N];
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
void dfs(int x, int y, char c)
{
st[x][y] = true;
g[x][y] = c;
for(int i = 0; i < 4; i++)
{
int a = x + dx[i], b = y + dy[i];
if(a >= 0 && a < m && b >= 0 && b < n && !st[a][b])
{
if(g[a][b] == '-' || g[a][b] == '|' || g[a][b] == '+')
continue;
dfs(a, b, c);
}
}
}
int main()
{
cin >> m >> n >> Q;
for(int i = 0; i < m; i++)
for(int j = 0; j < n; j++)
g[i][j] = '.';
while(Q --)
{
int op;
cin >> op;
if(op == 0)
{
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
if(x1 > x2) swap(x1, x2);
if(y1 > y2) swap(y1, y2);
char c = '-', d = '|';
if(x1 == x2) swap(c, d);
for(int i = x1; i <= x2; i++)
for(int j = y1; j <= y2; j++)
{
auto& t = g[i][j];
if(t == d || t == '+') t = '+';
else t = c;
}
}
else
{
int x, y;
char c;
cin >> x >> y >> c;
memset(st, 0, sizeof st);
dfs(x, y, c);
}
}
for(int i = n - 1; i >= 0; i--)
{
for(int j = 0; j < m; j++)
cout << g[j][i];
cout << endl;
}
return 0;
}