#include <bits/stdc++.h>
using namespace std;
int main() {
  int i;
  int n, m, k;
  cin >> n >> m >> k;
  pair<int, int> r[n + 1];
  pair<int, int> c[m + 1];
  for (i = 1; i <= n; i++) r[i] = make_pair(0, 0);
  for (i = 1; i <= m; i++) c[i] = make_pair(0, 0);
  int ch, a, b;
  for (i = 1; i <= k; i++) {
    cin >> ch >> a >> b;
    if (ch == 1) {
      r[a] = make_pair(b, i);
    } else
      c[a] = make_pair(b, i);
  }
  int j;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (r[i].second > c[j].second) {
        cout << r[i].first << " ";
      } else
        cout << c[j].first << " ";
    }
    cout << "\n";
  }
  return 0;
}
