#include <bits/stdc++.h>
using namespace std;
bitset<4100> f[100005];
int pos[100005][14], a[14][100005], n, k, q, nw;
bool cmp(int x, int y) { return a[x][nw] > a[y][nw]; }
int main() {
  scanf("%d%d%d", &n, &k, &q);
  for (int i = 1; i <= k; ++i) {
    for (int j = 1; j <= n; ++j) scanf("%d", &a[i][j]), pos[j][i] = i;
  }
  for (int i = 1; i <= n; ++i) {
    nw = i;
    sort(pos[i] + 1, pos[i] + 1 + k, cmp);
  }
  int zt = 1 << k;
  for (int i = 1, ii = 1; i <= k; ++i, ii <<= 1) {
    for (int j = 1; j < zt; ++j) {
      if (j & ii) f[i][j] = 1;
    }
  }
  int op, x, y, zz = k;
  while (q--) {
    scanf("%d%d%d", &op, &x, &y);
    if (op == 1)
      f[++zz] = f[x] | f[y];
    else if (op == 2)
      f[++zz] = f[x] & f[y];
    else {
      int hc = 0;
      for (int i = 1, p; i <= k; ++i) {
        p = pos[y][i];
        hc |= 1 << p - 1;
        if (f[x][hc]) {
          printf("%d\n", a[p][y]);
          break;
        }
      }
    }
  }
  return 0;
}
