#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int M[3][5005];
int T[3][5005];
int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  int i, j, a, b, c;
  cin >> n >> m >> k;
  for (i = 1; i <= k; ++i) {
    cin >> a >> b >> c;
    M[a][b] = c;
    T[a][b] = i;
  }
  for (i = 1; i <= n; ++i) {
    for (j = 1; j <= m; ++j) {
      if (T[1][i] > T[2][j])
        cout << M[1][i] << " ";
      else
        cout << M[2][j] << " ";
    }
    cout << "\n";
  }
  return 0;
}
