#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long i, j, t, k, n, m, no, clr, type, ans = 0;
  cin >> n >> m >> k;
  vector<pair<long long, long long> > row(n + 2), col(m + 2);
  for (i = 0; i < k; i++) {
    cin >> type >> no >> clr;
    if (type == 1) {
      row[no].first = clr;
      row[no].second = i + 1;
    } else if (type == 2) {
      col[no].first = clr;
      col[no].second = i + 1;
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (row[i].second > col[j].second) {
        cout << row[i].first << " ";
      } else {
        cout << col[j].first << " ";
      }
    }
    cout << endl;
  }
  return 0;
}
