#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T,class U>
inline bool chmax(T &a,U b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}
template<class T,class U>
inline bool chmin(T &a,U b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}
constexpr int INF=1000000000;
constexpr ll llINF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
/*
vector<vector<ll>>C,sC;
void init_comb(int n,int m){
    C.resize(n+1,vector<ll>(m+1,0));
    sC.resize(n+1,vector<ll>(m+1,0));
    C[0][0]=1;
    for(int i=1;i<=n;i++){
        C[i][0]=1;
        for(int j=1;j<=m;j++){
            C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
        }
    }
    rep(i,n+1){
        rep(j,m){
            sC[i][j+1]=(sC[i][j]+C[i][j])%mod;
        }
    }
}*/
ll gcd(ll a,ll b){
    while(a%b){
        a%=b;
        swap(a,b);
    }
    return b;
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
vector<int>primes;
void init_prime(int n){
    primes.push_back(2);
    for(int i=3;i<=n;i+=2){
        bool f=true;
        for(int j:primes){
            if(j*j>i)break;
            if(i%j==0){
                f=false;
                break;
            }
        }
        if(f)primes.push_back(i);
    }
}
ll modpow(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1){
            res*=a;
            res%=mod;
        }
        a*=a;
        a%=mod;
        b>>=1;
    }
    return res;
}
vector<ll>inv,fact,factinv;
void init_fact(int n){
    inv.resize(n+1);
    fact.resize(n+1);
    factinv.resize(n+1);
    inv[0]=0;
    inv[1]=1;
    fact[0]=1;
    factinv[0]=1;
    for(ll i=1;i<=n;i++){
        if(i>=2)inv[i]=mod-((mod/i)*inv[mod%i]%mod);
        fact[i]=(fact[i-1]*i)%mod;
        factinv[i]=factinv[i-1]*inv[i]%mod;
    }
}
ll _inv(ll a,ll m=mod){
    //gcd(a,m) must be 1
    ll b=m,u=1,v=0;
    while(b){
        ll t=a/b;
        a-=t*b;swap(a,b);
        u-=t*v;swap(u,v);
    }
    u%=m;
    if(u<0)u+=m;
    return u;
}
ll comb(int a,int b){
    if(a<b)return 0;
    if(a<0)return 0;
    return fact[a]*factinv[a-b]%mod*factinv[b]%mod;
}
ll multicomb(int a,int b){
    return comb(a+b-1,b);
}
int n,c[100010],cnt[100010];
vector<int>g[100010];
vector<int>ans;
void dfs(int x,int p=-1){
    cnt[c[x]]++;
    if(cnt[c[x]]==1)ans.pb(x);
    for(int i:g[x]){
        if(i!=p){
            dfs(i,x);
        }
    }
    cnt[c[x]]--;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n;
    rep(i,n)cin>>c[i];
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        a--,b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    dfs(0);
    sort(all(ans));
    for(int i:ans)cout<<i+1<<endl;
    return 0;
}
#include "bits/stdc++.h"
using namespace std;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusive
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long;
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

long long LLINF = 1e18;
int INF = 1e9+1e6;
#define MAXN (200006)
ll n, m, mod=998244353, dp[20][MAXN], f[MAXN], inv[MAXN];
ll qexp(ll x,ll e){
	ll sum=1;
	for(;e;e>>=1,x*=x,x%=mod) if(e&1) sum*=x, sum%=mod;
	return sum;
}
ll C(ll n,ll k) { return n < k ? 0ll : f[n] * inv[k] % mod * inv[n-k] % mod; }
vector<int> d[MAXN];
int main() {
	f[0]=1; FOR(i,1,MAXN-1) f[i]=f[i-1]*i%mod;
	inv[MAXN-1] = qexp(f[MAXN-1], mod-2); DEC(i,MAXN-2,0) inv[i]=inv[i+1]*(i+1)%mod;
	FAST
	cin>>n>>m;
	FOR(j,1,m) {
		for(ll k=2;k*k<=j;++k) if(j%k==0) {
			d[j].eb(k);
			if(j/k!=k) d[j].eb(j/k);
		}
	}
	FOR(i,1,m) dp[1][i] = 1;
	FOR(i,2,min(n, 19ll)) {
		FOR(j,1,m) {
			for(auto k:d[j]) {
				dp[i][j] += dp[i-1][k];
				if(dp[i][j] >= mod) dp[i][j] -= mod;
			}
			if(j != 1 && i == 2) {
				dp[i][j] += dp[i-1][1];
				if(dp[i][j] >= mod) dp[i][j] -= mod;
			}
		}
	}
	ll ans = 0;
	FOR(i,1,min(n,19ll)) FOR(j,1,m) {
		ans += dp[i][j] * C(n-1, i-1) % mod;
		if(ans >= mod) ans -= mod;
	}
	cout<<ans<<'\n';
}
