#include <bits/stdc++.h>
using namespace std;
int r[1000004], c[1000004], r1[1000004], c1[1000004];
int main() {
  long long n, m, k, x, y, t;
  cin >> n >> m >> k;
  for (int i = 1; i <= k; i++) {
    cin >> x >> y >> t;
    if (x == 1) {
      r[y] = t;
      r1[y] = i;
    } else if (x == 2) {
      c[y] = t;
      c1[y] = i;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (r1[i] > c1[j])
        cout << r[i] << " ";
      else
        cout << c[j] << " ";
    }
    cout << "\n";
  }
}
