#include <bits/stdc++.h>
using namespace std;
struct o {
  int i;
  int x;
};
int n, m, q;
o a[13][100001];
bitset<4096> c[100001];
int main() {
  cin >> n >> m >> q;
  for (int i = 0; i < m; ++i)
    for (int k = 1; k <= n; ++k) {
      cin >> a[i][k].x;
    }
  for (int k = 0; k < m; ++k) {
    for (int i = 0; i < (1 << 12); ++i) {
      if ((1 << k) & i) c[k + 1][i] = 1;
    }
  }
  int all = m;
  vector<pair<int, int> > v;
  for (int k = 0; k < q; ++k) {
    int t, x, y;
    cin >> t >> x >> y;
    if (t == 1) c[++all] = c[x] & c[y];
    if (t == 2) c[++all] = c[x] | c[y];
    if (t == 3) {
      v.clear();
      for (int i = 0; i < m; ++i) v.push_back(make_pair(a[i][y].x, i));
      sort(v.begin(), v.end());
      int used = 0;
      for (int i = 0; i < m; ++i) {
        used |= 1 << v[i].second;
        if (c[x][used]) {
          cout << v[i].first << endl;
          break;
        }
      }
    }
  }
}
