#include <bits/stdc++.h>
using namespace std;
const int MX_SZ = 5042;
int main() {
  ios_base::sync_with_stdio(false);
  static pair<int, int> r[MX_SZ], w[MX_SZ];
  int n, m, q;
  cin >> n >> m >> q;
  for (int i = 1; i <= q; i++) {
    int t, ps, a;
    cin >> t >> ps >> a;
    if (t == 1) {
      r[ps] = {a, i};
    } else {
      w[ps] = {a, i};
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (r[i].second > w[j].second) {
        cout << r[i].first << " ";
      } else {
        cout << w[j].first << " ";
      }
    }
    cout << '\n';
  }
}
