#include <bits/stdc++.h>
using namespace std;
bitset<100015> A[4096];
int n, m, k, q, lp, S, a[12][100015], t[100015], x[100015], y[100015],
    p[100015];
int main() {
  int i, j, l;
  scanf("%d %d %d", &n, &k, &q);
  for (i = 0; i < k; i++)
    for (j = 1; j <= n; j++) scanf("%d", &a[i][j]);
  for (i = 1; i <= q; i++) {
    scanf("%d %d %d", &t[i], &x[i], &y[i]);
    if (t[i] <= 2)
      x[i]--, y[i]--;
    else
      x[i]--;
  }
  for (i = 0; i < (1 << k); i++) {
    m = k;
    for (j = 0; j < k; j++) A[i][j] = ((i >> j) & 1);
    for (j = 1; j <= q; j++) {
      if (t[j] == 1) A[i][m++] = (A[i][x[j]] | A[i][y[j]]);
      if (t[j] == 2) A[i][m++] = (A[i][x[j]] & A[i][y[j]]);
    }
  }
  for (i = 1; i <= q; i++) {
    if (t[i] != 3) continue;
    for (j = 0; j < k; j++) p[j] = a[j][y[i]];
    sort(p, p + k);
    for (j = 0; j < k; j++) {
      for (l = S = 0; l < k; l++)
        if (a[l][y[i]] > p[j]) S |= (1 << l);
      if (!A[S][x[i]]) break;
    }
    printf("%d\n", p[j]);
  }
  return 0;
}
