#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 13;
const int K = 12;
bitset<4096> lis[N];
int ar[K][N];
pair<int, int> c[K];
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, i, j, k, l, q, now, num;
  cin >> n >> num >> q;
  for (i = 0; i < num; i++) {
    for (j = 0; j < n; j++) {
      cin >> ar[i][j];
    }
  }
  for (i = 0; i < num; i++) {
    for (j = 0; j < (1 << num); j++) {
      lis[i][j] = (j & (1 << i));
    }
  }
  now = num - 1;
  for (i = 1; i <= q; i++) {
    cin >> j >> k >> l;
    k--;
    l--;
    if (j == 1) {
      now++;
      lis[now] = lis[k] & lis[l];
    }
    if (j == 2) {
      now++;
      lis[now] = lis[k] | lis[l];
    }
    if (j == 3) {
      for (j = 0; j < num; j++) {
        c[j] = {ar[j][l], j};
      }
      sort(c, c + num);
      l = 0;
      for (j = 0; j < num; j++) {
        l |= (1 << c[j].second);
        if (lis[k][l]) {
          cout << c[j].first << '\n';
          break;
        }
      }
    }
  }
}
