#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream& operator<<(ostream& out, vector<T>& v) {
  for (auto a : v) out << a << " ";
  return out;
}
template <typename T>
istream& operator>>(istream& in, vector<T>& v) {
  for (auto& a : v) in >> a;
  return in;
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> R(n, 0);
  vector<int> C(m, 0);
  vector<int> S(k + 1, 0);
  for (int i = 1; i <= k; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == 1) {
      R[b - 1] = i;
    } else {
      C[b - 1] = i;
    }
    S[i] = c;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cout << S[max(R[i], C[j])] << " ";
    }
    cout << endl;
  }
  return 0;
}
