#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000000000000;
int main() {
  long long n, m, k;
  cin >> n >> m >> k;
  vector<vector<long long>> v;
  vector<long long> strc(n, 0), colc(m, 0), strt(n, 0), colt(m, 0);
  v.resize(n);
  for (long long i = 0; i < k; i++) {
    long long a, q, w;
    cin >> a >> q >> w;
    q--;
    if (a == 1) {
      strt[q] = i;
      strc[q] = w;
    } else {
      colt[q] = i;
      colc[q] = w;
    }
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if (strc[i] == 0 && colc[j] == 0) cout << "0";
      if (strc[i] == 0 && colc[j] != 0) cout << colc[j];
      if (strc[i] != 0 && colc[j] == 0) cout << strc[i];
      if (strc[i] != 0 && colc[j] != 0) {
        if (strt[i] > colt[j])
          cout << strc[i];
        else
          cout << colc[j];
      }
      cout << ' ';
    }
    cout << endl;
  }
}
