#include <bits/stdc++.h>
#define f(a, n) for (int a = 0; a < n; a++)
#define F(a, n) for (int a = 1; a <= n; a++)
using namespace std;

struct Student{
	map<int, int> mp;
	int sz = 1;
	Student* par = this;
}; 

Student* find(Student* a){
	if (a->par == a) return a;
	return a->par = find(a->par);
}

void join(Student* a, Student* b){ // b joins a
	a->sz += b->sz;
	b->par = a;
	for (auto p: b->mp){
		int x = p.first, y = p.second;
		a->mp[x] += y;
	}
}

int main(){
	int n, q;
	cin >> n >> q;
	Student A[200005];
	F(i, n) {
		int x;
		cin>>x;
		A[i].mp[x]++;
	}
	F(asdf, q){
		int a, b, c;
		cin >> a >> b >> c;
		if (a == 1){
			auto d = find(&A[b]);
			auto e = find(&A[c]);
			if (d != e){
				if (d->sz >= e->sz){
					join(d, e);
				} else{
					join(e, d);
				}
			}
		} else{
			cout<<find(&A[b])->mp[c]<<endl;
		}
	}
}
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
 
#include <bits/stdc++.h>                                                               
//#include <ext/pb_ds/assoc_container.hpp> // Общий файл. 
//#include <ext/pb_ds/tree_policy.hpp> // Содержит класс tree_order_statistics_node_updat 
//#include <ext/pb_ds/detail/standard_policies.hpp>
//#define int long long
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define repb(i, r, l) for (int i = r; i >= l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back  
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}
 
using namespace std;

mt19937 mrand(random_device{}()); 
const int mod = 998244353;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod;if(a==1)return 1; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
typedef pair < int , int > pii ;                                            
typedef pair < long long  , long long > pll ;
const int N = 5000;                               

using namespace std;
int n, m;
int u[N],v[N];
int c[N];
char ans[N];
int id[200][200];
vector <int> gr[N];
bool was[N];
void dfs(int u, int col){	
	was[u] = 1;
	for(int to : gr[u]){
		if(c[to] != col)continue;
		if(ans[id[u][to]] != 0)continue;
		int i = id[u][to];
		if(v[i] == u)
			ans[i] = '<';
		else ans[i] = '>';
		if(!was[to])
			dfs(to,col);		
	}
}
main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);                                 
	cin >> n >> m;
	rep(i,1,m){
		cin >> u[i] >> v[i];
		id[u[i]][v[i]] = id[v[i]][u[i]] = i;
		gr[u[i]].pb(v[i]);
		gr[v[i]].pb(u[i]);
	}
	rep(i,1,n)
		cin >> c[i];
			
	for(int i = 1; i <= n; i++){
		if(!was[i])
			dfs(i,c[i]);
	}
	for(int i = 1; i <= m;i++){	
		if(c[u[i]] > c[v[i]])
			ans[i] = '>';
		else if(c[u[i]] < c[v[i]])
			ans[i] = '<';		
	}
	for(int i = 1; i <= m; i++){
		if(ans[i] == '<')	
			cout << "<-\n";
		else cout << "->\n";	
	}
}
