#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n, m, k;
  cin >> n >> m >> k;
  vector<vector<long long int>> arr(n + 1, vector<long long int>(m + 1, 0));
  vector<pair<long long int, long long int>> rows(n + 1);
  vector<pair<long long int, long long int>> columns(m + 1);
  for (long long int i = 0; i < k; i++) {
    long long int a, b, c;
    cin >> a >> b >> c;
    if (a == 1) {
      rows[b].first = c;
      rows[b].second = i + 1;
    } else {
      columns[b].first = c;
      columns[b].second = i + 1;
    }
  }
  for (long long int i = 1; i < n + 1; i++) {
    long long int rowLatest = rows[i].second;
    long long int rowLatestValue = rows[i].first;
    for (long long int j = 1; j < m + 1; j++) {
      long long int columnLatest = columns[j].second;
      long long int columnLatestValue = columns[j].first;
      if (rowLatest > columnLatest) {
        cout << rowLatestValue;
      } else if (columnLatest > rowLatest) {
        cout << columnLatestValue;
      } else {
        cout << "0";
      }
      cout << " ";
    }
    cout << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
