#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  int mat[n][m];
  map<int, pair<int, int> > ro, co;
  for (int i = 0; i < k; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == 1)
      ro[b - 1] = {i, c};
    else
      co[b - 1] = {i, c};
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (ro.find(i) == ro.end() && co.find(j) == co.end())
        mat[i][j] = 0;
      else if (ro.find(i) != ro.end() && co.find(j) == co.end())
        mat[i][j] = ro[i].second;
      else if (ro.find(i) == ro.end() && co.find(j) != co.end())
        mat[i][j] = co[j].second;
      else if (ro[i].first < co[j].first)
        mat[i][j] = co[j].second;
      else
        mat[i][j] = ro[i].second;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) cout << mat[i][j] << ' ';
    cout << endl;
  }
  return 0;
}
