#include <bits/stdc++.h>
using namespace std;
template <class X>
void input(vector<X>& a, int N) {
  X temp;
  for (long long int i = 0; i < N; i++) {
    cin >> temp;
    a.push_back(temp);
  }
}
void solve() {
  long long int N, M, Q;
  cin >> N >> M >> Q;
  vector<int> row(N, 0);
  vector<int> col(M, 0);
  vector<vector<int>> query;
  for (long long int i = 0; i < Q; i++) {
    vector<int> x(3);
    for (long long int i = 0; i < 3; i++) {
      cin >> x[i];
    }
    if (x[0] == 1) {
      row[x[1] - 1] = i + 1;
    } else {
      col[x[1] - 1] = i + 1;
    }
    query.push_back(x);
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      if (row[i] == 0 && col[j] == 0) {
        cout << 0;
      } else if (row[i] == 0) {
        cout << query[col[j] - 1][2];
      } else if (col[j] == 0) {
        cout << query[row[i] - 1][2];
      } else {
        cout << query[max(col[j] - 1, row[i] - 1)][2];
      }
      cout << " ";
    }
    cout << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
