#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
const long long mod = (long long)1e9 + 7;
bool visc[N], visr[N];
int table[5005][5005];
int o[N], r[N], c[N];
int main() {
  ios_base::sync_with_stdio(false);
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < k; i++) {
    cin >> o[i] >> r[i] >> c[i];
    r[i]--;
  }
  for (int i = k - 1; i >= 0; i--) {
    int oo = o[i], rr = r[i], cc = c[i];
    if (oo == 1) {
      if (visr[rr]) continue;
      for (int j = 0; j < m; j++)
        if (table[rr][j] == 0) table[rr][j] = cc;
      visr[rr] = 1;
    } else {
      if (visc[rr]) continue;
      for (int j = 0; j < n; j++)
        if (table[j][rr] == 0) table[j][rr] = cc;
      visc[rr] = 1;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (j) cout << " ";
      cout << table[i][j];
    }
    cout << '\n';
  }
}
