#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  int i, j, a, b, c;
  int row[n + 1], row_count[n + 1], col[m + 1], col_count[m + 1];
  for (i = 1; i <= n; i++) {
    row[i] = 0;
    row_count[i] = 0;
  }
  for (i = 1; i <= m; i++) {
    col[i] = 0;
    col_count[i] = 0;
  }
  for (i = 1; i <= k; i++) {
    scanf("%d%d%d", &a, &b, &c);
    if (a == 1) {
      row[b] = c;
      row_count[b] = i;
    } else if (a == 2) {
      col[b] = c;
      col_count[b] = i;
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (row_count[i] > col_count[j]) {
        printf("%d ", row[i]);
      } else
        printf("%d ", col[j]);
    }
    printf("\n");
  }
  return 0;
}
