#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int n,q,c[maxn],f[maxn];
map <int,int> mp[maxn];

inline int F(int x)
{
	if(f[x]==x) return x;
	return f[x]=F(f[x]);
}

inline void mer(int u,int v)
{
	int tx=F(u),ty=F(v);
	if(tx!=ty)
	{
		int x=mp[tx].size(),y=mp[ty].size();
		if(x<y)
		{
			for(map <int,int>::iterator it=mp[tx].begin();it!=mp[tx].end();it++)
			{
				pair <int,int> p=*it;
				mp[ty][p.first]+=p.second;
			}
			f[tx]=ty;
		}
		else
		{
			for(map <int,int>::iterator it=mp[ty].begin();it!=mp[ty].end();it++)
			{
				pair <int,int> p=*it;
				mp[tx][p.first]+=p.second;
			}
			f[ty]=tx;
		}
	}
}

int main()
{
	n=read(); q=read(); rep(i,1,n) c[i]=read(),f[i]=i;
	rep(i,1,n) mp[i][c[i]]++;
	while(q--)
	{
		int opt=read(),u=read(),v=read();
		if(opt==1) mer(u,v);
		else
		{
			printf("%d\n",mp[F(u)][v]);
		}
	}
	return 0;
}
#include <bits/stdc++.h> 
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
  
 ll H,W;
ll A,B;
vector<vector<bool>> note;

ll dfs(ll h,ll w,ll count) {
    if(h==H-1&w==W-1) {

        if(count==A) {
            return 1;
        }
        else return 0;
    }

ll s=0;

if(!note[h][w]) {
if(h<H-1&&w<W-1) {
    if(!note[h+1][w]) {
        note[h][w]=true;
        note[h+1][w]=true;
        s+=dfs(h+1,w,count+1);
        note[h][w]=false;
        note[h+1][w]=false;
    }
    if(!note[h][w+1]) {
        note[h][w]=true;
        note[h][w+1]=true;
        s+=dfs(h+1,w,count+1);
     note[h][w]=false;
     note[h][w+1]=false;
    }

    s+=dfs(h+1,w,count);
}
else if(h==H-1) {
    if(!note[h][w+1]) {
        note[h][w]=true;
        note[h][w+1]=true;
        s+=dfs(0,w+1,count+1);
        note[h][w]=false;
        note[h][w+1]=false;
        s+=dfs(0,w+1,count);
    }
    else {
        s+=dfs(0,w+1,count);
    }
}
else {
    if(!note[h+1][w]) {
        note[h][w]=true;
        note[h+1][w]=true;
        s+=dfs(h+1,w,count+1);
    note[h][w]=false;
    note[h+1][w]=false;
    s+=dfs(h+1,w,count);
    }
else {
    s+=dfs(h+1,w,count);
}
}

}

else {
    if(h<H-1) {
        s+=dfs(h+1,w,count);
    }
    else {
        s+=dfs(0,w+1,count);
    }
}

return s;
}
    




 
    
    

  int main() {
    
     cin>>H>>W;
     
     cin>>A>>B;

     note=vector<vector<bool>>(H,vector<bool> (W,false));
     

     cout<<dfs(0,0,0)<<endl;
  }

     