#include <bits/stdc++.h>
using namespace std;
void solve() {
  map<long long, pair<long long, long long>> row, col;
  long long n, m, k;
  cin >> n >> m >> k;
  long long a[n][m];
  memset(a, 0, sizeof(a));
  long long i = 0;
  while (k--) {
    long long t, x;
    long long a;
    cin >> t >> x >> a;
    x -= 1;
    if (t == 1) {
      row[x] = make_pair(a, i);
    } else {
      col[x] = make_pair(a, i);
    }
    i++;
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if (row.find(i) == row.end() && col.find(j) != col.end())
        a[i][j] = col[j].first;
      else if (row.find(i) != row.end() && col.find(j) == col.end())
        a[i][j] = row[i].first;
      else if (row.find(i) != row.end() && col.find(j) != col.end()) {
        long long row_time = row[i].second;
        long long col_time = col[j].second;
        if (row_time < col_time)
          a[i][j] = col[j].first;
        else
          a[i][j] = row[i].first;
      }
    }
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      cout << a[i][j] << ' ';
    }
    cout << endl;
  }
}
signed main() {
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
