#include <bits/stdc++.h>
using namespace std;
long long fpow(long long base, long long power) {
  long long result = 1;
  while (power > 0) {
    if (power % 2 == 1) {
      result = (result * base);
    }
    base = (base * base);
    power /= 2;
  }
  return result;
}
pair<long long, long long> r[6000];
pair<long long, long long> c[6000];
int main() {
  long long n, m, k;
  cin >> n >> m >> k;
  long long i;
  for (i = 0; i < k; i++) {
    long long id, rc, col;
    cin >> id >> rc >> col;
    if (id == 1) {
      r[rc].first = i + 1;
      r[rc].second = col;
    } else {
      c[rc].first = i + 1;
      c[rc].second = col;
    }
  }
  long long j;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      long long maxx = r[i].first;
      maxx = max(maxx, c[j].first);
      if (r[i].first > c[j].first) {
        cout << r[i].second << " ";
      } else {
        cout << c[j].second << " ";
      }
    }
    cout << "\n";
  }
  return 0;
}
