#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
long long power(long long base, long long exp);
void solve() {
  long long n, m, k;
  cin >> n >> m >> k;
  vector<vector<long long>> arr(n, vector<long long>(m, 0));
  long long count[3][5001];
  memset(count, 0, sizeof(count));
  list<pair<long long, long long>> key;
  for (long long i = 0; i < k; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    key.push_front({a, b});
    count[a][b] = c;
  }
  set<pair<long long, long long>> s;
  for (auto k : key) {
    long long x = k.first;
    if (s.count(k))
      continue;
    else
      s.insert(k);
    if (x == 2) {
      for (long long i = 0; i < n; i++) {
        if (arr[i][k.second - 1] == 0) {
          arr[i][k.second - 1] = count[k.first][k.second];
        }
      }
    } else {
      for (long long i = 0; i < m; i++) {
        if (arr[k.second - 1][i] == 0) {
          arr[k.second - 1][i] = count[k.first][k.second];
        }
      }
    }
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      cout << arr[i][j] << " ";
    }
    cout << "\n";
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  srand(chrono::high_resolution_clock::now().time_since_epoch().count());
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
long long power(long long base, long long exp) {
  base %= 1000000007;
  long long result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((long long)result * base) % 1000000007;
    base = ((long long)base * base) % 1000000007;
    exp >>= 1;
  }
  return result;
}
