#include <bits/stdc++.h>
using namespace std;
const int maxn = 111111;
inline int read() {
  int x = 0, f = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') f |= ch == '-', ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return f ? -x : x;
}
struct node {
  int id, val;
  bool operator<(const node &nd) const { return val > nd.val; }
};
int n, k, q, a[13][maxn], cnt;
node b[maxn][13];
bitset<4096> bs[maxn];
int main() {
  n = read();
  k = cnt = read();
  q = read();
  for (int i = (1); i <= (k); i++) {
    for (int j = (1); j <= (n); j++) {
      a[i][j] = read();
      b[j][i] = (node){i, a[i][j]};
    }
    for (int s = (0); s <= ((1 << k) - 1); s++)
      if (s & (1 << (i - 1))) bs[i].set(s);
  }
  for (int i = (1); i <= (n); i++) sort(b[i] + 1, b[i] + k + 1);
  while (q--) {
    int op = read(), x = read(), y = read();
    if (op == 1) bs[++cnt] = bs[x] | bs[y];
    if (op == 2) bs[++cnt] = bs[x] & bs[y];
    if (op == 3) {
      int s = 0;
      for (int i = (1); i <= (k); i++) {
        s |= 1 << (b[y][i].id - 1);
        if (bs[x][s] == 1) {
          printf("%d\n", b[y][i].val);
          break;
        }
      }
    }
  }
}
