#include <bits/stdc++.h>
using namespace std;
struct st1 {
  int id, mau;
};
st1 h[5005], c[5005];
int a[5005][5005];
int nhang, ncot, k;
void solve() {
  int i, j, type, x, y;
  for (i = 0; i < nhang; i++) {
    h[i].id = 0;
    h[i].mau = 0;
  }
  for (j = 0; j < ncot; j++) {
    c[j].id = 0;
    c[j].mau = 0;
  }
  for (i = 0; i < k; i++) {
    scanf("%d %d %d", &type, &x, &y);
    if (type == 1) {
      h[x - 1].id = i + 1;
      h[x - 1].mau = y;
    } else {
      c[x - 1].id = i + 1;
      c[x - 1].mau = y;
    }
  }
  for (i = 0; i < nhang; i++) {
    for (j = 0; j < ncot; j++) {
      if (c[j].id != 0 || h[i].id != 0) {
        if (c[j].id > h[i].id)
          a[i][j] = c[j].mau;
        else
          a[i][j] = h[i].mau;
      } else
        a[i][j] = 0;
    }
  }
  for (i = 0; i < nhang; i++) {
    for (j = 0; j < ncot - 1; j++) printf("%d ", a[i][j]);
    printf("%d\n", a[i][ncot - 1]);
  }
}
int main() {
  while (scanf("%d %d %d", &nhang, &ncot, &k) > 0) {
    solve();
  }
  return 0;
}
