#include <bits/stdc++.h>
const int C = 340;
int a[C + 15][100010], to[100040];
int pa[100040], pb[100040], o[100040], cnt[100040];
int n, k, l;
int get(int i, int j) {
  if (to[i] != -1) {
    return a[to[i]][j];
  }
  int v = get(pa[i], j);
  int w = get(pb[i], j);
  return (v < w) == o[i] ? v : w;
}
int main() {
  int q;
  scanf("%d%d%d", &n, &k, &q);
  l = k;
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < n; j++) {
      scanf("%d", &a[i][j]);
    }
    to[i] = i;
  }
  while (q--) {
    int t, x, y;
    scanf("%d%d%d", &t, &x, &y);
    --x;
    --y;
    --t;
    if (t <= 1) {
      pa[k] = x;
      pb[k] = y;
      o[k] = t;
      cnt[k] = cnt[x] > cnt[y] ? cnt[x] : cnt[y];
      cnt[k]++;
      if (cnt[k] % C == 0) {
        to[k] = l;
        for (int i = 0; i < n; i++) {
          a[l][i] = get(k, i);
        }
        l++;
      } else {
        to[k] = -1;
      }
      k++;
    } else {
      printf("%d\n", get(x, y));
    }
  }
  return 0;
}
