#include <bits/stdc++.h>
using namespace std;
const int N = 100020;
int a[12][N], v[12], id[12];
bitset<4096> s[N];
inline int gi() {
  int x = 0, o = 1;
  char ch = getchar();
  while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') o = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * o;
}
inline bool cmp(const int &x, const int &y) { return v[x] < v[y]; }
int main() {
  int n, k, q, m;
  cin >> n >> k >> q;
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < n; j++) a[i][j] = gi();
    for (int j = 0; j < 1 << k; j++)
      if (j & (1 << i)) s[i].set(j);
  }
  m = k;
  while (q--) {
    int op = gi(), x = gi() - 1, y = gi() - 1;
    if (op == 1)
      s[m++] = s[x] & s[y];
    else if (op == 2)
      s[m++] = s[x] | s[y];
    else {
      for (int i = 0; i < k; i++) v[i] = a[i][y], id[i] = i;
      sort(id, id + k, cmp);
      for (int i = 0, j = 0; i < k; i++) {
        j |= 1 << id[i];
        if (s[x][j]) {
          printf("%d\n", v[id[i]]);
          break;
        }
      }
    }
  }
  return 0;
}
