#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k, i, j, a, b, c;
  cin >> n >> m >> k;
  vector<pair<int, int> > row(n, make_pair(0, -1)), col(m, make_pair(0, -1));
  for (i = 0; i < k; i++) {
    cin >> a >> b >> c;
    if (a == 1)
      row[--b] = make_pair(c, i);
    else
      col[--b] = make_pair(c, i);
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (row[i].second > col[j].second)
        cout << row[i].first;
      else
        cout << col[j].first;
      cout << (j == m - 1 ? '\n' : ' ');
    }
  }
}
