#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k, i, j, x, p, q;
  scanf("%d", &n);
  scanf("%d", &m);
  scanf("%d", &k);
  vector<int> r(n + 1);
  vector<int> c(m + 1);
  vector<long long> r_val(n + 1);
  vector<long long> c_val(m + 1);
  for (i = 1; i <= k; i++) {
    scanf("%d", &x);
    scanf("%d", &p);
    scanf("%d", &q);
    if (x == 1) {
      r[p] = i;
      r_val[p] = q;
    } else {
      c[p] = i;
      c_val[p] = q;
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (r[i] < c[j])
        printf("%lld ", c_val[j]);
      else if (r[i] > c[j])
        printf("%lld ", r_val[i]);
      else
        printf("0 ");
    }
    printf("\n");
  }
  return 0;
}
