#include <bits/stdc++.h>
using namespace std;
int n, m, q, cnt, ans, w[13][100010], bi[20], g[13][100010], tot;
bitset<4096> f[2 * 100010];
int main() {
  int i, s, a, b, j, k;
  for (i = bi[0] = 1; i < 20; i++) bi[i] = bi[i - 1] << 1;
  scanf("%d%d%d", &n, &m, &q);
  tot = m;
  for (i = 1; i <= m; i++) {
    for (s = 1; s <= n; s++) scanf("%d", &w[i][s]);
    for (s = 0; s < bi[m]; s++)
      if (s & bi[i - 1]) f[i][s] = 1;
  }
  for (i = 1; i <= m; i++)
    for (s = 1; s <= n; s++)
      for (k = 1; k <= m; k++)
        if (w[k][s] >= w[i][s]) g[i][s] |= bi[k - 1];
  while (q--) {
    scanf("%d%d%d", &k, &a, &b);
    if (k == 1) f[++tot] = f[a] | f[b];
    if (k == 2) f[++tot] = f[a] & f[b];
    if (k == 3) {
      ans = 0;
      for (i = 1; i <= m; i++)
        if (f[a][g[i][b]]) ans = max(ans, w[i][b]);
      printf("%d\n", ans);
    }
  }
  return 0;
}
