#include <bits/stdc++.h>
using namespace std;
int main() {
  int r[5000], c[5000], a[100001];
  int n, k, m, num, d;
  cin >> n >> m >> k;
  for (int i = 1; i <= k; i++) {
    cin >> num >> d >> a[i];
    if (num == 1)
      r[d] = i;
    else
      c[d] = i;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) cout << a[max(r[i], c[j])] << ' ';
    cout << endl;
  }
  return 0;
}
