#include <bits/stdc++.h>
using namespace std;
int n, m, k, a, u, v;
struct hoho {
  int x, y;
};
hoho A[5005], F[5005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> k;
  for (int i = 1; i <= k; i++) {
    cin >> a;
    if (a == 1) {
      cin >> u;
      cin >> A[u].x;
      A[u].y = i;
    } else {
      cin >> u;
      cin >> F[u].x;
      F[u].y = i;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (A[i].y > F[j].y) {
        cout << A[i].x << " ";
      } else
        cout << F[j].x << " ";
    }
    cout << "\n";
  }
  return 0;
}
