#include <bits/stdc++.h>
using namespace std;
const int Maxn = 1e5 + 5;
int n, k, q, now, cnt, a[15][Maxn], b[Maxn][15];
bitset<4096> f[Maxn];
bool cmp(int x, int y) {
  if (a[x][now] == a[y][now]) return x < y;
  return a[x][now] > a[y][now];
}
int main() {
  scanf("%d%d%d", &n, &k, &q);
  for (int i = 1; i <= k; i++)
    for (int j = 1; j <= n; j++) {
      scanf("%d", &a[i][j]);
      b[j][i] = i;
    }
  for (int i = 1; i <= n; i++) {
    now = i;
    sort(b[i] + 1, b[i] + 1 + k, cmp);
  }
  for (int i = 1; i <= k; i++)
    for (int j = 0; j < (1 << k); j++)
      if (j & (1 << (i - 1))) f[i][j] = 1;
  cnt = k;
  while (q--) {
    int opt, x, y;
    scanf("%d%d%d", &opt, &x, &y);
    if (opt == 1)
      f[++cnt] = f[x] | f[y];
    else if (opt == 2)
      f[++cnt] = f[x] & f[y];
    else {
      int t = 0;
      for (int i = 1; i <= k; i++) {
        t |= (1 << (b[y][i] - 1));
        if (f[x][t]) {
          printf("%d\n", a[b[y][i]][y]);
          break;
        }
      }
    }
  }
  return 0;
}
