#include <bits/stdc++.h>
using namespace std;
int main() {
  long long i, j, n, a, b, m, k, y, z, cos, pos, color;
  long long r[5005], c[5005], x[100009];
  cin >> n >> m >> k;
  for (i = 1; i <= k; i++) {
    cin >> cos >> pos >> color;
    x[i] = color;
    if (cos == 1)
      r[pos] = i;
    else
      c[pos] = i;
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      y = max(r[i], c[j]);
      cout << x[y] << " ";
    }
    cout << endl;
  }
  return 0;
}
