#include <bits/stdc++.h>
using namespace std;
const int xx[] = {0, 1, 0, -1, -1, 1, -1, 1};
const int yy[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int kx[] = {-2, -1, 1, 2, 2, 1, -1, -2};
const int ky[] = {1, 2, 2, 1, -1, -2, -2, -1};
class data {
 public:
  int color, val;
  data() { color = val = 0; }
};
data row[5004];
data col[5004];
int main() {
  int i, j, k, T, x, m, n, mx, low, high, mid, l, r, q, a;
  char ch, ch1;
  bool key = 1, flag = 1;
  scanf("%d%d", &n, &m);
  scanf("%d", &k);
  for (i = 1; i <= k; i++) {
    scanf("%d%d", &q, &r);
    scanf("%d", &a);
    if (q == 1) {
      row[r].color = a;
      row[r].val = i;
    } else {
      col[r].color = a;
      col[r].val = i;
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (row[i].val > col[j].val)
        printf("%d", row[i].color);
      else if (row[i].val < col[j].val)
        printf("%d", col[j].color);
      else
        printf("0");
      if (j < m) printf(" ");
    }
    printf("\n");
  }
  return 0;
}
