#include <bits/stdc++.h>
using namespace std;
const int mx = 100001;
vector<pair<int, int> > g[mx];
bool vis[mx];
int dis[mx];
void solve();
int main() {
  int t = 1;
  for (int i = 0; i < t; i++) solve();
}
int n;
int R[5001], C[5001], r[5001], c[5001];
int ar[5001][5001];
void solve() {
  int n, m, q, i, j, k, y;
  cin >> n >> m >> q;
  for (y = 0; y < q; y++) {
    cin >> i >> j >> k;
    j--;
    if (i == 1) {
      R[j] = k;
      r[j] = y;
    } else {
      C[j] = k;
      c[j] = y;
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (R[i] && C[j]) {
        if (r[i] > c[j])
          ar[i][j] = R[i];
        else
          ar[i][j] = C[j];
      } else if (R[i])
        ar[i][j] = R[i];
      else if (C[j])
        ar[i][j] = C[j];
      cout << ar[i][j] << " ";
    }
    cout << "\n";
  }
}
