#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 123;
const int inf = 1e9 + 123;
const long long INF = 1e18 + 123;
const long long MAXN = 1e10 + 123;
const long long MOD = 1e9 + 7;
const long long mod = 555557;
const double pi = acos(-1.0);
int n, m, k, d1[N], d2[N], b[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> k;
  for (int i = 1, t, a; i <= k; ++i) {
    cin >> t >> a >> b[i];
    if (t == 1)
      d1[a] = i;
    else
      d2[a] = i;
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) cout << b[max(d1[i], d2[j])] << " ";
    cout << endl;
  }
}
