#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, k, i, j;
  cin >> n >> m >> k;
  long long r[n + 1], c[m + 1], R[n + 1], C[m + 1];
  for (i = 1; i <= n; i++) {
    r[i] = 0;
    R[i] = 0;
  }
  for (i = 1; i <= m; i++) {
    c[i] = 0;
    C[i] = 0;
  }
  long long a, b, N;
  for (i = 1; i <= k; i++) {
    cin >> a >> b >> N;
    if (a == 1) {
      r[b] = N;
      R[b] = i;
    } else {
      c[b] = N;
      C[b] = i;
    }
  }
  long long t;
  for (i = 1; i <= n; i++) {
    if (r[i] == 0) {
      for (j = 1; j <= m; j++) cout << c[j] << ' ';
      cout << endl;
    } else {
      t = R[i];
      for (j = 1; j <= m; j++) {
        if (t < C[j])
          cout << c[j] << ' ';
        else
          cout << r[i] << ' ';
      }
      cout << endl;
    }
  }
  return 0;
}
