#include <bits/stdc++.h>
using namespace std;
long long n, m, q, T, k;
long long dp[10000 + 2][100 + 2];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> k;
  vector<pair<long long, long long> > row_colors(n), col_colors(m);
  for (int i = 1; i < 1 + k; i++) {
    long long x, y, z;
    cin >> x >> y >> z;
    if (x == 1) {
      row_colors[y - 1] = {z, i};
    } else {
      col_colors[y - 1] = {z, i};
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (col_colors[j].second > row_colors[i].second)
        cout << col_colors[j].first;
      else
        cout << row_colors[i].first;
      if (j < m - 1) cout << " ";
    }
    if (i < n - 1) cout << "\n";
  }
  return 0;
}
