#include <bits/stdc++.h>
using namespace std;
int mod = 1e9 + 7;
long long powmod(long long a, long long b) {
  long long res = 1;
  if (a >= mod) a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a;
    if (res >= mod) res %= mod;
    a = a * a;
    if (a >= mod) a %= mod;
  }
  return res;
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long n, m, k, i, j, a, r, op;
pair<long long, long long> row[100010], col[100010];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> k;
  for (i = 0; i <= 100000; i++) {
    row[i] = make_pair(0, -1);
    col[i] = make_pair(0, -1);
  }
  for (i = 0; i < k; i++) {
    cin >> op >> r >> a;
    if (op == 1)
      row[r] = make_pair(a, i);
    else
      col[r] = make_pair(a, i);
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (row[i].second > col[j].second)
        cout << row[i].first << " ";
      else
        cout << col[j].first << " ";
    }
    cout << "\n";
  }
}
