#include <bits/stdc++.h>
using namespace std;
int n, m, k, x, y, z, a[5005], b[5005], r[5005], c[5005];
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= k; i++) {
    cin >> z >> x >> y;
    if (z == 1)
      r[x] = y, a[x] = i;
    else
      c[x] = y, b[x] = i;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) cout << (a[i] > b[j] ? r[i] : c[j]) << " ";
    cout << endl;
  }
  return 0;
}
