#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9;
const int N = 5007;
long long n, m, k, I[N], J[N], Ii[N], Jj[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> k;
  for (int i = 1; i <= k; ++i) {
    int q, pos, x;
    cin >> q >> pos >> x;
    if (q == 1)
      I[pos] = x, Ii[pos] = i;
    else
      J[pos] = x, Jj[pos] = i;
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (Ii[i] > Jj[j])
        cout << I[i] << " ";
      else
        cout << J[j] << " ";
    }
    cout << endl;
  }
  return 0;
}
