#include <bits/stdc++.h>
using namespace std;
struct stu {
  int step, val;
};
stu col[5005], row[5005];
int main() {
  int a, b, r, c, i, j, k, n, m, l, o;
  cin >> n >> m >> k;
  for (l = 0; l < k; l++) {
    cin >> b;
    if (b == 1) {
      cin >> r >> a;
      row[r - 1].val = a;
      row[r - 1].step = l + 1;
    }
    if (b == 2) {
      cin >> c >> a;
      col[c - 1].val = a;
      col[c - 1].step = l + 1;
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (row[i].step > col[j].step)
        cout << row[i].val;
      else
        cout << col[j].val;
      if (j != m) cout << " ";
    }
    cout << endl;
  }
  return 0;
}
