#include <bits/stdc++.h>
using namespace std;
template <class T, class T2>
inline void chkmax(T &x, const T2 &y) {
  if (x < y) x = y;
}
template <class T, class T2>
inline void chkmin(T &x, const T2 &y) {
  if (x > y) x = y;
}
const int MAXN = (int)1e5 + 17;
const int MAXSTATES = (1 << 12);
int n, k, q, m;
int a[MAXN][12];
bitset<MAXSTATES> dp[MAXN];
vector<int> li[MAXN];
int curr_col;
bool cmp(int i, int j) { return a[curr_col][i] > a[curr_col][j]; }
void read() {
  cin >> n >> k >> q;
  for (int j = 0; j < k; j++) {
    for (int i = 0; i < n; i++) cin >> a[i][j];
    for (int mask = 0; mask < (1 << k); mask++)
      if (mask & (1 << j)) dp[j + 1][mask] = 1;
  }
  m = k;
}
void set_min(int i, int j) {
  m++;
  dp[m] = dp[i] & dp[j];
}
void set_max(int i, int j) {
  m++;
  dp[m] = dp[i] | dp[j];
}
int get(int i, int col) {
  int cmask = 0, ret = -1;
  for (int p = 0; p < k; p++) {
    cmask |= (1 << li[col][p]);
    if (dp[i][cmask]) {
      ret = p;
      break;
    }
  }
  return a[col][li[col][ret]];
}
void solve() {
  for (int i = 0; i < n; i++) {
    curr_col = i;
    for (int j = 0; j < k; j++) li[i].push_back(j);
    sort(li[i].begin(), li[i].end(), cmp);
  }
  while (q--) {
    int type;
    cin >> type;
    if (type == 1) {
      int x, y;
      cin >> x >> y;
      set_max(x, y);
    } else if (type == 2) {
      int x, y;
      cin >> x >> y;
      set_min(x, y);
    } else {
      int x, y;
      cin >> x >> y;
      cout << get(x, y - 1) << '\n';
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  read();
  solve();
  return 0;
}
