#include <bits/stdc++.h>
using namespace std;
int n, m, k, x, y, z;
int last_row[5128], last_col[5128], color_row[5128], color_col[5128];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int i, j;
  scanf("%d %d %d", &n, &m, &k);
  for (i = 1; i <= k; i++) {
    scanf("%d %d %d", &x, &y, &z);
    if (x == 1) {
      last_row[y] = i;
      color_row[y] = z;
    } else {
      last_col[y] = i;
      color_col[y] = z;
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (j > 1) printf(" ");
      if (last_row[i] > last_col[j]) {
        printf("%d", color_row[i]);
      } else {
        printf("%d", color_col[j]);
      }
    }
    printf("\n");
  }
  return 0;
}
