#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  int p[k], r[k], c[k];
  int str[n], sto[m], str_c[n], sto_c[m];
  for (int i = 0; i < n; i++) {
    str[i] = -1;
    str_c[i] = 0;
  }
  for (int i = 0; i < m; i++) {
    sto[i] = -1;
    sto_c[i] = 0;
  }
  for (int i = 0; i < k; i++) {
    cin >> p[i] >> r[i] >> c[i];
    if (p[i] == 1) {
      str[r[i] - 1] = i;
      str_c[r[i] - 1] = c[i];
    }
    if (p[i] == 2) {
      sto[r[i] - 1] = i;
      sto_c[r[i] - 1] = c[i];
    }
  }
  int x[n][m];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) x[i][j] = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if ((str[i] != -1) || (sto[j] != -1)) x[i][j] = c[max(str[i], sto[j])];
    }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) printf("%d ", x[i][j]);
    printf("\n");
  }
}
