9 5 14
7 1 4 8 5 2 6 9 3
2 8
1 6
5 7
1 3
3 9
1 5
1 8
1 5
1 4
1 8
1 3
1 5
1 5
1 7
1 7
2 3
1 2
1 1
1 2
 6 5 8
1 2 6 3 4 5
2 4
1 3
1 6
3 5
2 5
1 1
1 4
1 1
2 1
2 5
2 2
2 3
1 4
 2 1 3
1 2
1 2
1 1
1 1
1 1

6
9
5
8
1
7
0
0
0
0
0
4
0
 6
5
4
3
 2
1
0

#include <bits/stdc++.h>
using namespace std;
int a[200001] = {0};
int p[300001] = {0};
int main() {
  int n, m, q;
  cin >> n >> m >> q;
  int i, temp, v, u, max;
  for (i = 1; i <= n; i++) {
    cin >> p[i];
  }
  for (i = 1; i <= m; i++) {
    cin >> temp;
    cin >> a[temp];
  }
  while (q > 0) {
    cin >> temp;
    if (temp == 1) {
      cin >> v;
      i = v;
      max = v;
      i = a[i];
      while (v != i && i != a[i]) {
        if (p[i] > p[max]) {
          max = i;
        }
        i = a[i];
      }
      cout << p[max] << endl;
      p[max] = 0;
    } else {
      cin >> u;
      a[u] = u;
    }
    q--;
  }
  return 0;
}
