#include <bits/stdc++.h>
using namespace std;
struct qeury {
  int a, b, c;
};
const int N = 5000 + 5;
int ans[N][N];
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  set<pair<int, int>> in;
  set<int> r, cc;
  for (int i = 0; i < n; i++) {
    r.insert(i);
  }
  for (int i = 0; i < m; i++) {
    cc.insert(i);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      in.insert({i, j});
    }
  }
  vector<qeury> q;
  int a, b, c;
  for (int i = 0; i < k; i++) {
    cin >> a >> b >> c;
    q.push_back({a, b, c});
  }
  reverse(q.begin(), q.end());
  for (int i = 0; i < q.size(); i++) {
    a = q[i].a;
    b = q[i].b - 1;
    c = q[i].c;
    if (a == 1) {
      if (r.count(b)) {
        r.erase(b);
        for (int j = 0; j < m; j++) {
          if (in.count({b, j})) {
            ans[b][j] = c;
            in.erase({b, j});
          }
        }
      }
    } else {
      if (cc.count(b)) {
        cc.erase(b);
        for (int j = 0; j < n; j++) {
          if (in.count({j, b})) {
            ans[j][b] = c;
            in.erase({j, b});
          }
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cout << ans[i][j];
      if (j < m - 1) cout << " ";
    }
    cout << "\n";
  }
}
