#include <bits/stdc++.h>
using namespace std;
int rows[5005];
int cols[5005];
int trow[5005];
int tcol[5005];
int R, C;
int main() {
  int com, k, i, j, it;
  scanf("%d%d%d", &R, &C, &k);
  for (i = 1; i <= R; i++) rows[i] = 0, trow[i] = 0;
  for (i = 1; i <= C; i++) cols[i] = 0, tcol[i] = 0;
  for (it = 1; it <= k; it++) {
    scanf("%d%d%d", &com, &i, &j);
    if (com == 1) {
      rows[i] = j;
      trow[i] = it;
    } else {
      cols[i] = j;
      tcol[i] = it;
    }
  }
  for (i = 1; i <= R; i++) {
    for (j = 1; j <= C; j++) {
      if (j > 1) printf(" ");
      int now = 0;
      if (rows[i] != 0 || cols[j] != 0) {
        if (trow[i] > tcol[j])
          now = rows[i];
        else
          now = cols[j];
      }
      printf("%d", now);
    }
    puts("");
  }
  return 0;
}
