#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, M = 13;
int n, k, Q, tot, a[M][N], b[N][M];
bitset<1 << M> f[N + M];
int main() {
  scanf("%d%d%d", &n, &k, &Q), tot = k;
  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)
    sort(b[i] + 1, b[i] + k + 1, [=](int x, int y) {
      return a[x][i] == a[y][i] ? x > y : a[x][i] > a[y][i];
    });
  for (int i = 1; i <= k; ++i)
    for (int S = 0; S < 1 << k; ++S)
      if (S >> (i - 1) & 1) f[i][S] = 1;
  for (int i = 1, op, x, y; i <= Q; ++i) {
    scanf("%d%d%d", &op, &x, &y);
    if (op == 1) f[++tot] = f[x] | f[y];
    if (op == 2) f[++tot] = f[x] & f[y];
    if (op == 3)
      for (int j = 1, S = 0; j <= k; ++j) {
        S |= 1 << (b[y][j] - 1);
        if (f[x][S]) {
          printf("%d\n", a[b[y][j]][y]);
          break;
        }
      }
  }
  return 0;
}
