#include <bits/stdc++.h>
using namespace std;
const int N = 5005, M = 1e5 + 15;
int ret[N][N];
int type[M], x[M], a[M];
set<int> row[N], col[N];
set<int>::iterator it;
void sovle() {
  int n, m, i, j, k;
  cin >> n >> m >> k;
  for (i = 0; i < k; ++i) scanf("%d%d%d", &type[i], &x[i], &a[i]);
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= m; ++j) {
      row[i].insert(j);
    }
  for (j = 1; j <= m; ++j)
    for (i = 1; i <= n; ++i) col[j].insert(i);
  for (i = k - 1; i >= 0; --i) {
    if (type[i] == 2) {
      int v = x[i];
      for (it = col[v].begin(); it != col[v].end(); ++it) {
        int u = *it;
        ret[u][v] = a[i];
        row[u].erase(v);
      }
      col[v].clear();
    } else {
      int v = x[i];
      for (it = row[v].begin(); it != row[v].end(); ++it) {
        int u = *it;
        ret[v][u] = a[i];
        col[u].erase(v);
      }
      row[v].clear();
    }
  }
  for (i = 1; i <= n; ++i) {
    for (j = 1; j <= m; ++j) {
      cout << ret[i][j] << " ";
    }
    cout << endl;
  }
}
int main() { sovle(); }
