#include <bits/stdc++.h>
using namespace std;
const int sz = 1 << 12;
int n, k, q, i, j, tp, x, y, cnt, mask;
int ini[14][100111];
bitset<sz> data[100111];
vector<int> aux;
int main() {
  cin >> n >> k >> q;
  for (i = 1; i <= k; i++)
    for (j = 1; j <= n; j++) cin >> ini[i][j];
  for (i = 1; i <= k; i++)
    for (j = 0; j < sz; j++) data[i][j] = (j >> (i - 1)) & 1;
  cnt = k;
  for (int qq = 1; qq <= q; qq++) {
    cin >> tp >> x >> y;
    if (tp == 1) data[++cnt] = (data[x] | data[y]);
    if (tp == 2) data[++cnt] = (data[x] & data[y]);
    if (tp == 3) {
      aux.clear();
      for (i = 1; i <= k; i++) aux.push_back(i);
      sort(aux.begin(), aux.end(),
           [&](int a, int b) -> bool const { return ini[a][y] < ini[b][y]; });
      mask = sz - 1;
      for (i = 0; i < k; i++) {
        mask ^= (1 << (aux[i] - 1));
        if (data[x][mask] == 0) {
          cout << ini[aux[i]][y] << '\n';
          break;
        }
      }
    }
  }
  return 0;
}
