#include <bits/stdc++.h>
using namespace std;
template <typename S, typename T>
ostream& operator<<(ostream& out, pair<S, T> const& p) {
  out << '(' << p.first << ", " << p.second << ')';
  return out;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T> const& v) {
  long long l = v.size();
  for (long long i = 0; i < l - 1; i++) out << v[i] << ' ';
  if (l > 0) out << v[l - 1];
  return out;
}
template <typename T>
void trace(const char* name, T&& arg1) {
  cout << name << " : " << arg1 << "\n";
}
template <typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  trace(comma + 1, args...);
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m, k;
  cin >> n >> m >> k;
  vector<pair<long long, long long> > row(n + 1, make_pair(0, 0));
  vector<pair<long long, long long> > col(m + 1, make_pair(0, 0));
  for (long long i = 1; i <= k; i++) {
    long long type;
    cin >> type;
    if (type == 1) {
      long long num, color;
      cin >> num >> color;
      row[num] = make_pair(color, i);
    } else {
      long long num, color;
      cin >> num >> color;
      col[num] = make_pair(color, i);
    }
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      if (row[i].second > col[j].second)
        cout << row[i].first << " ";
      else
        cout << col[j].first << " ";
    }
    cout << "\n";
  }
  return 0;
}
