#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e3 + 10;
int n, m, k, mat[2][MAXN], tmat[2][MAXN];
int qr() {
  char c = getchar();
  for (; c < 48 || c > 57; c = getchar())
    ;
  int num = c - 48;
  for (c = getchar(); c >= 48 && c <= 57;
       num = num * 10 + c - 48, c = getchar())
    ;
  return num;
}
void qw(const int &x) {
  if (x) {
    qw(x / 10);
    putchar(x % 10 + 48);
  }
  return;
}
int main() {
  n = qr(), m = qr(), k = qr();
  memset(mat, 0, sizeof(mat));
  memset(tmat, 0, sizeof(tmat));
  for (int i = 1; i <= k; ++i) {
    int t = qr(), no = qr();
    mat[t - 1][no] = qr();
    tmat[t - 1][no] = i;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (!tmat[0][i] && !tmat[1][j])
        putchar(48);
      else if (tmat[0][i] > tmat[1][j])
        qw(mat[0][i]);
      else
        qw(mat[1][j]);
      putchar(' ');
    }
    puts("");
  }
  return 0;
}
