#include <bits/stdc++.h>
using namespace std;
int n, K, Q, i, j, k, l, tp, x, y, z, t;
int a[13][100001];
bitset<4096> b[200001];
int p[13];
int ans;
struct type {
  int x, id;
} c[13];
bool cmp(type a, type b) { return a.x < b.x; }
int main() {
  p[0] = 1;
  for (i = 1; i <= 12; i++) p[i] = p[i - 1] * 2;
  scanf("%d%d%d", &n, &K, &Q);
  for (i = 1; i <= K; i++)
    for (j = 1; j <= n; j++) scanf("%d", &a[i][j]);
  t = K;
  for (i = 1; i <= K; i++) {
    for (j = 0; j <= p[K] - 1; j++) b[i][j] = (j & p[i - 1]) > 0;
  }
  for (; Q; --Q) {
    scanf("%d%d%d", &tp, &x, &y);
    switch (tp) {
      case 1: {
        b[++t] = b[x] | b[y];
        break;
      }
      case 2: {
        b[++t] = b[x] & b[y];
        break;
      }
      case 3: {
        for (i = 1; i <= K; i++) c[i] = type{a[i][y], i};
        sort(c + 1, c + K + 1, cmp);
        l = p[K] - 1;
        for (i = 1; i <= K; i++) {
          l ^= p[c[i].id - 1];
          if (!b[x][l]) {
            printf("%d\n", c[i].x);
            break;
          }
        }
        break;
      }
    }
  }
  fclose(stdin);
  fclose(stdout);
  return 0;
}
