#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const long long mod = 998244353;
int a[15][maxn];
bitset<4096> s[maxn];
int main() {
  int N, M, Q;
  scanf("%d%d%d", &N, &M, &Q);
  for (int i = 1; i <= M; i++) {
    for (int j = 1; j <= N; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  for (int i = 1; i < 4096; i++) {
    for (int j = 1; j <= M; j++) {
      if (i & (1 << (j - 1))) s[j].set(i);
    }
  }
  int tot = M + 1;
  for (int i = 1; i <= Q; i++) {
    int t, x, y;
    scanf("%d%d%d", &t, &x, &y);
    if (t == 1)
      s[tot++] = s[x] | s[y];
    else if (t == 2)
      s[tot++] = s[x] & s[y];
    else {
      vector<pair<int, int> > v;
      for (int j = 1; j <= M; j++) v.push_back({a[j][y], j});
      sort(v.begin(), v.end(), greater<pair<int, int> >());
      int b = 0;
      for (int j = 0; j < M; j++) {
        b |= (1 << (v[j].second - 1));
        if (s[x][b]) {
          printf("%d\n", a[v[j].second][y]);
          break;
        }
      }
    }
  }
  return 0;
}
