#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m, q;
  cin >> n >> m >> q;
  int arr[n][m];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) arr[i][j] = 0;
  int t[q];
  int nu[q];
  int c[q];
  for (int i = q - 1; i >= 0; i--) {
    cin >> t[i] >> nu[i] >> c[i];
    nu[i]--;
  }
  set<int> row;
  set<int> col;
  for (int i = 0; i < q; i++) {
    if (t[i] == 1 and row.find(nu[i]) == row.end()) {
      row.insert(nu[i]);
      for (int j = 0; j < m; j++)
        if (arr[nu[i]][j] == 0) arr[nu[i]][j] = c[i];
    }
    if (t[i] == 2 and col.find(nu[i]) == col.end()) {
      col.insert(nu[i]);
      for (int j = 0; j < n; j++)
        if (arr[j][nu[i]] == 0) arr[j][nu[i]] = c[i];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) cout << arr[i][j] << " ";
    cout << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) solve();
}
