#include <bits/stdc++.h>
using namespace std;
int m, n, q, a[13][110005], id;
bitset<4100> s[110005];
inline int read() {
  int ret = 0, ff = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') ff = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    ret = (ret << 3) + (ret << 1) + (ch ^ 48);
    ch = getchar();
  }
  return ret * ff;
}
signed main() {
  m = read(), n = read(), q = read();
  id = n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) a[i][j] = read();
    for (int j = 0; j < (1 << n); j++)
      if (j & (1 << (i - 1))) s[i][j] = 1;
  }
  for (int que = 1; que <= q; que++) {
    int opt = read(), x = read(), y = read();
    if (opt == 1) {
      s[++id] = s[x] & s[y];
      continue;
    }
    if (opt == 2) {
      s[++id] = s[x] | s[y];
      continue;
    }
    if (opt == 3) {
      vector<pair<int, int> > v;
      for (int i = 1; i <= n; i++) v.push_back(make_pair(a[i][y], i));
      sort(v.begin(), v.end());
      int sum = 0;
      for (int i = 0; i < n; i++) {
        sum |= (1 << (v[i].second - 1));
        if (s[x][sum]) {
          printf("%d\n", v[i].first);
          break;
        }
      }
      continue;
    }
  }
  return 0;
}
