#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int tc[10050], tr[10050], c[10050], r[10050];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= k; i++) {
    int a, b, d;
    scanf("%d%d%d", &a, &b, &d);
    if (a == 1) {
      tr[b] = i;
      r[b] = d;
    } else
      tc[b] = i, c[b] = d;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (tr[i] > tc[j])
        printf("%d ", r[i]);
      else
        printf("%d ", c[j]);
    }
    printf("\n");
  }
}
