#include <bits/stdc++.h>
using namespace std;
const int N = 100000, M = 12;
int n, m, cq, a[N + 9][M + 9];
void into() {
  scanf("%d%d%d", &n, &m, &cq);
  for (int i = 0; i < m; ++i)
    for (int j = 1; j <= n; ++j) scanf("%d", &a[j][i]);
}
int ord[N + 9][M + 9];
void Get_ord() {
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < m; ++j) ord[i][j] = j;
    sort(ord[i], ord[i] + m,
         [&](const int &x, const int &y) { return a[i][x] > a[i][y]; });
  }
}
bitset<1 << M> b[N + 9];
int cb;
void Get_b() {
  cb = m;
  for (int i = 1; i <= m; ++i)
    for (int s = 0; s < 1 << m; ++s) b[i][s] = s >> i - 1 & 1;
}
void work() {
  Get_ord();
  Get_b();
}
void outo() {
  for (; cq--;) {
    int opt, x, y;
    scanf("%d%d%d", &opt, &x, &y);
    switch (opt) {
      case 1:
        b[++cb] = b[x] | b[y];
        break;
      case 2:
        b[++cb] = b[x] & b[y];
        break;
      case 3:
        for (int i = 0, s = 0; i < m; ++i) {
          s |= 1 << ord[y][i];
          if (b[x][s]) {
            printf("%d\n", a[y][ord[y][i]]);
            break;
          }
        }
        break;
    }
  }
}
int main() {
  into();
  work();
  outo();
  return 0;
}
