#include <bits/stdc++.h>
using namespace std;
struct colornode {
  int color;
  int time;
};
struct colornode colorr[5001], colorc[5001];
int n, m, k;
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    colorr[i].time = 0;
    colorr[i].color = 0;
  }
  for (int i = 1; i <= m; i++) {
    colorc[i].time = 0;
    colorc[i].color = 0;
  }
  for (int i = 1; i <= k; i++) {
    int op, num, c;
    cin >> op >> num >> c;
    if (op == 1) {
      colorr[num].color = c;
      colorr[num].time = i;
    } else {
      colorc[num].color = c;
      colorc[num].time = i;
    }
  }
  for (int i = 1; i <= n; i++) {
    int nowt = colorr[i].time, nowc = colorr[i].color;
    for (int j = 1; j <= m; j++) {
      nowc = colorr[i].color;
      if (colorc[j].time > nowt) {
        nowc = colorc[j].color;
      }
      cout << nowc << " ";
    }
    cout << endl;
  }
  return 0;
}
