#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const int mof = 1000000007;
const int inf = 1000000010;
const long long llinf = 1000000007000000007;
const double pi = 3.14159265359;
int r[5555];
int rt[5555];
int c[5555];
int ct[5555];
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= k; i++) {
    int type;
    cin >> type;
    if (type == 1) {
      int x, y;
      scanf("%d%d", &x, &y);
      r[x - 1] = y;
      rt[x - 1] = i;
    } else {
      int x, y;
      scanf("%d%d", &x, &y);
      c[x - 1] = y;
      ct[x - 1] = i;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (rt[i] < ct[j]) {
        cout << c[j] << " ";
      } else {
        cout << r[i] << " ";
      }
    }
    cout << endl;
  }
  return 0;
}
