#include <bits/stdc++.h>
using namespace std;
const long double Pi = 3.14159265359;
const long MOD = (long)1e9 + 7;
long long const MAXN = (long long)1e6 + 10;
long long r[5000];
long long rt[5000];
long long c[5000];
long long ct[5000];
int main() {
  ios::sync_with_stdio(false);
  long long n, m, k;
  cin >> n >> m >> k;
  long long t, x, co;
  for (int i = 0; i < k; i++) {
    cin >> t >> x >> co;
    if (t == 1) {
      r[x - 1] = co;
      rt[x - 1] = i + 1;
    }
    if (t == 2) {
      c[x - 1] = co;
      ct[x - 1] = i + 1;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (rt[i] > ct[j]) {
        cout << r[i] << " ";
      } else
        cout << c[j] << " ";
    }
    cout << endl;
  }
  return 0;
}
