#include <bits/stdc++.h>
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
using namespace std;
bool isPowerOfTwo(int x) { return x && (!(x & (x - 1))); }
int takemod(int x) { return (x % 1000000007 + 1000000007) % 1000000007; }
int fpow(int base, int power, int MOD) {
  int result = 1;
  base = base % MOD;
  while (power) {
    if (power & 1) result = (result * base) % MOD;
    base = (base * base) % MOD;
    power = power >> 1;
  }
  return result;
}
int modinv(int x) { return fpow(x, 1000000007 - 2, 1000000007); }
void solve() {
  long long int n, m, k;
  cin >> n >> m >> k;
  map<long long int, long long int> pqrow;
  map<long long int, long long int> pqcol;
  vector<long long int> row(5005, 0), col(5005, 0);
  for (long long int i = 0; i < (k); ++i) {
    long long int op;
    cin >> op;
    if (op == 1) {
      long long int ind, val;
      cin >> ind >> val;
      ind--;
      pqrow[ind] = i;
      row[ind] = val;
    } else {
      long long int ind, val;
      cin >> ind >> val;
      ind--;
      pqcol[ind] = i;
      col[ind] = val;
    }
  }
  for (long long int i = 0; i < (n); ++i) {
    for (long long int j = 0; j < (m); ++j) {
      if (row[i] == 0 || col[j] == 0) {
        if (row[i] != 0)
          cout << row[i];
        else if (col[j] != 0)
          cout << col[j];
        else
          cout << 0;
      } else {
        if (pqrow[i] > pqcol[j]) {
          cout << row[i];
        } else
          cout << col[j];
      }
      cout << " ";
    }
    cout << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  int T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
