#include <bits/stdc++.h>
using namespace std;
int main() {
  int lin[5010][2] = {0}, col[5010][2] = {0};
  int n, m, k;
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 1; i <= k; i++) {
    int cmd, x, c;
    scanf("%d %d %d", &cmd, &x, &c);
    x--;
    if (cmd == 1) {
      lin[x][0] = i;
      lin[x][1] = c;
    } else {
      col[x][0] = i;
      col[x][1] = c;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (j) printf(" ");
      printf("%d", lin[i][0] > col[j][0] ? lin[i][1] : col[j][1]);
    }
    printf("\n");
  }
  return 0;
}
