#include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 10;
pair<int, int> R[N], S[N];
int i, n, m, k, type, l, r, j;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  scanf("%d%d%d", &n, &m, &k);
  for (i = 1; i <= k; ++i) {
    scanf("%d%d%d", &type, &l, &r);
    if (type == 1)
      R[l].first = i, R[l].second = r;
    else
      S[l].first = i, S[l].second = r;
  }
  for (i = 1; i <= n; ++i) {
    for (j = 1; j <= m; ++j) {
      if (j > 1) printf(" ");
      if (R[i].first > S[j].first)
        printf("%d", R[i].second);
      else
        printf("%d", S[j].second);
    }
    printf("\n");
  }
  return 0;
}
