#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, k, time = 0, r, c, a, typ;
  scanf("%lld%lld%lld", &n, &m, &k);
  vector<long long int> rc(n + 1, 0);
  vector<long long int> rt(n + 1, 0);
  vector<long long int> cc(m + 1, 0);
  vector<long long int> ct(m + 1, 0);
  while (k--) {
    scanf("%lld", &typ);
    ++time;
    if (typ == 1) {
      scanf("%lld%lld", &r, &a);
      rc[r] = a;
      rt[r] = time;
    } else {
      scanf("%lld%lld", &c, &a);
      cc[c] = a;
      ct[c] = time;
    }
  }
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = 1; j <= m; j++) {
      if (rt[i] > ct[j])
        printf("%lld ", rc[i]);
      else
        printf("%lld ", cc[j]);
    }
    printf("\n");
  }
}
