#include <stdio.h>
#include <stdlib.h>
#include <math.h>


int main()
{
    int n;
    scanf("%d", &n);
    
    int redosledNaselja[n];
    char array[n];
    scanf("%s", &array);
    
    char pom = strtok(array, " ");
    redosledNaselja[0] = (int)pom;
    int k = 1;
    
    while(pom != NULL)
    {
        redosledNaselja[k] = (int)strtok(NULL, " ");
        k++;
    }
        
    int spisak[n];
    for(int i=0;i<n;i++)
    {
        int ind = redosledNaselja[i];
        spisak[ind] = i+1;
    }
    
    int stablo[n][n];
    
    for(int i=0;i<n-1;i++)
    {
        int u, v;
        scanf("%d %d", &u, &v);
        stablo[u][v] = 1;
        stablo[v][u] = 1;
    }
    
    int Q;
    scanf("%d", &Q);
    for(int i=0;i<Q;i++)
    {
        char dogadjaj[10];
        scanf("%s", &dogadjaj);
        char p = strtok(dogadjaj, " ");
        int a, b;
        int l, r, x;

        if((int)p == 1)
        {
            //prvi tip
            a = (int)strtok(NULL, " ");
            b = (int)strtok(NULL, " ");
            int ppom = spisak[a];
            spisak[a] = spisak[b];
            spisak[b] = pom;
        }
        else if((int)p == 2)
        {
            //drugi tip
            l = (int)strtok(NULL, " ");
            r = (int)strtok(NULL, " ");
            x = (int)strtok(NULL, " ");
        }
    }
    
    return 0;
}