#include <bits/stdc++.h>
using namespace std;
struct node {
  int a, b, c;
} p[200000];
struct node2 {
  int x;
} row[200000], col[200000];
int n, m, k;
int main() {
  while (scanf("%d %d %d", &n, &m, &k) != EOF) {
    memset(row, 0, sizeof(row));
    memset(col, 0, sizeof(col));
    for (int i = 1; i <= k; i++) scanf("%d%d%d", &p[i].a, &p[i].b, &p[i].c);
    for (int i = k; i >= 1; i--) {
      if (p[i].a == 1) {
        if (!row[p[i].b].x) row[p[i].b].x = i;
      } else if (p[i].a == 2) {
        if (!col[p[i].b].x) col[p[i].b].x = i;
      }
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j < m; j++) printf("%d ", p[max(row[i].x, col[j].x)].c);
      printf("%d\n", p[max(row[i].x, col[m].x)].c);
    }
  }
  return 0;
}
