#include <bits/stdc++.h>
using namespace std;
int main() {
  int r, c, k, a, b, v;
  scanf("%d%d%d", &r, &c, &k);
  pair<int, int> rp[5010], cp[5010];
  int arr[r + 1][c + 1];
  int save[r + 1][c + 1];
  int rowVal[r + 1];
  int colVal[c + 1];
  memset(arr, 0, sizeof(arr));
  memset(save, 0, sizeof(save));
  memset(rp, 0, sizeof(rp));
  memset(cp, 0, sizeof(cp));
  for (int i = 1; i <= k; i++) {
    scanf("%d%d%d", &a, &b, &v);
    if (a == 1) {
      rp[b].first = v;
      rp[b].second = i;
      rowVal[b] = v;
      if (colVal[b] != 0) save[b][b] = v;
    } else if (a == 2) {
      cp[b].first = v;
      cp[b].second = i;
      colVal[b] = v;
      if (rowVal[b] != 0) save[b][b] = v;
    }
  }
  for (int k = 1; k <= r; k++) {
    for (int l = 1; l <= c; l++) {
      if (rp[k].second > cp[l].second)
        arr[k][l] = rp[k].first;
      else
        arr[k][l] = cp[l].first;
    }
  }
  for (int i = 1; i <= r; i++) {
    for (int j = 1; j <= c; j++) printf("%d ", arr[i][j]);
    printf("\n");
  }
  return 0;
}
