#include <bits/stdc++.h>
using namespace std;
int n, k, q, ib, t, x, y;
vector<int> z, res;
vector<vector<int> > a;
bitset<4096> b[100012];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> k >> q;
  a.assign(k, vector<int>(n));
  for (int i = 0; i < k; ++i) {
    for (int j = 0; j < n; ++j) cin >> a[i][j];
    for (int j = 0; j < (1 << k); ++j)
      if ((j & (1 << i)) > 0) b[i][j] = 1;
  }
  ib = k;
  z.resize(k);
  for (int i = 0; i < q; ++i) {
    cin >> t >> x >> y;
    --x;
    --y;
    if (t == 1) b[ib++] = b[x] | b[y];
    if (t == 2) b[ib++] = b[x] & b[y];
    if (t != 3) continue;
    for (int j = 0; j < k; ++j) z[j] = a[j][y];
    sort(z.begin(), z.end());
    int sum = 0;
    for (int j = 0; j < k; ++j) {
      int pos = 0;
      for (int s = k - 1; s >= 0; --s) pos = 2 * pos + (a[s][y] >= z[j]);
      sum += b[x][pos];
    }
    cout << z[sum - 1] << "\n";
  }
  return 0;
}
