#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret *= a;
    a *= a;
    if (ret >= 1000000007) ret %= 1000000007;
    if (a >= 1000000007) a %= 1000000007;
    b >>= 1;
  }
  return ret;
}
int main() {
  long long t, i, j, n, m, k, ch, r, colr, c;
  cin >> n >> m >> k;
  long long a[n + 1][m + 1];
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      a[i][j] = 0;
    }
  }
  map<long long, pair<long long, long long> > row, col;
  for (i = 1; i <= k; i++) {
    cin >> ch;
    if (ch == 1) {
      cin >> r >> colr;
      row[r] = make_pair(colr, i);
    } else {
      cin >> c >> colr;
      col[c] = make_pair(colr, i);
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (col[j].first && row[i].first) {
        if (col[j].second > row[i].second) {
          a[i][j] = col[j].first;
        } else {
          a[i][j] = row[i].first;
        }
      } else if (col[j].second) {
        a[i][j] = col[j].first;
      } else {
        a[i][j] = row[i].first;
      }
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      cout << a[i][j] << " ";
    }
    cout << endl;
  }
}
