#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1.1e5;
int N, K, Q, R;
vector<pair<int, int> > V[MAXN];
bitset<4096> A[MAXN];
int main() {
  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(pair<int, int>(x, i));
    }
    for (int j = 0; j < (1 << K); j++) {
      A[i][j] = (j >> i) & 1;
    }
  }
  for (int i = 0; i < N; i++) {
    sort((V[i]).begin(), (V[i]).end());
  }
  R = K;
  for (int qi = 0; qi < Q; qi++) {
    int tp, x, y;
    scanf("%d %d %d", &tp, &x, &y);
    x--;
    y--;
    if (tp == 3) {
      int m = 0;
      for (int i = 0; i < K; i++) {
        m |= (1 << V[y][i].second);
        if (A[x][m]) {
          printf("%d\n", V[y][i].first);
          break;
        }
      }
    } else {
      if (tp == 1) {
        A[R++] = (A[x] & A[y]);
      } else {
        A[R++] = (A[x] | A[y]);
      }
    }
  }
}
