#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
int ans[5010][5010];
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int n, m, k;
  cin >> n >> m >> k;
  int st = 0;
  vector<pair<int, int> > r(n, {0, 0});
  vector<pair<int, int> > c(m, {0, 0});
  for (int i = 0; i < k; i++) {
    int x, rc, z;
    cin >> x >> rc >> z;
    rc--;
    if (x == 1)
      r[rc] = {z, i + 1};
    else
      c[rc] = {z, i + 1};
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (r[i].second > c[j].second)
        ans[i][j] = r[i].first;
      else
        ans[i][j] = c[j].first;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) cout << ans[i][j] << ' ';
    cout << endl;
  }
  return 0;
}
