#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int t[100000], x[100000], a[100000];
bool used[2][5000] = {};
bool g[100000];
vector<int> v[5000];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < (int)(n); ++i) v[i].resize(m);
  for (int i = 0; i < (int)(k); ++i)
    scanf("%d%d%d", t + i, x + i, a + i), --t[i], --x[i];
  for (int i = k - 1; i >= 0; --i) {
    g[i] = !used[t[i]][x[i]];
    used[t[i]][x[i]] = true;
  }
  for (int i = 0; i < (int)(k); ++i)
    if (g[i]) {
      if (t[i] == 0) {
        int r = x[i], col = a[i];
        for (int j = 0; j < (int)(m); ++j) v[r][j] = col;
      } else {
        int c = x[i], col = a[i];
        for (int j = 0; j < (int)(n); ++j) v[j][c] = col;
      }
    }
  for (int i = 0; i < (int)(n); ++i) {
    for (int j = 0; j < (int)(m); ++j) printf("%d ", v[i][j]);
    printf("\n");
  }
  return 0;
}
