#include <bits/stdc++.h>
using namespace std;
int m, n, k;
int r[5001][2];
int l[5001][2];
int main() {
  cin >> n >> m >> k;
  int rc, w, a;
  for (int p = 1; p <= k; ++p) {
    cin >> rc >> w >> a;
    if (rc == 1) {
      r[w][0] = p;
      r[w][1] = a;
    } else {
      l[w][0] = p;
      l[w][1] = a;
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j < m; ++j) {
      if (r[i][0] > l[j][0])
        cout << r[i][1] << " ";
      else
        cout << l[j][1] << " ";
    }
    if (r[i][0] > l[m][0])
      cout << r[i][1] << endl;
    else
      cout << l[m][1] << endl;
  }
  return 0;
}
