#include <bits/stdc++.h>

using namespace std;

void addEdge(vector<int> adj[], int u, int v){
    adj[u].push_back(v);
    adj[v].push_back(u);
}

void zameni(int& a, int& b){
    int tmp = a;
    a = b;
    b= tmp;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int redosled[n];
    for(int i=0;i<n;++i){
        cin >> redosled[i];
    }
    vector<int> adj[n];
    int x, y;
    for(int i=0;i<n-1;++i){
        cin >> x >> y;
        addEdge(adj, x-1, y-1);
    }

    int q;
    cin >> q;
    int m;
    int ispis[q];
    int br=0;
    for(int i=0;i<q;++i){
        cin >> m;
        if(m==1){
            int a,b;
            cin >> a >> b;
            zameni(redosled[a-1],redosled[b-1]);
        }
        else{
            int l,r,x;
            cin >> l >> r >> x;
            int length = n/2;
            ispis[br]=length;
            br++;
        }
    }

    for(int i=0;i<br;++i){
        cout << ispis[i] << endl;
    }
    return 0;
}