#include <bits/stdc++.h>
using namespace std;
int main() {
  int row[5010][2], col[5010][2], n, m, x, y, c, j, i, k;
  cin >> n >> m >> k;
  for (i = 0; i < 5010; i++) {
    row[i][0] = 0;
    row[i][1] = -1;
    col[i][0] = 0;
    col[i][1] = -1;
  }
  for (int i = 0; i < k; i++) {
    cin >> x >> y >> c;
    if (x == 1) {
      row[y - 1][0] = c;
      row[y - 1][1] = i;
    }
    if (x == 2) {
      col[y - 1][0] = c;
      col[y - 1][1] = i;
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (row[i][1] > col[j][1])
        cout << row[i][0] << " ";
      else
        cout << col[j][0] << " ";
    }
    cout << endl;
  }
  return 0;
}
