#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e3 + 5;
int n, m, k, a, b, c;
int cr[maxn], cc[maxn], pr[maxn], pc[maxn];
int G[maxn][maxn];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= k; i++) {
    scanf("%d%d%d", &a, &b, &c);
    if (a == 1) {
      cr[b] = c;
      pr[b] = i;
    } else {
      cc[b] = c;
      pc[b] = i;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      G[i][j] = pr[i] > pc[j] ? cr[i] : cc[j];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      printf("%d ", G[i][j]);
    }
    puts("");
  }
  return 0;
}
