#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> str(100001);
vector<pair<int, int>> stb(100001);
int main() {
  int n, m, k;
  scanf("%d %d %d", &n, &m, &k);
  int kk = 1;
  while (k--) {
    int i, r, c;
    scanf("%d %d %d", &i, &r, &c);
    if (i == 1) {
      str[r - 1] = make_pair(kk, c);
    } else
      stb[r - 1] = make_pair(kk, c);
    kk++;
  }
  printf("\n");
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (str[i].first > stb[j].first) {
        printf("%d ", str[i].second);
      } else
        printf("%d ", stb[j].second);
    }
    printf("\n");
  }
  return 0;
}
