#include <bits/stdc++.h>
using namespace std;
int n, m, k, TIME[3][5005], color[3][5005], a[5005][5005];
set<pair<int, pair<int, int> > > s;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m >> k;
  for (int T = 0; T < k; T++) {
    int type, x, col;
    cin >> type >> x >> col;
    s.erase(make_pair(TIME[type][x], pair<int, int>(type, x)));
    color[type][x] = col;
    TIME[type][x] = T;
    s.insert(make_pair(TIME[type][x], pair<int, int>(type, x)));
  }
  for (set<pair<int, pair<int, int> > >::iterator it = s.begin(); it != s.end();
       it++) {
    if (it->second.first == 1) {
      for (int i = 1; i <= m; i++)
        a[it->second.second][i] = color[it->second.first][it->second.second];
    } else {
      for (int i = 1; i <= n; i++)
        a[i][it->second.second] = color[it->second.first][it->second.second];
    }
  }
  for (int i = 1; i <= n; i++, cout << endl)
    for (int j = 1; j <= m; j++) cout << a[i][j] << ' ';
  return 0;
}
