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