#include <bits/stdc++.h>
using namespace std;
int nhang, ncot, n, t, x, mau;
struct l {
  int h, c, t;
};
l hang[5010];
l cot[5010];
void solve() {
  for (int i = 1; i <= nhang; i++) {
    for (int j = 1; j <= ncot; j++) {
      if (j > 1) printf(" ");
      if (hang[i].t > cot[j].t) {
        printf("%d", hang[i].h);
      } else
        printf("%d", cot[j].c);
    }
    printf("\n");
  }
}
int main() {
  while (scanf("%d %d %d", &nhang, &ncot, &n) == 3) {
    memset(hang, 0, sizeof(hang));
    memset(cot, 0, sizeof(cot));
    for (int i = 1; i <= n; i++) {
      scanf("%d %d %d", &t, &x, &mau);
      if (t == 1) {
        hang[x].h = mau;
        hang[x].t = i;
      } else {
        cot[x].c = mau;
        cot[x].t = i;
      }
    }
    solve();
  }
  return 0;
}
