#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
template <typename T>
T pow(T a, T b, long long m) {
  T ans = 1;
  while (b > 0) {
    if (b % 2 == 1) ans = ((ans % m) * (a % m)) % m;
    b /= 2;
    a = ((a % m) * (a % m)) % m;
  }
  return ans % m;
}
int pos[2][5005];
int ans[5005][5005];
int ty[100005], d[100005], a[100005];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, m, k;
  cin >> n >> m >> k;
  memset(pos, -1, sizeof pos);
  for (int i = 0; i < k; i++) {
    cin >> ty[i] >> d[i] >> a[i];
  }
  for (int i = 0; i < k; i++) {
    if (ty[i] == 1)
      pos[0][d[i]] = i;
    else
      pos[1][d[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (pos[0][i] > pos[1][j]) {
        ans[i][j] = a[pos[0][i]];
      } else if (pos[0][i] < pos[1][j]) {
        ans[i][j] = a[pos[1][j]];
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cout << ans[i][j] << " ";
    }
    cout << "\n";
  }
}
