#include <bits/stdc++.h>
using namespace std;
pair<string, string> second[50005];
int a[5005][5005] = {};
int r1[5005] = {}, r[5005] = {};
int c1[5005] = {}, c[5005] = {};
int main() {
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  int k;
  cin >> k;
  for (int i = 1; i <= k; i++) {
    int q, x, y;
    cin >> q >> x >> y;
    if (q == 1) {
      r[x] = y;
      r1[x] = i;
    } else {
      c[x] = y;
      c1[x] = i;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++)
      if (c1[j] > r1[i])
        cout << c[j] << " ";
      else
        cout << r[i] << " ";
    cout << endl;
  }
  return 0;
}
