#include <bits/stdc++.h>
using namespace std;
constexpr int UNDEF = -1;
class Application {
 public:
  inline void Run();

 private:
  inline void LoadData();
  inline void Solve();
  int n, m;
  int k;
};
int main() {
  ios_base::sync_with_stdio(false);
  Application app;
  app.Run();
}
inline void Application::LoadData() {
  cin >> n >> m >> k;
  vector<pair<int, int> > wiersz(n, pair<int, int>(-1, 0));
  vector<pair<int, int> > kolumna(m, pair<int, int>(-1, 0));
  int type, no, color;
  for (int i = 0; i < (k); i++) {
    cin >> type >> no >> color;
    --no;
    if (type == 1) {
      wiersz[no] = pair<int, int>(i, color);
    } else {
      kolumna[no] = pair<int, int>(i, color);
    }
  }
  for (int x = 0; x < (n); x++) {
    for (int y = 0; y < (m); y++) {
      if (kolumna[y].first > wiersz[x].first)
        cout << kolumna[y].second << " ";
      else
        cout << wiersz[x].second << " ";
    }
    cout << "\n";
  }
}
inline void Application::Solve() {}
inline void Application::Run() {
  LoadData();
  Solve();
}
