#include <bits/stdc++.h>
using namespace std;
int n, m, k;
struct NODE {
  int x, y;
} a[100010], b[100010];
int main() {
  int i;
  int type, x, y;
  scanf("%d%d%d", &n, &m, &k);
  memset(a, 0, sizeof(a));
  memset(b, 0, sizeof(b));
  for (i = 1; i <= k; i++) {
    scanf("%d%d%d", &type, &x, &y);
    if (type == 1) {
      a[x].x = i;
      a[x].y = y;
    } else {
      b[x].x = i;
      b[x].y = y;
    }
  }
  int j;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (b[j].x > a[i].x)
        printf("%d", b[j].y);
      else
        printf("%d", a[i].y);
      if (j == m)
        printf("\n");
      else
        printf(" ");
    }
  }
  return 0;
}
