#include <bits/stdc++.h>
int col[5001], a[5001];
int row[5001], b[5001];
int main() {
  int n, m, k;
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 0; i < n; i++) a[i] = -1;
  for (int j = 0; j < m; j++) b[j] = -1;
  for (int i = 0; i < k; i++) {
    int s, rc, color;
    scanf("%d %d %d", &s, &rc, &color);
    rc -= 1;
    if (s == 1) {
      row[rc] = color;
      a[rc] = i;
    } else {
      col[rc] = color;
      b[rc] = i;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      printf("%d ", a[i] > b[j] ? row[i] : col[j]);
    }
    printf("\n");
  }
}
