#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y) {
  if (y == 0)
    return x;
  else
    return gcd(y, x % y);
}
long long expo(long long n, long long m) {
  long long r = 1;
  while (m > 0) {
    if (m % 2) r = (r * n) % 1000000007;
    n = (n * n) % 1000000007;
    m = m / 2;
  }
  return r % 1000000007;
}
long long f(vector<long long> &a, long long x) {
  long long s = 0;
  for (long long i = 0; i < a.size(); i++) {
    s += abs(x - a[i]);
  }
  return s;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, m, k;
  cin >> n >> m >> k;
  vector<long long> r(n, -1), c(m, -1);
  vector<pair<long long, pair<long long, long long> > > v;
  for (long long i = 0; i < k; i++) {
    long long x, y, z;
    cin >> x >> y >> z;
    v.push_back(make_pair(x, make_pair(y - 1, z)));
    if (x == 1) {
      r[y - 1] = i;
    } else
      c[y - 1] = i;
  }
  long long a[n][m];
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if (r[i] > c[j]) {
        a[i][j] = v[r[i]].second.second;
      } else if (c[j] > r[i])
        a[i][j] = v[c[j]].second.second;
      else
        a[i][j] = 0;
      cout << a[i][j] << ' ';
    }
    cout << '\n';
  }
  return 0;
}
