#include <bits/stdc++.h>
using namespace std;
int r1[5050], r2[5050], c1[5050], c2[5050];
int n, m, k, o1, o2, o3;
int main() {
  int i, j;
  scanf("%d%d%d", &n, &m, &k);
  for (i = 1; i <= k; i++) {
    scanf("%d%d%d", &o1, &o2, &o3);
    if (o1 == 1) {
      r1[o2] = o3;
      r2[o2] = i;
    } else {
      c1[o2] = o3;
      c2[o2] = i;
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (c2[j] > r2[i])
        printf("%d ", c1[j]);
      else
        printf("%d ", r1[i]);
    }
    printf("\n");
  }
  return 0;
}
