#include <bits/stdc++.h>
using namespace std;
struct node {
  int a;
  int t;
  node() {
    a = 0;
    t = 0;
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m, k;
  n = ({
    int a;
    scanf("%d", &a);
    a;
  });
  m = ({
    int a;
    scanf("%d", &a);
    a;
  });
  k = ({
    int a;
    scanf("%d", &a);
    a;
  });
  int tt = 0;
  node dpr[5005];
  node dpc[5005];
  for (__typeof(k) i = (1); i <= k; ++i) {
    int kk = ({
      int a;
      scanf("%d", &a);
      a;
    });
    int p = ({
      int a;
      scanf("%d", &a);
      a;
    });
    int q = ({
      int a;
      scanf("%d", &a);
      a;
    });
    ++tt;
    if (kk == 1)
      dpr[p - 1].a = q, dpr[p - 1].t = tt;
    else
      dpc[p - 1].a = q, dpc[p - 1].t = tt;
  }
  for (__typeof(n - 1) i = (0); i <= n - 1; ++i) {
    bool fg = false;
    int pk = dpr[i].a;
    for (__typeof(m - 1) j = (0); j <= m - 1; ++j) {
      if (dpr[i].t >= dpc[j].t)
        printf("%d", pk);
      else
        printf("%d", dpc[j].a);
      if (j != m - 1) putchar(' ');
    }
    printf("\n");
  }
  return 0;
}
