#include <bits/stdc++.h>
using namespace std;
int row[5002], col[5002];
bool last[5002][5002];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  vector<pair<int, int> > row(n, pair<int, int>(-1, 0)),
      col(m, pair<int, int>(-1, 0));
  for (int i = 0, op, x, a; i < k; ++i) {
    cin >> op >> x >> a;
    x--;
    if (op == 1)
      row[x] = {i, a};
    else
      col[x] = {i, a};
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cout << (j ? " " : "");
      if (row[i].first > col[j].first)
        cout << row[i].second;
      else
        cout << col[j].second;
    }
    cout << endl;
  }
  return 0;
}
