#include <bits/stdc++.h>
using namespace std;
int const N = 201010;
int const M = 4096;
bitset<M> b[N];
vector<pair<int, int> > v[N];
int main() {
  int n, k, q;
  scanf("%d%d%d", &n, &k, &q);
  for (int i = 0; i < (k); ++i) {
    for (int j = 0; j < (n); ++j) {
      int x;
      scanf("%d", &x);
      v[j].push_back(make_pair(x, 1 << i));
    }
    for (int t = 0; t < (M); ++t) b[i][t] = (t >> i & 1);
  }
  for (int i = 0; i < (n); ++i) {
    sort(v[i].begin(), v[i].end());
  }
  int m = k;
  for (int i = 0; i < (q); ++i) {
    int t, x, y;
    scanf("%d%d%d", &t, &x, &y);
    --x, --y;
    if (t == 1) {
      b[m++] = b[x] & b[y];
    } else if (t == 2) {
      b[m++] = b[x] | b[y];
    } else {
      int msk = 0;
      for (int j = 0; j < (k); ++j) {
        msk |= v[y][j].second;
        if (b[x][msk]) {
          printf("%d\n", v[y][j].first);
          break;
        }
      }
    }
  }
  return 0;
}
