#include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 10;
int n, m, k, r[N], c[N];
struct operation {
  int op, a, b;
} op[100010];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= k; i++) scanf("%d%d%d", &op[i].op, &op[i].a, &op[i].b);
  for (int i = k; i > 0; i--) {
    if (op[i].op == 1 && !r[op[i].a]) {
      r[op[i].a] = i;
      continue;
    } else if (op[i].op == 2 && !c[op[i].a]) {
      c[op[i].a] = i;
      continue;
    }
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      if (r[i] > c[j])
        printf("%d", op[r[i]].b);
      else
        printf("%d", op[c[j]].b);
      printf("%c", j == m ? '\n' : ' ');
    }
  return 0;
}
