#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void in(T &x) {
  x = 0;
  char c = getchar();
  bool f = 0;
  while (!isdigit(c)) f |= (c == '-'), c = getchar();
  while (isdigit(c)) x = x * 10 + (c ^ '0'), c = getchar();
  f ? x = -x : 0;
}
template <class T>
inline void out(T x, const char c = '\n') {
  static short st[30];
  short m = 0;
  if (x < 0) {
    if (x == -2147483648) {
      printf("-2147483648");
      return;
    }
    putchar('-'), x = -x;
  }
  do st[++m] = x % 10, x /= 10;
  while (x);
  while (m) putchar(st[m--] | '0');
  putchar(c);
}
template <class T, class... Args>
inline void in(T &x, Args &...args) {
  in(x);
  in(args...);
}
template <class T, class... Args>
inline void out(const T &x, const Args &...args) {
  out(x, ' ');
  out(args...);
}
template <class T>
inline void prt(T a[], int n) {
  for (register int i = 0; i < n; ++i) out(a[i], ' ');
  putchar('\n');
}
template <class T>
inline void clr(T a[], int n) {
  memset(a, 0, sizeof(T) * n);
}
template <class T>
inline void clr(T *a, T *b) {
  memset(a, 0, sizeof(T) * (b - a));
}
template <class T>
inline bool ckmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
template <class T>
inline bool ckmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
namespace MOD_CALC {
const int md = 998244353, inv2 = (md + 1) / 2;
inline int add(const int a, const int b) {
  return a + b >= md ? a + b - md : a + b;
}
inline int sub(const int a, const int b) {
  return a - b < 0 ? a - b + md : a - b;
}
inline int mul(const int a, const int b) { return (long long)a * b % md; }
inline void inc(int &a, const int b) { (a += b) >= md ? a -= md : 0; }
inline void dec(int &a, const int b) { (a -= b) < 0 ? a += md : 0; }
inline int qpow(int a, int b) {
  int r = 1;
  for (; b; b >>= 1, a = mul(a, a))
    if (b & 1) r = mul(r, a);
  return r;
}
inline int mdinv(const int a) { return qpow(a, md - 2); }
template <class... Args>
inline int add(const int a, const int b, const Args &...args) {
  return add(add(a, b), args...);
}
template <class... Args>
inline int mul(const int a, const int b, const Args &...args) {
  return mul(mul(a, b), args...);
}
}  // namespace MOD_CALC
using namespace MOD_CALC;
namespace i207M {
int n, m, U, cnt;
int a[13][100005], zt[13][100005];
bitset<4100> f[100050];
signed main() {
  int cq, op, x, y;
  in(n, m, cq);
  U = 1 << m;
  for (register int i = 1; i <= m; ++i)
    for (register int j = 1; j <= n; ++j) in(a[i][j]);
  cnt = m;
  for (register int i = 1; i <= m; ++i)
    for (register int j = 0; j < U; ++j)
      if ((j >> (i - 1)) & 1) f[i][j] = 1;
  for (register int i = 1; i <= m; ++i)
    for (register int j = 1; j <= n; ++j) {
      int &s = zt[i][j];
      for (register int k = 1; k <= m; ++k)
        if (a[i][j] <= a[k][j]) s |= 1 << (k - 1);
    }
  while (cq--) {
    in(op, x, y);
    if (op == 1)
      f[++cnt] = f[x] | f[y];
    else if (op == 2)
      f[++cnt] = f[x] & f[y];
    else {
      int ans = 0;
      for (register int i = 1; i <= m; ++i)
        if (f[x][zt[i][y]]) ckmax(ans, a[i][y]);
      out(ans);
    }
  }
  return 0;
}
}  // namespace i207M
signed main() {
  i207M::main();
  return 0;
}
