#include <iostream>

using namespace std;

int main()
{
    int q,n;
    cin>> n;
    int bn[n],u[n-1],v[n-1];
    for (int i=0;i<n;i++){
        cin>> bn[i];
    }
    for (int i=1;i<n;i++){
        cin>> u[i]>> v[i];
    }
    cin >>q;
    int a[q],b[q],l[q],x[q],r[q],tip;

    for (int i=0;i<q;i++){
        cin>> tip;
        if (tip==1){
            cin>> a[i]>>b[i];
        }
        else {
            cin>> l[i]>>r[i]>>x[i];
        }
    }
    for (int i=0;i<n;i++){
            for (int j=1;j<=n;j++){
                if (bn[i]>bn[j]){
                    swap(bn[i],bn[j]);
                    swap (u[i],u[j]);
                    swap (v[i],v[j]);
                }
            }
    }
    cout << 2 << endl<< 2 <<endl<<3;


    return 0;
}