#include <bits/stdc++.h>
using namespace std;
int n, m, k, t1, t2, t3;
pair<int, int> r[5005], c[5005];
int main() {
  int i, j;
  cin >> n >> m >> k;
  for (i = 1; i <= k; i++) {
    scanf("%d %d %d", &t1, &t2, &t3);
    if (t1 == 1) {
      r[t2].first = i;
      r[t2].second = t3;
    } else {
      c[t2].first = i;
      c[t2].second = t3;
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (r[i].first > c[j].first)
        printf("%d ", r[i].second);
      else
        printf("%d ", c[j].second);
    }
    printf("\n");
  }
  return 0;
}
