#include <bits/stdc++.h>
using namespace std;
const int N = 5010;
int a[N][N];
int have[N][3];
struct data {
  int type, num, color;
};
data tmp;
vector<data> b;
int main() {
  int n, m, k, i, j, type, color, num;
  scanf("%d %d %d", &n, &m, &k);
  for (i = 1; i < N; i++) {
    have[i][1] = -1;
    have[i][2] = -1;
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      a[i][j] = 0;
    }
  }
  for (i = 1; i <= k; i++) {
    scanf("%d %d %d", &type, &num, &color);
    tmp.type = type;
    tmp.num = num;
    tmp.color = color;
    b.push_back(tmp);
  }
  vector<int> q;
  for (i = (int(b.size())) - 1; i >= 0; i--) {
    type = b[i].type;
    num = b[i].num;
    color = b[i].color;
    if (have[num][type] != -1) {
      continue;
    }
    have[num][type] = i;
    q.push_back(i);
  }
  int idx;
  for (i = (int(q.size())) - 1; i >= 0; i--) {
    idx = q[i];
    type = b[idx].type;
    num = b[idx].num;
    color = b[idx].color;
    if (type == 1) {
      for (j = 1; j <= m; j++) {
        a[num][j] = color;
      }
    } else {
      for (j = 1; j <= n; j++) {
        a[j][num] = color;
      }
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      printf("%d ", a[i][j]);
    }
    printf("\n");
  }
  return 0;
}
