#include <bits/stdc++.h>
using namespace std;
struct node {
  int color, idx;
} row[5002], colu[5002];
int main() {
  int n, m, k, i, j;
  while (~scanf("%d %d %d", &n, &m, &k)) {
    for (i = 1; i <= k; i++) {
      int u, v, w;
      scanf("%d %d %d", &u, &v, &w);
      if (u == 1) {
        row[v].color = w;
        row[v].idx = i;
      } else {
        colu[v].color = w;
        colu[v].idx = i;
      }
    }
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= m; j++) {
        if (row[i].color && colu[j].color) {
          if (row[i].idx > colu[j].idx) {
            printf("%d", row[i].color);
          } else
            printf("%d", colu[j].color);
        } else if (row[i].color) {
          printf("%d", row[i].color);
        } else if (colu[j].color) {
          printf("%d", colu[j].color);
        } else {
          printf("0");
        }
        if (j < m)
          printf(" ");
        else
          printf("\n");
      }
    }
  }
}
