#include <bits/stdc++.h>
using namespace std;
int r[2][5555];
int c[2][5555];
int main() {
  int x, y, z;
  int n, m, k;
  scanf("%d %d %d", &n, &m, &k);
  memset(r, 0, sizeof(r));
  memset(c, 0, sizeof(c));
  for (int i = 1; i <= k; i++) {
    scanf("%d %d %d", &x, &y, &z);
    if (x == 1) {
      r[0][y] = z;
      r[1][y] = i;
    } else if (x == 2) {
      c[0][y] = z;
      c[1][y] = i;
    }
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      printf("%d%c", r[1][i] > c[1][j] ? r[0][i] : c[0][j],
             j == m ? '\n' : ' ');
  return 0;
}
