#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<pair<long long, int> > rows(n);
  vector<pair<long long, int> > cols(m);
  for (int i = 0; i < n; i++) {
    rows[i] = make_pair(0, 0);
  }
  for (int i = 0; i < m; i++) {
    cols[i] = make_pair(0, 0);
  }
  int k;
  cin >> k;
  int a, b, c;
  for (int i = 0; i < k; i++) {
    cin >> a >> b >> c;
    b--;
    if (a == 1)
      rows[b] = make_pair(c, i);
    else
      cols[b] = make_pair(c, i);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (cols[j].second == 0 && rows[i].second == 0) {
        cout << max(cols[j].first, rows[i].first) << " ";
        continue;
      }
      if (cols[j].second > rows[i].second)
        cout << cols[j].first << " ";
      else
        cout << rows[i].first << " ";
    }
    cout << endl;
  }
  return 0;
}
