#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, k, q;
  cin >> n >> k >> q;
  int a[k][n], p = k;
  for (int i = 0; i < k; i++)
    for (int j = 0; j < n; j++) cin >> a[i][j];
  pair<int, int> mp[n][k];
  bitset<1 << 12> c[k + q];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < k; j++) mp[i][j] = make_pair(a[j][i], j);
    sort(mp[i], mp[i] + k);
  }
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < (1 << 12); j++)
      if (j & (1 << i)) c[i][j] = true;
  }
  for (int i = 0; i < q; i++) {
    int t, x, y;
    cin >> t >> x >> y;
    x--;
    y--;
    if (t == 1)
      c[p++] = c[x] & c[y];
    else if (t == 2)
      c[p++] = c[x] | c[y];
    else {
      int idx = 0;
      for (int j = 0; j < k; j++) {
        idx |= (1 << mp[y][j].second);
        if (c[x][idx]) {
          cout << mp[y][j].first << endl;
          break;
        }
      }
    }
  }
  return 0;
}
