#include <bits/stdc++.h>
using namespace std;
vector<pair<long long int, int> > row, col;
int main() {
  ios::sync_with_stdio(false);
  int n, m, k, q, l, c, color;
  cin >> n >> m >> k;
  row.assign(n, make_pair(-1, -1));
  col.assign(m, make_pair(-1, -1));
  for (int i = 1; i <= k; i++) {
    cin >> q >> l >> c;
    switch (q) {
      case 1:
        row[l - 1].first = c;
        row[l - 1].second = i;
        break;
      case 2:
        col[l - 1].first = c;
        col[l - 1].second = i;
        break;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (row[i].second == -1 && col[j].second == -1)
        color = 0;
      else if (row[i].second == -1)
        color = col[j].first;
      else if (col[j].second == -1)
        color = row[i].first;
      else
        color = row[i].second > col[j].second ? row[i].first : col[j].first;
      cout << color << " ";
    }
    cout << "\n";
  }
  row.clear();
  col.clear();
  return 0;
}
