#include <bits/stdc++.h>
using namespace std;
struct Eve {
  int color;
  int num;
  Eve(int num, int color) : num(num), color(color){};
};
bool operator<(Eve& a, Eve& b) { return a.num < b.num; }
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  vector<vector<Eve> > r(n + 2, vector<Eve>());
  vector<vector<Eve> > c(m + 2, vector<Eve>());
  for (int i = 1; i <= k; i++) {
    int z, x, color;
    scanf("%d%d%d", &z, &x, &color);
    if (z == 1) {
      r[x].push_back(Eve(i, color));
    } else {
      c[x].push_back(Eve(i, color));
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (r[i].size() || c[j].size()) {
        if (r[i].size() && c[j].size() == 0) {
          printf("%d ", r[i].back().color);
        } else if (r[i].size() == 0 && c[j].size()) {
          printf("%d ", c[j].back().color);
        } else if (r[i].back().num < c[j].back().num) {
          printf("%d ", c[j].back().color);
        } else {
          printf("%d ", r[i].back().color);
        }
      } else {
        printf("0 ");
      }
    }
    printf("\n");
  }
  return 0;
}
