#include <bits/stdc++.h>
using namespace std;
class z {
 public:
  z(int t1, int n1, int c1) {
    t = t1;
    c = c1;
    num = n1;
  }
  int t;
  int num;
  int c;
};
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  int na[6000] = {0};
  int ma[6000] = {0};
  vector<vector<int> > res;
  res.reserve(n + 3);
  vector<int> vsp;
  vsp.reserve(5005);
  for (int i = 0; i < m; ++i) vsp.push_back(0);
  for (int i = 0; i < n; ++i) res.push_back(vsp);
  vector<z> ka;
  ka.reserve(100005);
  for (int i = 0; i < k; ++i) {
    int t, num, c;
    cin >> t >> num >> c;
    z zz(t, num, c);
    ka.push_back(zz);
  }
  for (int i = k - 1; i >= 0; --i) {
    if (ka[i].t == 1 && na[ka[i].num - 1] == 0) {
      int nn = ka[i].num - 1;
      int cc = ka[i].c;
      na[nn] = cc;
      for (int i = 0; i < m; ++i)
        if (res[nn][i] == 0) res[nn][i] = cc;
    } else if (ka[i].t == 2 && ma[ka[i].num - 1] == 0) {
      int mm = ka[i].num - 1;
      int cc = ka[i].c;
      ma[mm] = cc;
      for (int i = 0; i < n; ++i)
        if (res[i][mm] == 0) res[i][mm] = cc;
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int i1 = 0; i1 < m; ++i1) cout << res[i][i1] << ' ';
    cout << endl;
  }
  return 0;
}
