#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int l[5050];
int stl[5050];
int w[5050];
int str[5050];
int main() {
  scanf("%d %d %d", &n, &m, &k);
  int x;
  int a, b;
  for (int i = 1; i <= k; i++) {
    scanf("%d %d %d", &x, &a, &b);
    if (x == 1) {
      l[a] = i;
      str[a] = b;
    } else {
      w[a] = i;
      stl[a] = b;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (w[j] > l[i]) {
        printf("%d ", stl[j]);
      } else {
        printf("%d ", str[i]);
      }
    }
    cout << endl;
  }
  return 0;
}
