#include <bits/stdc++.h>
struct node {
  int color, time;
} r[5005], c[5005];
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= k; i++) {
    int f, x, co;
    scanf("%d%d%d", &f, &x, &co);
    if (f == 1) {
      r[x].color = co;
      r[x].time = i;
    } else {
      c[x].color = co;
      c[x].time = i;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j < m; j++) {
      if (r[i].time >= c[j].time)
        printf("%d ", r[i].color);
      else
        printf("%d ", c[j].color);
    }
    if (r[i].time >= c[m].time)
      printf("%d\n", r[i].color);
    else
      printf("%d\n", c[m].color);
  }
}
