#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int col[MAXN];
int fil[MAXN];
int colC[MAXN];
int colF[MAXN];
int main() {
  int n, m, k;
  int a, b, c;
  scanf("%d %d %d", &n, &m, &k);
  int cont = 1;
  while (k--) {
    scanf("%d %d %d", &a, &b, &c);
    b--;
    if (a == 1) {
      colF[b] = c;
      fil[b] = cont++;
    } else {
      colC[b] = c;
      col[b] = cont++;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (fil[i] > col[j])
        printf("%d ", colF[i]);
      else
        printf("%d ", colC[j]);
    }
    printf("\n");
  }
  return 0;
}
