#include <bits/stdc++.h>
using namespace std;
pair<int, int> r[5050], c[5050];
int n, m, k;
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < k; i++) {
    int t, x, y;
    cin >> t >> x >> y;
    if (t == 1) {
      r[x] = make_pair(i, y);
    } else {
      c[x] = make_pair(i, y);
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      pair<int, int> cur = max(r[i], c[j]);
      cout << cur.second << ' ';
    }
    cout << endl;
  }
  return 0;
}
