#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 51;
int n, m, kk, op, x, y;
int r[MAXN], rt[MAXN], ct[MAXN];
inline int read() {
  register int num = 0, neg = 1;
  register char ch = getchar();
  while (!isdigit(ch) && ch != '-') {
    ch = getchar();
  }
  if (ch == '-') {
    neg = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    num = (num << 3) + (num << 1) + (ch - '0');
    ch = getchar();
  }
  return num * neg;
}
int main() {
  n = read(), m = read(), kk = read();
  for (register int i = 1; i <= kk; i++) {
    op = read(), x = read(), y = read(), r[i] = y,
    op == 1 ? rt[x] = i : ct[x] = i;
  }
  for (register int i = 1; i <= n; i++) {
    for (register int j = 1; j <= m; j++) {
      printf("%d ", rt[i] > ct[j] ? r[rt[i]] : r[ct[j]]);
    }
    puts("");
  }
}
