#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
map<long long, long long> cpos, rpos, c, r;
long long ans[5005][5005];
void solve() {
  long long n, m, k;
  cin >> n >> m >> k;
  for (long long i = 1; i <= k; i++) {
    long long t, x, a;
    cin >> t >> x >> a;
    if (t == 1) {
      rpos[x] = i;
      r[x] = a;
    } else {
      cpos[x] = i;
      c[x] = a;
    }
  }
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= m; j++)
      if (rpos[i] > cpos[j])
        ans[i][j] = r[i];
      else
        ans[i][j] = c[j];
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) cout << ans[i][j] << " ";
    cout << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  long long t;
  t = 1;
  while (t--) {
    solve();
  }
}
