#include <bits/stdc++.h>
using namespace std;
const int N = 111111;
const double PI = 2 * acos(0);
const int MOD = 1e9 + 7;
int n, m, k;
int h[N], c[N], a[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 1; i <= k; ++i) {
    int x, q;
    scanf("%d %d %d", &x, &q, &a[i]);
    if (x == 1)
      h[q] = i;
    else
      c[q] = i;
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) printf("%d ", a[max(h[i], c[j])]);
    printf("\n");
  }
}
