#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(false);
  int n, m, k;
  cin >> n >> m >> k;
  vector<pair<int, int>> rows(n + 3, {0, 0}), cols(m + 3, {0, 0});
  for (int i = 0; i < k; i++) {
    int t, w, a;
    cin >> t >> w >> a;
    if (t == 1)
      rows[w] = {a, i + 1};
    else
      cols[w] = {a, i + 1};
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++)
      if (rows[i].second > cols[j].second)
        cout << rows[i].first << ' ';
      else
        cout << cols[j].first << ' ';
    cout << '\n';
  }
  return 0;
}
