#include <bits/stdc++.h>
using namespace std;
int n, k, q, t, x, y;
int V[12][1000015];
pair<int, int> T[100015];
bool B[100015];
int solve(int x1) {
  if (x1 < k) return V[x1][y];
  if (B[x1]) return max(solve(T[x1].first), solve(T[x1].second));
  return min(solve(T[x1].first), solve(T[x1].second));
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> k >> q;
  for (int i = 0; i < k; i++)
    for (int j = 0; j < n; j++) cin >> V[i][j];
  int ind = k;
  for (int i = 0; i < k; i++) {
    T[i].first = T[i].second = i;
    B[i] = false;
  }
  for (int z = 0; z < q; z++) {
    cin >> t >> x >> y;
    x--, y--;
    if (t == 1) {
      T[ind] = {x, y};
      B[ind] = true;
      ind++;
    } else if (t == 2) {
      T[ind] = {x, y};
      B[ind] = false;
      ind++;
    } else
      cout << solve(x) << "\n";
  }
  return 0;
}
