#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  if (0) freopen("../input.txt", "r", stdin);
  int n, m, k;
  cin >> n >> m >> k;
  pair<int, int> r[n], c[m];
  for (int i = 0; i < n; i++) r[i] = {0, -1};
  for (int i = 0; i < m; i++) c[i] = {0, -1};
  for (int i = 0; i < k; i++) {
    int p, x, y;
    cin >> p >> x >> y;
    if (p == 1)
      r[x - 1] = {y, i};
    else if (p == 2)
      c[x - 1] = {y, i};
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      pair<int, int> c1 = r[i], c2 = c[j];
      printf("%d ", c1.second > c2.second ? c1.first : c2.first);
    }
    printf("\n");
  }
  return 0;
}
