#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  pair<int, int> rows[n];
  pair<int, int> columns[m];
  for (int i = 0; i < n; i++) rows[i].first = rows[i].second = 0;
  for (int i = 0; i < m; i++) columns[i].first = columns[i].second = 0;
  int t = 1;
  while (k--) {
    int x, a, val;
    scanf("%d%d%d", &x, &a, &val);
    if (x == 1) {
      rows[a - 1].first = val;
      rows[a - 1].second = t++;
    } else {
      columns[a - 1].first = val;
      columns[a - 1].second = t++;
    }
  }
  for (int i = 0; i < n; i++) {
    int x = rows[i].first;
    int time = rows[i].second;
    for (int j = 0; j < m; j++) {
      int y = columns[j].first;
      int z = columns[j].second;
      if (z > time)
        printf("%d ", y);
      else
        printf("%d ", x);
    }
    printf("\n");
  }
  return 0;
}
