#include <bits/stdc++.h>
using namespace std;
int main(int argc, char **argv) {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  int Rows[n], Col[m], X[k];
  for (int i = 0; i < n; i++) Rows[i] = -1;
  for (int j = 0; j < m; j++) Col[j] = -1;
  for (int i = 0; i < k; i++) {
    X[i] = 0;
    int t, rc;
    scanf("%d%d%d", &t, &rc, &X[i]);
    if (t == 1)
      Rows[rc - 1] = i;
    else
      Col[rc - 1] = i;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (max(Rows[i], Col[j]) == -1)
        cout << 0 << " ";
      else
        printf("%d ", X[max(Rows[i], Col[j])]);
    }
    printf("\n");
  }
  return 0;
}
