#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  int arr[n][m];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) arr[i][j] = 0;
  int rang[k + 1];
  rang[0] = 0;
  int row[100069] = {0}, col[10069] = {0};
  for (int i = 1; i < k + 1; i++) {
    int x, y, c;
    cin >> x >> y >> c;
    rang[i] = c;
    if (x == 1)
      row[--y] = i;
    else
      col[--y] = i;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) printf("%d ", rang[max(row[i], col[j])]);
    printf("\n");
  }
  return 0;
}
