#include <bits/stdc++.h>
using namespace std;
int f[5010][5010];
pair<int, int> colom[5010], line[5010];
struct cz {
  int t, c, col, ord;
};
bool operator<(cz a, cz b) { return a.ord < b.ord; }
vector<cz> qwq;
int main() {
  int n, m, q;
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 1; i <= q; i++) {
    int x, y, z;
    scanf("%d %d %d", &x, &y, &z);
    if (x & 1) {
      line[y].first = i;
      line[y].second = z;
    } else {
      colom[y].first = i;
      colom[y].second = z;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (line[i].first) {
      cz t = {1, i, line[i].second, line[i].first};
      qwq.push_back(t);
    }
  }
  for (int i = 1; i <= m; i++) {
    if (colom[i].first) {
      cz t = {2, i, colom[i].second, colom[i].first};
      qwq.push_back(t);
    }
  }
  sort(qwq.begin(), qwq.end());
  for (int i = 0; i < qwq.size(); i++) {
    if (qwq[i].t & 1) {
      for (int j = 1; j <= m; j++) {
        f[qwq[i].c][j] = qwq[i].col;
      }
    } else {
      for (int j = 1; j <= n; j++) {
        f[j][qwq[i].c] = qwq[i].col;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      printf("%d ", f[i][j]);
    }
    printf("\n");
  }
  return 0;
}
