#include <bits/stdc++.h>
using namespace std;
const int N = 110200;
int n, k, size;
int a[14][N], c[14][N];
bitset<4098> b[N << 1];
inline void read(int &x) {
  x = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') {
    x = 10 * x + c - '0';
    c = getchar();
  }
}
int main() {
  int q;
  read(n);
  read(k);
  read(q);
  for (int j = 1; j <= k; ++j)
    for (int i = 1; i <= n; ++i) read(a[j][i]);
  for (int i = 1; i <= k; ++i)
    for (int j = 0; j <= (1 << k) - 1; ++j) b[i][j] = ((j >> (i - 1)) & 1);
  for (int i = 1; i <= k; ++i)
    for (int j = 1; j <= n; ++j)
      for (int p = 1; p <= k; ++p)
        if (a[p][j] >= a[i][j]) c[i][j] |= (1 << (p - 1));
  size = k;
  while (q--) {
    int op, x, y;
    read(op);
    read(x);
    read(y);
    if (op == 1)
      b[++size] = b[x] | b[y];
    else if (op == 2)
      b[++size] = b[x] & b[y];
    else {
      int ans = 0;
      for (int i = 1; i <= k; ++i)
        if (b[x][c[i][y]]) ans = max(ans, a[i][y]);
      printf("%d\n", ans);
    }
  }
  return 0;
}
