#include <bits/stdc++.h>
using namespace std;
struct task {
  int t, p, a;
  task(int a, int b, int c) : t(a), p(b), a(c){};
};
int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, k;
  cin >> n >> m >> k;
  vector<vector<int>> v(n, vector<int>(m, 0));
  vector<bool> r_colored(n, false);
  vector<bool> c_colored(m, false);
  stack<task> st;
  for (int i = 0; i < k; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    b--;
    st.push(task(a, b, c));
  }
  while (!st.empty()) {
    task t = st.top();
    st.pop();
    if (t.t == 1) {
      int r = t.p;
      if (!r_colored[r]) {
        r_colored[r] = true;
        for (int i = 0; i < m; i++) {
          if (!c_colored[i]) v[r][i] = t.a;
        }
      }
    } else {
      int c = t.p;
      if (!c_colored[c]) {
        c_colored[c] = true;
        for (int i = 0; i < n; i++) {
          if (!r_colored[i]) v[i][c] = t.a;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cout << v[i][j] << " ";
    }
    cout << '\n';
  }
  return 0;
}
