#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
const int N = 5e3 + 10;
int n, m, k;
int r[N], c[N];
int rl[N], cl[N];
int main() {
  int i, j;
  scanf("%d%d%d", &n, &m, &k);
  for (i = 0; i < k; ++i) {
    int ta, tb, tc;
    scanf("%d%d%d", &ta, &tb, &tc);
    if (ta == 1) {
      r[tb - 1] = tc;
      rl[tb - 1] = i;
    } else {
      c[tb - 1] = tc;
      cl[tb - 1] = i;
    }
  }
  for (i = 0; i < n; ++i) {
    for (j = 0; j < m; ++j) {
      int ans;
      if (r[i]) {
        if (c[j]) {
          ans = rl[i] > cl[j] ? r[i] : c[j];
        } else {
          ans = r[i];
        }
      } else if (c[j]) {
        ans = c[j];
      } else
        ans = 0;
      printf("%d ", ans);
    }
    printf("\n");
  }
  return 0;
}
