#include <bits/stdc++.h>
using namespace std;
char buffer[100000], *p1, *p2;
template <class T>
void read(T& x) {
  char ch = ((p1 == p2 &&
              (p2 = (p1 = buffer) + fread(buffer, 1, 100000, stdin), p1 == p2))
                 ? EOF
                 : *p1++);
  x = 0;
  bool f = 1;
  while (!('0' <= ch && ch <= '9') && ch != '-')
    ch = ((p1 == p2 &&
           (p2 = (p1 = buffer) + fread(buffer, 1, 100000, stdin), p1 == p2))
              ? EOF
              : *p1++);
  if (ch == '-')
    ch = ((p1 == p2 &&
           (p2 = (p1 = buffer) + fread(buffer, 1, 100000, stdin), p1 == p2))
              ? EOF
              : *p1++),
    f = 0;
  while ('0' <= ch && ch <= '9')
    x = (x << 1) + (x << 3) + ch - '0',
    ch = ((p1 == p2 &&
           (p2 = (p1 = buffer) + fread(buffer, 1, 100000, stdin), p1 == p2))
              ? EOF
              : *p1++);
  x = (f) ? x : -x;
}
int n, k, q;
int a[13][100019];
vector<pair<int, int> > s;
bitset<4096> f[100019];
int main() {
  read(n), read(k), read(q);
  for (register int i = 1; i <= k; i++)
    for (register int j = 1; j <= n; j++) read(a[i][j]);
  int t, x, y;
  for (register int i = 1; i <= k; i++)
    for (register int j = 0; j <= 4095; j++)
      if (j & (1 << i - 1))
        f[i][j] = 1;
      else
        f[i][j] = 0;
  int _k = k;
  for (register int T = 1; T <= q; T++) {
    read(t), read(x), read(y);
    if (t == 1)
      f[++_k] = f[x] | f[y];
    else if (t == 2)
      f[++_k] = f[x] & f[y];
    else {
      s.clear();
      for (register int i = 1; i <= k; i++)
        s.push_back(pair<int, int>(a[i][y], i));
      sort(s.begin(), s.end());
      int now = 0;
      for (register int i = k - 1; i >= 0; i--) {
        now |= (1 << s[i].second - 1);
        if (f[x][now]) {
          printf("%d\n", s[i].first);
          break;
        }
      }
    }
  }
  return 0;
}
