#include <bits/stdc++.h>
using namespace std;
int f[5005], c[5005];
int tf[5005], tc[5005];
int mat[5005][5005];
int main() {
  int n, m, k, a, col, op;
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 1; i <= k; i++) {
    scanf("%d %d %d", &op, &a, &col);
    if (op == 1) {
      f[a] = col;
      tf[a] = i;
    } else {
      c[a] = col;
      tc[a] = i;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      mat[i][j] = f[i];
    }
  }
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      if (tc[i] > tf[j]) mat[j][i] = c[i];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (j == m)
        printf("%d\n", mat[i][j]);
      else
        printf("%d ", mat[i][j]);
    }
  }
  return 0;
}
