#include <bits/stdc++.h>
using namespace std;
class op {
 public:
  long long col;
  long long turn;
  op() {
    col = 0;
    turn = 0;
  }
};
int main() {
  long long n, m, k;
  cin >> n >> m >> k;
  op *row = new op[5000];
  op *cm = new op[5000];
  long long t, s, col;
  for (long long d = 0; d < k; ++d) {
    cin >> t >> s >> col;
    if (t == 1) {
      row[s - 1].col = col;
      row[s - 1].turn = d + 1;
    } else {
      cm[s - 1].col = col;
      cm[s - 1].turn = d + 1;
    }
  }
  for (long long i = 0; i < n; ++i) {
    for (long long j = 0; j < m; ++j) {
      if (cm[j].turn > row[i].turn)
        cout << cm[j].col << ' ';
      else
        cout << row[i].col << ' ';
    }
    printf("\n");
  }
  return 0;
}
