#include <bits/stdc++.h>
using namespace std;
long long flag, cnt, j, i, k, powe, count1, count2;
long long int n, a, b, y, m, ans, ans1, ans2;
long long maxy, miny, sum, ann[1000010];
string s, s2;
long long mod = 1000000007;
const int N = 5000, K = (int)1e5 + 1;
int r[N], c[N], x[K];
int main() {
  cin >> n >> m >> k;
  x[0] = 0;
  for (i = 1; i <= k; i++) {
    cin >> a >> b >> x[i];
    if (a == 1)
      r[--b] = i;
    else
      c[--b] = i;
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) cout << x[max(r[i], c[j])] << " ";
    cout << endl;
  }
}
