#include <bits/stdc++.h>
using namespace std;
int main() {
  long i, j, n, m, k;
  cin >> n >> m >> k;
  int r[n], c[m], rr[n], cc[m];
  for (i = 0; i < n; i++) r[i] = -1;
  for (j = 0; j < m; j++) c[j] = -1;
  for (i = 0; i < k; i++) {
    int in, v;
    cin >> in >> v;
    if (in == 1) {
      r[v - 1] = i + 1;
      cin >> j;
      rr[v - 1] = j;
    } else {
      c[v - 1] = i + 1;
      cin >> j;
      cc[v - 1] = j;
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (r[i] == -1 && c[j] == -1)
        cout << 0 << " ";
      else if (r[i] > c[j])
        cout << rr[i] << " ";
      else
        cout << cc[j] << " ";
    }
    cout << endl;
  }
  return 0;
}
