#include <bits/stdc++.h>
using namespace std;
const long long maxn = 5e3 + 20;
long long n, m, k, tmp1, tmp2, tmp3;
pair<long long, long long> C[maxn], R[maxn];
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> k;
  for (long long i = 1; i <= k; i++) {
    cin >> tmp1 >> tmp2 >> tmp3;
    if (tmp1 == 1) {
      R[tmp2] = {i, tmp3};
    } else {
      C[tmp2] = {i, tmp3};
    }
  }
  cout << endl;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      if (R[i].first > C[j].first) {
        cout << R[i].second << " ";
      } else {
        cout << C[j].second << " ";
      }
    }
    cout << endl;
  }
  return 0;
}
