#include <bits/stdc++.h>
using namespace std;
using int_ = int;
int_ main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);
  long long n, m, k;
  cin >> n >> m >> k;
  map<pair<bool, long long>, pair<long long, long long> > actions;
  for (long long i = 0; i < k; ++i) {
    long long x, r, a;
    cin >> x >> r >> a;
    actions[{x == 2, r - 1}] = {i, a};
  }
  vector<tuple<long long, bool, long long, long long> > ops;
  for (auto& p : actions)
    ops.emplace_back(p.second.first, p.first.first, p.first.second,
                     p.second.second);
  sort(ops.begin(), ops.end());
  vector<vector<long long> > table(n, vector<long long>(m));
  for (auto& tup : ops) {
    long long t, index, color;
    bool is_row;
    tie(t, is_row, index, color) = tup;
    if (is_row)
      for (auto& v : table) v[index] = color;
    else
      fill(table[index].begin(), table[index].end(), color);
  }
  for (auto& v : table) {
    for (auto& c : v) cout << c << ' ';
    cout << '\n';
  }
}
