#include <bits/stdc++.h>
using namespace std;
int row[5001], col[5001];
int op[100001], a[100001], b[100001];
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= k; ++i) {
    scanf("%d%d%d", &op[i], &a[i], &b[i]);
    if (op[i] == 1)
      row[a[i]] = i;
    else
      col[a[i]] = i;
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      int x = (col[j] <= row[i] ? b[row[i]] : b[col[j]]);
      if (j == m)
        printf("%d\n", x);
      else
        printf("%d ", x);
    }
  }
  return 0;
}
