#include <bits/stdc++.h>
using namespace std;
const int N = 5005, MOD = 7 + 1e9;
pair<int, int> r[N], c[N];
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++) r[i] = make_pair(0, 0);
  for (int i = 1; i <= m; i++) c[i] = make_pair(0, 0);
  for (int i = 1; i <= k; i++) {
    int tp, x, a;
    scanf("%d%d%d", &tp, &x, &a);
    if (tp == 1)
      r[x].first = a, r[x].second = i;
    else
      c[x].first = a, c[x].second = i;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j < m; j++)
      printf("%d ", r[i].second > c[j].second ? r[i].first : c[j].first);
    printf("%d\n", r[i].second > c[m].second ? r[i].first : c[m].first);
  }
  return 0;
}
