#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m, k;
cin >> n >> m >> k;
// 用 '.' 表示还没有被粉刷的格子
vector<string> board(n, string(m, '.'));
for (int i = 0; i < k; i++) {
int r, c;
char color, dir;
cin >> r >> c >> color >> dir;
--r;
--c;
// 每次粉刷都是一条从起点一直延伸到边界的直线,后刷的覆盖先刷的
if (dir == 'R') {
for (int j = c; j < m; j++) board[r][j] = color;
} else if (dir == 'L') {
for (int j = c; j >= 0; j--) board[r][j] = color;
} else if (dir == 'D') {
for (int j = r; j < n; j++) board[j][c] = color;
} else { // 'U'
for (int j = r; j >= 0; j--) board[j][c] = color;
}
}
for (const string &row : board) cout << row << "\n";
return 0;
}