#include <bits/stdc++.h>
using namespace std;
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int &x, int y, int mod = 1000000007) {
  assert(y >= 0);
  x += y;
  if (x >= mod) x -= mod;
  assert(x >= 0 && x < mod);
}
void et() {
  puts("-1");
  exit(0);
}
long long fastPow(long long x, long long y, int mod = 1000000007) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = (x * ans) % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
long long gcd1(long long x, long long y) {
  long long z = y;
  while (x % y != 0) {
    z = x % y;
    x = y;
    y = z;
  }
  return z;
}
int a[12][100105];
bitset<4100> b[100105 << 1];
int c[100105][12];
void fmain(int ID) {
  scanf("%d%d%d", &n, &k, &m);
  for (int(i) = 0; (i) < (int)(k); (i)++) {
    for (int(j) = 0; (j) < (int)(n); (j)++) scanf("%d", &a[i][j]);
    for (int j = 0; j < 1 << k; j++) {
      if ((j >> i) & 1) b[i][j] = 1;
    }
  }
  for (int(j) = 0; (j) < (int)(n); (j)++) {
    for (int(i) = 0; (i) < (int)(k); (i)++)
      for (int(z) = 0; (z) < (int)(k); (z)++)
        if (a[z][j] >= a[i][j]) {
          c[j][i] |= 1 << z;
        }
  }
  int cnt = k;
  for (int(i) = 1; (i) <= (int)(m); (i)++) {
    int t, x, y;
    scanf("%d%d%d", &t, &x, &y);
    x--;
    y--;
    if (t == 1)
      b[cnt++] = b[x] | b[y];
    else if (t == 2)
      b[cnt++] = b[x] & b[y];
    else {
      int ans = 0;
      for (int(j) = 0; (j) < (int)(k); (j)++)
        if (b[x][c[y][j]]) {
          ans = max(ans, a[j][y]);
        }
      printf("%d\n", ans);
    }
  }
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}
