#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long double pi = acos(-1);
const int MOD = 1e9 + 7;
const long long int LINF = 0x3f3f3f3f3f3f3f3f;
bitset<4096> bs[100050];
pair<int, int> carac[100005][15];
int c[15][100005];
int n, k, q;
int type[100050];
int a[100050];
int b[100050];
int qte;
int pega(int x, int y) {
  int mask = 0;
  for (int i = k - 1; i >= 0; i--) {
    mask ^= (1 << carac[y][i].second);
    if (bs[x][mask]) {
      return carac[y][i].first;
    }
  }
}
int main() {
  scanf("%d%d%d", &n, &k, &q);
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < n; j++) {
      scanf("%d", &c[i][j]);
      carac[j][i] = make_pair(c[i][j], i);
    }
  }
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < (1 << k); j++) {
      if ((1 << i) & j) bs[i][j] = 1;
    }
  }
  for (int i = 0; i < n; i++) {
    sort(carac[i], carac[i] + k);
  }
  qte = k;
  for (int i = 0; i < q; i++) {
    int t, x, y;
    cin >> t >> x >> y;
    if (t == 1) {
      type[qte] = 1;
      x--, y--;
      bs[qte] = bs[x] | bs[y];
      qte++;
    } else if (t == 2) {
      x--, y--;
      type[qte] = 2;
      bs[qte] = bs[x] & bs[y];
      qte++;
    } else if (t == 3) {
      x--;
      y--;
      cout << pega(x, y) << "\n";
    }
  }
  return 0;
}
