#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k, t, r, v;
  cin >> n >> m >> k;
  vector<pair<long long, int>> row(n + 1, make_pair(0, 0)),
      col(m + 1, make_pair(0, 0));
  for (int i = 1; i <= k; i++) {
    cin >> t >> r >> v;
    if (t == 1)
      row[r] = {v, i};
    else
      col[r] = {v, i};
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (row[i].second > col[j].second)
        cout << row[i].first;
      else
        cout << col[j].first;
      cout << " ";
    }
    cout << endl;
  }
  return 0;
}
