#include <bits/stdc++.h>
using namespace std;
int main() {
  long long A[10000] = {}, B[10000] = {}, n, m, k, D[10000] = {}, C[10000] = {},
            x, y, a;
  cin >> n >> m >> k;
  for (long long i = 1; i <= k; i++) {
    cin >> x >> y >> a;
    if (x == 1) {
      A[y] = a;
      B[y] = i;
    } else {
      C[y] = a;
      D[y] = i;
    }
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      if (B[i] > D[j]) {
        cout << A[i];
      } else if (B[i] < D[j]) {
        cout << C[j];
      } else
        cout << "0";
      cout << " ";
    }
    cout << endl;
  }
  return 0;
}
