#include <bits/stdc++.h>
const long double EPS = 1e-10;
const long long int MOD = 1000000007ll;
const long long int mod1 = 1000000009ll;
const long long int mod2 = 1100000009ll;
int INF = 2147483645;
long long int INFINF = 9223372036854775807;
int debug = 0;
using namespace std;
long long int bit_count(long long int _x) {
  long long int _ret = 0;
  while (_x) {
    if (_x % 2 == 1) _ret++;
    _x /= 2;
  }
  return _ret;
}
long long int bit(long long int _mask, long long int _i) {
  return (_mask & (1 << _i)) == 0 ? 0 : 1;
}
long long int powermod(long long int _a, long long int _b, long long int _m) {
  long long int _r = 1;
  while (_b) {
    if (_b % 2 == 1) _r = (_r * _a) % _m;
    _b /= 2;
    _a = (_a * _a) % _m;
  }
  return _r;
}
long long int add(long long int a, long long int b, long long int m) {
  long long int x = a + b;
  while (x >= m) x -= m;
  return x;
}
long long int sub(long long int a, long long int b, long long int m) {
  long long int x = a - b;
  while (x < 0) x += m;
  return x;
}
long long int mul(long long int a, long long int b, long long int m) {
  long long int x = a * b;
  x %= m;
  return x;
}
int n, m, k;
pair<int, int> r[5010], c[5010];
int main() {
  srand(time(NULL));
  cin >> n >> m >> k;
  for (int i = 1; i <= k; i++) {
    int type, l, a;
    cin >> type >> l >> a;
    if (type == 1) {
      r[l] = {a, i};
    } else {
      c[l] = {a, i};
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (r[i].first == 0 && c[j].first == 0)
        cout << 0 << " ";
      else {
        if (r[i].second > c[j].second)
          cout << r[i].first << " ";
        else
          cout << c[j].first << " ";
      }
    }
    cout << "\n";
  }
  return 0;
}
