#include <bits/stdc++.h>
using namespace std;
const long double pi = acosl(-1);
const int maxn = 100100;
const long long mod = 1e6 + 3;
const int inf = 1e9;
int n, k, q;
bitset<4096> bs[maxn];
vector<pair<int, int> > vec[maxn];
int main() {
  int t;
  scanf("%d%d%d", &n, &k, &q);
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < 4096; j++) {
      bs[i][j] = (j >> i) & 1;
    }
    for (int j = 0; j < n; j++) {
      scanf("%d", &t);
      vec[j].push_back({t, i});
    }
  }
  for (int i = 0; i < n; i++) {
    sort(vec[i].begin(), vec[i].end());
  }
  int x, y;
  int w = k;
  for (int i = 0; i < q; i++) {
    scanf("%d%d%d", &t, &x, &y);
    x--;
    y--;
    if (t != 3) {
      bs[w++] = t == 1 ? bs[x] | bs[y] : bs[x] & bs[y];
    } else {
      int s = 0;
      for (int j = k - 1; j >= 0; j--) {
        s |= 1 << vec[y][j].second;
        if (bs[x][s]) {
          printf("%d\n", vec[y][j].first);
          break;
        }
      }
    }
  }
  return 0;
}
