#include <bits/stdc++.h>
using namespace std;
long long i, j, k, p, l, m, n, c, d, q, e, r, x, y, mx, mn, pas, ans;
vector<long long> v[10000];
set<long long> st;
pair<long long, long long> qr[2][(int)(2e5 + 100)];
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < max(n, m); i++) qr[0][i] = {0, 0}, qr[1][i] = {0, 0};
  for (int i = 1; i <= k; i++) {
    cin >> q >> p >> c;
    q--;
    p--;
    qr[q][p] = {c, i};
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (qr[0][i].second > qr[1][j].second)
        cout << qr[0][i].first << " ";
      else
        cout << qr[1][j].first << " ";
    }
    cout << endl;
  }
  return 0;
}
