#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n, m, k, i, j, a, b, c;
  cin >> n >> m >> k;
  pair<int, int> pa;
  unordered_map<int, pair<int, int> > rowmap, colmap;
  vector<vector<int> > foo(n, vector<int>(m, 0));
  for (i = 0; i < k; i++) {
    cin >> a >> b >> c;
    if (a == 1) {
      pa.first = i;
      pa.second = c;
      rowmap[b - 1] = pa;
    } else {
      pa.first = i;
      pa.second = c;
      colmap[b - 1] = pa;
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (colmap.find(j) != colmap.end() && rowmap.find(i) != rowmap.end()) {
        if (colmap[j].first > rowmap[i].first)
          foo[i][j] = colmap[j].second;
        else
          foo[i][j] = rowmap[i].second;
      } else if (colmap.find(j) != colmap.end())
        foo[i][j] = colmap[j].second;
      else if (rowmap.find(i) != rowmap.end())
        foo[i][j] = rowmap[i].second;
      cout << foo[i][j] << " ";
    }
    cout << "\n";
  }
  return 0;
}
