#include <bits/stdc++.h>
using namespace std;
int main() {
  long long i, j, k, m, n, p, x, y, q, sum1, sum2, r[10000], c[10000],
      r1[10000], c1[10000];
  cin >> m >> n >> k;
  memset(r, 0, sizeof(r));
  memset(c, 0, sizeof(c));
  memset(r1, 0, sizeof(r1));
  memset(c1, 0, sizeof(c1));
  for (i = 1; i <= k; i++) {
    cin >> p;
    if (p == 1) {
      cin >> x >> y;
      r[x] = y;
      r1[x] = i;
    } else {
      cin >> x >> y;
      c[x] = y;
      c1[x] = i;
    }
  }
  for (i = 1; i <= m; i++) {
    for (j = 1; j <= n; j++) {
      if (c1[j] > r1[i]) {
        cout << c[j];
      } else {
        cout << r[i];
      }
      cout << " ";
    }
    cout << "\n";
  }
  return 0;
}
