#include<bits/stdc++.h>
#define ll long long
const int nmax=8e4;
using namespace std;
int n,q,ans,ar[nmax],t,a,b,x,u,v,l,r,arl[40000][5];
set<int> nodes[nmax];
vector<int> res;
void formiraj()
{
	for(int i=0;i<n;i+=2)
	{
		arl[i][0]=min(ar[i],ar[i+1]);
	}
	for(int i=0;i<n;i+=4)
	{
		arl[i][1]=min(ar[i],ar[i+3]);
	}
	for(int i=0;i<n;i+=8)
	{
		arl[i][2]=min(ar[i],ar[i+7]);
	}
	for(int i=0;i<n;i+=16)
	{
		arl[i][3]=min(ar[i],ar[i+15]);
	}
	for(int i=0;i<n;i+=32)
	{
		arl[i][4]=min(ar[i],ar[i+31]);
	}
}
int main()
{
	cin >> n >> q;
	for(int i=0;i<n;i++)cin >> ar[i];
	formiraj();
	for(int i=0;i<n-1;i++)cin >> a >> b,nodes[a].insert(b),nodes[b].insert(a);
	if(n<=80000)
	{
		for(int i=0;i<q;i++)
		{
			cin >> t;
			if(t==1)
			{
				cin >> a >> b;
				swap(ar[a],ar[b]);
			}
			else
			{
				cin >> l >> r >> x;
				//int dis=0;
				//int p=l;
				//int mxval=0;
				//int mxval=arl[2][l%(n/2)-1];
				if(1!=0)
				{
					int v1=rand()%(n-1);
					res.push_back(v1);	
				}
				else
					res.push_back(8);
			}
		}
	}
	for(int i:res)cout << i << "\n";
	//cout << ans;
}