#include <bits/stdc++.h>
using namespace std;
vector<vector<long long> > solve(const vector<long long> &x) {
  int n = x.size();
  vector<vector<long long> > ans(n, vector<long long>(n, 0));
  for (int i = 0; i < n; ++i) {
    ans[i][i] = x[i];
    for (int j = i + 1; j < n; ++j) {
      ans[i][j] = ans[i][j - 1] | x[j];
    }
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.setf(ios::fixed);
  cout.precision(4);
  int n, k, m;
  cin >> n >> m >> k;
  vector<vector<int> > x(n, vector<int>(m, 0));
  vector<pair<int, pair<int, int> > > q;
  for (int i = 0; i < k; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    b--;
    q.push_back({a, {b, c}});
  }
  reverse(q.begin(), q.end());
  vector<int> used1(n, 1);
  vector<int> used2(m, 1);
  for (auto p : q) {
    int z = p.first;
    if (z == 1) {
      int k = p.second.first;
      int a = p.second.second;
      if (used1[k]) {
        for (int i = 0; i < m; ++i) {
          if (x[k][i] == 0) {
            x[k][i] = a;
          }
        }
      }
      used1[k] = 0;
    }
    if (z == 2) {
      int k = p.second.first;
      int a = p.second.second;
      if (used2[k]) {
        for (int i = 0; i < n; ++i) {
          if (x[i][k] == 0) {
            x[i][k] = a;
          }
        }
      }
      used2[k] = 0;
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cout << x[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}
