#include <bits/stdc++.h>
using namespace std;
const int MAXN = 110000;
const int MAXK = 15;
const int MAXS = 1 << 12;
int a[MAXN][MAXK];
int c[MAXN][MAXK];
bitset<MAXS> b[MAXN];
int main() {
  int n, k, q;
  scanf("%d%d%d", &n, &k, &q);
  for (int j = 1; j <= k; j++)
    for (int i = 1; i <= n; i++) scanf("%d", &a[i][j]);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= k; j++)
      for (int p = 1; p <= k; p++)
        if (a[i][p] >= a[i][j]) c[i][j] |= 1 << p - 1;
  for (int i = 1; i <= k; i++)
    for (int j = 0; j < MAXS; j++) b[i][j] = j >> i - 1 & 1;
  for (int i = 1, m = k; i <= q; i++) {
    int t, x, y;
    scanf("%d%d%d", &t, &x, &y);
    switch (t) {
      case 1:
        b[++m] = b[x] | b[y];
        break;
      case 2:
        b[++m] = b[x] & b[y];
        break;
      case 3:
        int ans = 0;
        for (int j = 1; j <= k; j++)
          if (b[x][c[y][j]]) ans = max(ans, a[y][j]);
        printf("%d\n", ans);
        break;
    }
  }
  return 0;
}
