#include <bits/stdc++.h>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <vector>
#define loop(i,a,b) for (int i = (a); i <= (b); i++)
#define loopr(i, a, b) for(int i = (a); i >= (b); i--)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define mp(a,b) make_pair(a,b)
#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long int
#define inf 1e18
#define mod 1000000007
#define mod1 998244353
using namespace std;


int main()
{
	fast_io;
	ll s,p;
	cin>>s>>p;
	int f = 0;
	for(ll i = 1;i*i<=p;i++)
	{
		if(p%i==0)
		{
			if(i+p/i==s)
			{
				f = 1;
			}
		}
	}
	if(f)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
}
#include <bits/stdc++.h>
#define LOCAL
 
using namespace std;
 
using ll = long long;
const int mod = 1e9 + 7;
 
#define mem(a, b) memset(a, b, sizeof(a))
#define REP(i, a) for (int i = 0; i < a; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(a) a.begin(), a.end()
 
inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout << fixed << setprecision(10);
}
 
inline void print_vector(vector<int> &A){
    for (auto&& x : A){
        cout << x << " ";
    }
    cout << endl;
}
 
inline void print_vector(vector<ll> &A){
    for (auto&& x : A){
        cout << x << " ";
    }
    cout << endl;
}
 
inline void print_array(const int A[], int n) {
    REP(i, n) {
        if (i < n - 1) {
            cout << A[i] << " ";
        } else {
            cout << A[i] << endl;
        }
    }
}
 
ll gcd(ll x, ll y) {
    return (y == 0 ? x : gcd(y, x % y));
}
ll lcm(ll x, ll y) {
    return x * y / gcd(x, y);
}
 
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
 
int color[100000 + 10];
int node_color[100000 + 10];
vector<int> res;
set<int> v;
 
void dfs(int node, unordered_map<int, vector<int>>& nei) {
    // cout << node << " " << parent << endl;
    v.insert(node);
    if (color[node_color[node]] == 0) {res.push_back(node);}
    color[node_color[node]]++;
    for (auto x : nei[node]) {
        if (v.find(x) == v.end()) {
            // cout << x << " " << node << endl;
            dfs(x, nei);
        }
    }
    color[node_color[node]]--;
}
 
int solve() {
    memset(color, 0, sizeof(color));
    memset(node_color, 0, sizeof(color));
 
    int n;
    cin >> n;
 
    int c;
    REP(i, n) {
        cin >> c;
        node_color[i+1] = c;
    }
 
    unordered_map<int, vector<int>> nei;
 
    int a, b;
    REP(i, n - 1) {
        cin >> a >> b;
        nei[a].push_back(b);
        nei[b].push_back(a);
    }
 
    dfs(1, nei);
    sort(ALL(res));
 
    for (auto x : res) {
        cout << x << endl;
    }
 
    return 0;
}
 
int main() {
    quickread();
    int t = 1;
    // cin >> t;
 
    for (int _ = 0; _ < t; _++) {
        int res = solve();
        // cout << "Case #" << _ + 1 << ": " << res << endl;
    }
 
    return 0;
}