#include <bits/stdc++.h>
#pragma GCC optimize "03"
using namespace std;
const long long int inf = LONG_MAX;
const long long int MOD = 1e9 + 7;
const long long int N = 5005;
pair<long long int, long long int> r[N], c[N];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long int n, m, k;
  cin >> n >> m >> k;
  for (long long int i = 1; i <= k; i++) {
    long long int a, b, cc;
    cin >> a >> b >> cc;
    if (a == 1)
      r[b] = {i, cc};
    else
      c[b] = {i, cc};
  }
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = 1; j <= m; j++) {
      if (r[i].first >= c[j].first)
        cout << r[i].second << " ";
      else
        cout << c[j].second << " ";
    }
    cout << '\n';
  }
  return 0;
}
