#include <cassert>
#include <cstdio>
#include <ctime>
#include <cstdlib>
#include <climits>
#include <cstddef>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <numeric>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <bitset>
#include <list>
#include <string>
#include <functional>
#include <utility>
using namespace std;
typedef long long llint;

class UF
{
public:
    UF(int n): n(n), st(n + 1), sz(n + 1, 1)
    {
    }
    int find_(int u);
    void union_(int u, int v);
private:
    int n;
    vector <int> st;
    vector <int> sz;
};

int UF::find_(int u)
{
    int r = u;
    while (st[r] != 0)
    {
        r = st[r];
    }
    int x = u, y;
    while (st[x] != 0)
    {
        y = st[x];
        st[x] = r;
        x = y;
    }
    return r;
}

void UF::union_(int u, int v)
{
    int ru = find_(u), rv = find_(v);
    if (ru == rv)
    {
        return;
    }
    if (sz[ru] >= sz[rv])
    {
        st[rv] = ru;
        sz[ru] += sz[rv];
    }
    else
    {
        st[ru] = rv;
        sz[rv] += sz[ru];
    }
}

bool can_be_root(int v, int nl, UF &uf, vector <vector <int> > const &adj)
{
    int cnt = 0;
    for (vector <int>::const_iterator jt = adj[v].begin(); jt != adj[v].end(); ++jt)
    {
        if (uf.find_(*jt) != uf.find_(v))
        {
            ++cnt;
        }
    }
    return (cnt == nl);
}

int main()
{
    std::ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector <vector <int> > adj(n + 1);
    for (int i = 0, x, y; i < n - 1; ++i)
    {
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    vector <int> c(n + 1);
    for (int i = 1; i <= n; ++i)
    {
        cin >> c[i];
    }

    UF uf(n);
    for (int i = 1; i <= n; ++i)
    {
        for (vector <int>::const_iterator it = adj[i].begin(); it != adj[i].end(); ++it)
        {
            if (c[i] == c[*it])
            {
                uf.union_(i, *it);
            }
        }
    }

    vector <int> deg(n + 1);
    for (int i = 1; i <= n; ++i)
    {
        for (vector <int>::const_iterator it = adj[i].begin(); it != adj[i].end(); ++it)
        {
            if (uf.find_(i) == uf.find_(*it))
            {
                continue;
            }
            ++deg[uf.find_(i)];
        }
    }

    int r = count_if(deg.begin(), deg.end(), bind2nd(greater <int>(), 1));
    if (r > 1)
    {
        cout << "NO" << endl;
    }
    else if (r == 0)
    {
        cout << "YES" << endl;
        cout << 1 << endl;
    }
    else
    {
        int nl = count_if(deg.begin(), deg.end(), bind2nd(equal_to <int>(), 1));
        int u = find_if(deg.begin(), deg.end(), bind2nd(greater <int>(), 1)) - deg.begin();
        int ans = -1;
        if (can_be_root(u, nl, uf, adj))
        {
            ans = u;
        }
        for (vector <int>::const_iterator it = adj[u].begin(); ans == -1 && it != adj[u].end(); ++it)
        {
            int v = *it;
            if (uf.find_(v) != u)
            {
                continue;
            }
            if (can_be_root(v, nl, uf, adj))
            {
                ans = v;
            }
        }
        if (ans == -1)
        {
            cout << "NO" << endl;
        }
        else
        {
            cout << "YES" << endl << ans << endl;
        }
    }

    return 0;
}


#include <cassert>
#include <cstdio>
#include <ctime>
#include <cstdlib>
#include <climits>
#include <cstddef>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <numeric>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <bitset>
#include <list>
#include <string>
#include <functional>
#include <utility>
using namespace std;
typedef long long llint;

class UF
{
public:
    UF(int n): n(n), st(n + 1), sz(n + 1, 1)
    {
    }
    int find_(int u);
    void union_(int u, int v);
private:
    int n;
    vector <int> st;
    vector <int> sz;
};

int UF::find_(int u)
{
    int r = u;
    while (st[r] != 0)
    {
        r = st[r];
    }
    int x = u, y;
    while (st[x] != 0)
    {
        y = st[x];
        st[x] = r;
        x = y;
    }
    return r;
}

void UF::union_(int u, int v)
{
    int ru = find_(u), rv = find_(v);
    if (ru == rv)
    {
        return;
    }
    if (sz[ru] >= sz[rv])
    {
        st[rv] = ru;
        sz[ru] += sz[rv];
    }
    else
    {
        st[ru] = rv;
        sz[rv] += sz[ru];
    }
}

bool can_be_root(int v, int nl, UF &uf, vector <vector <int> > const &adj)
{
    int cnt = 0;
    for (vector <int>::const_iterator jt = adj[v].begin(); jt != adj[v].end(); ++jt)
    {
        if (uf.find_(*jt) != uf.find_(v))
        {
            ++cnt;
        }
    }
    return (cnt == nl);
}

int main()
{
    std::ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector <vector <int> > adj(n + 1);
    for (int i = 0, x, y; i < n - 1; ++i)
    {
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    vector <int> c(n + 1);
    for (int i = 1; i <= n; ++i)
    {
        cin >> c[i];
    }

    UF uf(n);
    for (int i = 1; i <= n; ++i)
    {
        for (vector <int>::const_iterator it = adj[i].begin(); it != adj[i].end(); ++it)
        {
            if (c[i] == c[*it])
            {
                uf.union_(i, *it);
            }
        }
    }

    vector <int> deg(n + 1);
    for (int i = 1; i <= n; ++i)
    {
        for (vector <int>::const_iterator it = adj[i].begin(); it != adj[i].end(); ++it)
        {
            if (uf.find_(i) == uf.find_(*it))
            {
                continue;
            }
            ++deg[uf.find_(i)];
        }
    }

    int r = count_if(deg.begin(), deg.end(), bind2nd(greater <int>(), 1));
    if (r > 1)
    {
        cout << "NO" << endl;
    }
    else
    {
        int nl = count_if(deg.begin(), deg.end(), bind2nd(equal_to <int>(), 1));
        int u = find_if(deg.begin(), deg.end(), bind2nd(greater <int>(), 1)) - deg.begin();
        if (u > n)
        {
            u = 1;
            nl -= 1;
        }
        int ans = -1;
        queue <int> q;
        vector <bool> vis(n + 1);
        q.push(u);
        while (!q.empty())
        {
            int v = q.front();
            q.pop();
            vis[v] = true;
            if (can_be_root(v, nl, uf, adj))
            {
                ans = v;
                break;
            }
            for (vector <int>::const_iterator it = adj[v].begin(); it != adj[v].end(); ++it)
            {
                if (!vis[*it] && c[*it] == c[u])
                {
                    q.push(*it);
                }
            }
        }
        if (ans == -1)
        {
            cout << "NO" << endl;
        }
        else
        {
            cout << "YES" << endl << ans << endl;
        }
    }

    return 0;
}


#include <cassert>
#include <cstdio>
#include <ctime>
#include <cstdlib>
#include <climits>
#include <cstddef>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <numeric>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <bitset>
#include <list>
#include <string>
#include <functional>
#include <utility>
using namespace std;
typedef long long llint;

class UF
{
public:
    UF(int n): n(n), st(n + 1), sz(n + 1, 1)
    {
    }
    int find_(int u);
    void union_(int u, int v);
private:
    int n;
    vector <int> st;
    vector <int> sz;
};

int UF::find_(int u)
{
    int r = u;
    while (st[r] != 0)
    {
        r = st[r];
    }
    int x = u, y;
    while (st[x] != 0)
    {
        y = st[x];
        st[x] = r;
        x = y;
    }
    return r;
}

void UF::union_(int u, int v)
{
    int ru = find_(u), rv = find_(v);
    if (ru == rv)
    {
        return;
    }
    if (sz[ru] >= sz[rv])
    {
        st[rv] = ru;
        sz[ru] += sz[rv];
    }
    else
    {
        st[ru] = rv;
        sz[rv] += sz[ru];
    }
}

bool can_be_root(int v, int nl, UF &uf, vector <vector <int> > const &adj)
{
    int cnt = 0;
    for (vector <int>::const_iterator jt = adj[v].begin(); jt != adj[v].end(); ++jt)
    {
        if (uf.find_(*jt) != uf.find_(v))
        {
            ++cnt;
        }
    }
    return (cnt == nl);
}

int main()
{
    std::ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector <vector <int> > adj(n + 1);
    for (int i = 0, x, y; i < n - 1; ++i)
    {
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    vector <int> c(n + 1);
    for (int i = 1; i <= n; ++i)
    {
        cin >> c[i];
    }

    UF uf(n);
    for (int i = 1; i <= n; ++i)
    {
        for (vector <int>::const_iterator it = adj[i].begin(); it != adj[i].end(); ++it)
        {
            if (c[i] == c[*it])
            {
                uf.union_(i, *it);
            }
        }
    }

    vector <int> deg(n + 1);
    for (int i = 1; i <= n; ++i)
    {
        for (vector <int>::const_iterator it = adj[i].begin(); it != adj[i].end(); ++it)
        {
            if (uf.find_(i) == uf.find_(*it))
            {
                continue;
            }
            ++deg[uf.find_(i)];
        }
    }

    int r = count_if(deg.begin(), deg.end(), bind2nd(greater <int>(), 1));
    if (r > 1)
    {
        cout << "NO" << endl;
    }
    else
    {
        int nl = count_if(deg.begin(), deg.end(), bind2nd(equal_to <int>(), 1));
        int u = find_if(deg.begin(), deg.end(), bind2nd(greater <int>(), 1)) - deg.begin();
        if (u > n)
        {
            u = 1;
            nl = max(nl - 1, 0);
        }
        int ans = -1;
        queue <int> q;
        vector <bool> vis(n + 1);
        q.push(u);
        while (!q.empty())
        {
            int v = q.front();
            q.pop();
            vis[v] = true;
            if (can_be_root(v, nl, uf, adj))
            {
                ans = v;
                break;
            }
            for (vector <int>::const_iterator it = adj[v].begin(); it != adj[v].end(); ++it)
            {
                if (!vis[*it] && c[*it] == c[u])
                {
                    q.push(*it);
                }
            }
        }
        if (ans == -1)
        {
            cout << "NO" << endl;
        }
        else
        {
            cout << "YES" << endl << ans << endl;
        }
    }

    return 0;
}


#include <cstdio>
#include <cstring>
using namespace std;

const int N = 1e5 + 5;

static int n;

int cnt[N], u[N], v[N], c[N];

/*
4
1 2
2 3
3 4
1 2 1 2
*/

int main()
{
    while( scanf("%d", &n) != EOF )
    {
        memset(cnt, 0, sizeof(cnt));
        for(int i = 0; i < n - 1; i++)
            scanf("%d%d", &u[i], &v[i]);

        for(int i = 1; i <= n; i++)
            scanf("%d", &c[i]);

        int diff = 0;
        for(int i = 0; i < n - 1; i++)
        if(c[u[i]] != c[v[i]])
        {
            diff++;
            cnt[u[i]]++;
            cnt[v[i]]++;
        }

        if(diff == 0)
        {
            printf("YES\n1\n");
            continue;
        }

        int cntv = 0, maxid = 1;
        for(int i = 1; i <= n; i++)
        if(cnt[i] != 0)
        {
            if(cnt[i] > 1)  cntv++;
            if(cnt[maxid] < cnt[i]) maxid = i;
        }

        if(cntv <= 1)
        {
            printf("YES\n%d\n", maxid);
        }
        else
        {
            printf("NO\n");
        }
    }

    return 0;
}


#include <cstdio>
#include <cstring>
using namespace std;

const int N = 1e5 + 5;

static int n;

int cnt[N], u[N], v[N], c[N];

/*
4
1 2
2 3
3 4
1 2 1 2
*/

int main()
{
    while( scanf("%d", &n) != EOF )
    {
        memset(cnt, 0, sizeof(cnt));
        for(int i = 0; i < n - 1; i++)
            scanf("%d%d", &u[i], &v[i]);

        for(int i = 1; i <= n; i++)
            scanf("%d", &c[i]);

        int diff = 0;
        for(int i = 0; i < n - 1; i++)
        if(c[u[i]] != c[v[i]])
        {
            diff++;
            cnt[u[i]]++;
            cnt[v[i]]++;
        }

        if(diff == 0)
        {
            printf("YES\n1\n");
            continue;
        }

        int cntv = 0, cntu = 0, maxid = 1;
        for(int i = 1; i <= n; i++)
        if(cnt[i] != 0)
        {
            cntu++;
            if(cnt[i] > 1)  cntv++;
            if(cnt[maxid] < cnt[i]) maxid = i;
        }

        if(cntv <= 1 && cntu == diff + 1)
        {
            printf("YES\n%d\n", maxid);
        }
        else
        {
            printf("NO\n");
        }
    }

    return 0;
}


#include<iostream>
#include<vector>
using namespace std;
vector<vector<int> >v;
int boja[100001];
bool mozi;
void dfs(int x,int prev,int momentalna)
{
    if(mozi&&boja[x]==momentalna)
		mozi=true;
	else
		mozi=false;
    for(int i=0;i<v[x].size();i++)
	{
        if(v[x][i]!=prev)
            dfs(v[x][i],x,momentalna);
    }
}
int main()
{
	int n;
    cin>>n;
	vector<int> vec;
	v.insert(v.begin(),n+1,vec);
    for(int i=0;i<n-1;i++)
	{
        int a,b;
        cin>>a>>b;
		a--;
		b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    for(int i=0;i<n;i++)
		cin>>boja[i];
    int koren1=-1,koren2=-1;
    for(int i=0;i<n;i++)
	{
        for(int j=0;j<v[i].size();j++)
		{
            if(boja[v[i][j]]!=boja[i])
			{
                koren1=v[i][j];
                koren2=i;
            }
        }
    }
    if(koren1==-1)
	{
        cout<<"YES"<<endl;
		cout<<1<<endl;
        return 0;
    }
	bool cc=true;
    for(int i=0;i<v[koren1].size();i++)
	{

        mozi=true;
        dfs(v[koren1][i],koren1,boja[v[koren1][i]]);
        if(!mozi)
			cc=false;
    }
	if(cc)
	{
		cout<<"YES"<<endl;
		cout<<koren1+1<<endl;
		return 0;
	}
	cc=true;
	for(int i=0;i<v[koren2].size();i++)
	{

        mozi=true;
        dfs(v[koren2][i],koren2,boja[v[koren2][i]]);
        if(!mozi)
			cc=false;
    }
	if(cc)
	{
		cout<<"YES"<<endl;
		cout<<koren2+1<<endl;
		return 0;
	}
    cout<<"NO"<<endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <set>
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<vector<int> > v;
	vector<int> vec;
	v.insert(v.begin(),n+1,vec);
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	set<int> s;
	vector<int> vv(100001,0);
	for(int i=0;i<n;i++)
	{
		int a;
		cin>>a;
		s.insert(a);
		vec.push_back(a);
		vv[a]++;
	}
	for(int i=0;i<n;i++)
	{
		set<int> ss;
		int brojac=0;
		for(int j=0;j<v[i].size();j++)
		{
			ss.insert(vec[v[i][j]]);

		}
		if(vv[vec[i]]>1)
		{
		    if(ss.size()==s.size())
		    {
		        cout<<"YES"<<endl;
			cout<<i+1<<endl;
			return 0;
		    }
		}
	else
		{
		   if(ss.size()==s.size()-1)
		    {
		        cout<<"YES"<<endl;
			cout<<i+1<<endl;
			return 0;
		    }
		}
	}
	cout<<"NO"<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6+1;

int head[N],cnt,n,m,a[N],ans[N],st[N],ed[N],totw,top[N],X[N],Y[N];
int use[N];
vector<int>q[N];
struct nd{int ne,to;}e[N*2];
void in(int x,int y){e[++cnt].to=y;e[cnt].ne=head[x];head[x]=cnt;}

void dfs(int x,int f)
{
	top[x]=1;
	for(int i=head[x];i;i=e[i].ne)
	if(e[i].to!=f)
	if(a[e[i].to]==a[x])dfs(e[i].to,x);
}
void judge(int x,int f,int col)
{
	if(a[x]!=col){cout<<"NO";exit(0);}
	for(int i=head[x];i;i=e[i].ne)
	if(e[i].to!=f)
	judge(e[i].to,x,col);
}

int get_ans(int x)
{
	for(int i=head[x];i;i=e[i].ne)
	judge(e[i].to,x,a[e[i].to]);
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;++i)
	scanf("%d%d",&X[i],&Y[i]),in(X[i],Y[i]),in(Y[i],X[i]);
	for(int i=1;i<=n;++i)scanf("%d",a+i);
	dfs(1,-1);
	static pair<int,int>q[N];
	int tmp=0;
	for(int i=1;i<=n;++i)
	{
		if(top[X[i]]==1&&top[Y[i]]==0)q[++tmp]=make_pair(Y[i],X[i]);
		if(top[Y[i]]==1&&top[X[i]]==0)q[++tmp]=make_pair(X[i],Y[i]);
	}
	if(!tmp){cout<<"YES"<<endl<<1;return 0;}
	if(tmp==1)
	{
		get_ans(q[1].first);
		cout<<"YES"<<endl<<q[1].first;
	}
	else
	{
		for(int i=1;i<tmp;++i)
		if(q[i].second!=q[i+1].second){cout<<"NO";exit(0);}
		get_ans(q[1].second);
		cout<<"YES"<<endl<<q[1].second;
	}
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6+1;

int head[N],cnt,n,m,a[N],ans[N],st[N],ed[N],totw,top[N],X[N],Y[N];
int use[N];
vector<int>q[N];
struct nd{int ne,to;}e[N*2];
void in(int x,int y){e[++cnt].to=y;e[cnt].ne=head[x];head[x]=cnt;}

void dfs(int x,int f)
{
	top[x]=1;
	for(int i=head[x];i;i=e[i].ne)
	if(e[i].to!=f)
	if(a[e[i].to]==a[x])dfs(e[i].to,x);
}
void judge(int x,int f,int col)
{
	if(a[x]!=col){cout<<"NO";exit(0);}
	for(int i=head[x];i;i=e[i].ne)
	if(e[i].to!=f)
	judge(e[i].to,x,col);
}

int get_ans(int x)
{
	for(int i=head[x];i;i=e[i].ne)
	judge(e[i].to,x,a[e[i].to]);
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;++i)
	scanf("%d%d",&X[i],&Y[i]),in(X[i],Y[i]),in(Y[i],X[i]);
	for(int i=1;i<=n;++i)scanf("%d",a+i);
	dfs(1,-1);
	static int q[N];q[0]=0;
	for(int i=1;i<=n;++i)
	{
		if(top[X[i]]==1&&top[Y[i]]==0)q[++q[0]]=Y[i];
		if(top[Y[i]]==1&&top[X[i]]==0)q[++q[0]]=X[i];
	}
	if(q[0]!=1)
	{
		if(!q[0]){cout<<"YES"<<endl<<1;return 0;}
		if(q[0]){cout<<"NO";return 0;}
	}
	get_ans(q[1]);
	cout<<"YES"<<endl<<q[1];
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6+1;

int head[N],cnt,n,m,a[N],ans[N],st[N],ed[N],totw,top[N],X[N],Y[N];
int use[N];
vector<int>q[N];
struct nd{int ne,to;}e[N*2];
void in(int x,int y){e[++cnt].to=y;e[cnt].ne=head[x];head[x]=cnt;}

void dfs(int x,int f)
{
	top[x]=1;
	for(int i=head[x];i;i=e[i].ne)
	if(e[i].to!=f)
	if(a[e[i].to]==a[x])dfs(e[i].to,f);
}
void judge(int x,int f,int col)
{
	if(a[x]!=col){cout<<"NO";exit(0);}
	for(int i=head[x];i;i=e[i].ne)
	if(e[i].to!=f)
	judge(e[i].to,x,col);
}

int get_ans(int x)
{
	for(int i=head[x];i;i=e[i].ne)
	{
		judge(e[i].to,x,a[e[i].to]);
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;++i)
	scanf("%d%d",&X[i],&Y[i]),in(X[i],Y[i]),in(Y[i],X[i]);
	for(int i=1;i<=n;++i)scanf("%d",a+i);
	dfs(1,-1);
	static int q[N];q[0]=0;
	for(int i=1;i<=n;++i)
	{
		if(top[X[i]]==1&&top[Y[i]]==0)q[++q[0]]=Y[i];
		if(top[Y[i]]==1&&top[X[i]]==0)q[++q[0]]=X[i];
	}
	if(q[0]!=1)
	{
		if(!q[0]){cout<<"YES"<<endl<<1;return 0;}
		if(q[0]){cout<<"NO";return 0;}
	}
	get_ans(q[1]);
	cout<<"YES"<<endl<<q[1];
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
long long vis[100009],col[100009],n,c,flag,d;
vvi graph;
vector<ii> Pair;
#define mp make_pair
#define pb push_back
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define inf LONG_LONG_MAX
#define MOD 1000000007

void dfs(int u)
{
	vis[u]=1;

	if(col[u]!=c){
		 flag=1;return;
	}
	for(int j=0;j<graph[u].size();j++)
	{
		if(!vis[graph[u][j]] && graph[u][j]!=d)
		dfs(graph[u][j]);
	}
}

int main()
{
	ll  m=0,i,j,k,a,b,x,t,y,z;
	//freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

	cin>>n;
	graph.resize(100009);
	for(i=1;i<n;i++){
		cin>>a>>b;	graph[a].pb(b);	graph[b].pb(a);
		Pair.pb(mp(a,b));
	}
	for(i=1;i<=n;i++) cin>>col[i];

	for(i=0;i<Pair.size();i++)
	{
		a=Pair[i].first; b=Pair[i].second;
		if(col[a]!=col[b])
		{
			for(j=0;j<graph[a].size();j++)
			{
				memset(vis,0,sizeof vis);	c=col[graph[a][j]];	flag=0; d=a;
				dfs(graph[a][j]);
				if(flag==1) break;
			}
			if(j==graph[a].size())
			{
				cout<<"YES\n"<<a;return 0;
			}
			for(j=0;j<graph[b].size();j++)
			{
				memset(vis,0,sizeof vis);	c=col[graph[b][j]];	flag=0; d=b;
				dfs(graph[b][j]);
				if(flag==1) break;
			}
			if(j==graph[b].size())
			{
				cout<<"YES\n"<<b;return 0;
			}
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES\n"<<i;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
long long vis[100009],col[100009],n,c,flag,d;
vvi graph;

#define mp make_pair
#define pb push_back
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define inf LONG_LONG_MAX
#define MOD 1000000007

void dfs(int u)
{
	vis[u]=1;

	if(col[u]!=c){
		 flag=1;return;
	}
	for(int j=0;j<graph[u].size();j++)
	{
		if(!vis[graph[u][j]] && graph[u][j]!=d)
		dfs(graph[u][j]);
	}
}

int main()
{
	ll  m=0,i,j,k,a,b,x,t,y,z;
	//freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
	cin>>n;
	graph.resize(100000);
	for(i=1;i<n;i++){
		cin>>a>>b;graph[a].pb(b);graph[b].pb(a);
	}

	for(i=1;i<=n;i++) cin>>col[i];

	for(i=1;i<=n;i++)
	{	d=i;
		for(j=0;j<graph[i].size();j++)
		{
			memset(vis,0,sizeof vis);	c=col[graph[i][j]];	flag=0;
			dfs(graph[i][j]);
			if(flag==1) break;
		}
		if(j==graph[i].size())
		{
			cout<<"YES\n"<<i;return 0;
		}
	}
	cout<<"NO";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
long long vis[100009],col[100009],n,c,flag,d;
vvi graph;
vector<ii> Pair;
#define mp make_pair
#define pb push_back
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define inf LONG_LONG_MAX
#define MOD 1000000007

void dfs(int u)
{
	vis[u]=1;

	if(col[u]!=c){
		 flag=1;return;
	}
	for(int j=0;j<graph[u].size();j++)
	{
		if(!vis[graph[u][j]] && graph[u][j]!=d)
		dfs(graph[u][j]);
	}
}

int main()
{
	ll  m=0,i,j,k,a,b,x,t,y,z;
	//freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

	cin>>n;
	graph.resize(1000);
	for(i=1;i<n;i++){
		cin>>a>>b;	graph[a].pb(b);	graph[b].pb(a);
		Pair.pb(mp(a,b));
	}
	for(i=1;i<=n;i++) cin>>col[i];

	for(i=0;i<Pair.size();i++)
	{
		a=Pair[i].first; b=Pair[i].second;
		if(col[a]!=col[b])
		{
			for(j=0;j<graph[a].size();j++)
			{
				memset(vis,0,sizeof vis);	c=col[graph[a][j]];	flag=0; d=a;
				dfs(graph[a][j]);
				if(flag==1) break;
			}
			if(j==graph[a].size())
			{
				cout<<"YES\n"<<a;return 0;
			}
			for(j=0;j<graph[b].size();j++)
			{
				memset(vis,0,sizeof vis);	c=col[graph[b][j]];	flag=0; d=b;
				dfs(graph[b][j]);
				if(flag==1) break;
			}
			if(j==graph[b].size())
			{
				cout<<"YES\n"<<b;return 0;
			}
			cout<<"NO";
			return 0;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
long long vis[100009],col[100009],n,c,flag,d;
vvi graph;
vector<ii> Pair;
#define mp make_pair
#define pb push_back
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define inf LONG_LONG_MAX
#define MOD 1000000007

void dfs(int u)
{
	vis[u]=1;
	if(col[u]!=c){
		 flag=1;return;
	}
	for(int j=0;j<graph[u].size();j++)
	{
		if(!vis[graph[u][j]] && graph[u][j]!=d)
		dfs(graph[u][j]);
	}
}

int main()
{
	ll  m=0,i,j,k,a,b,x,t,y,z;
	//freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

	cin>>n;
	graph.resize(100009);
	for(i=1;i<n;i++){
		cin>>a>>b;	graph[a].pb(b);	graph[b].pb(a);
		Pair.pb(mp(a,b));
	}
	for(i=1;i<=n;i++) cin>>col[i];

	for(i=0;i<Pair.size();i++)
	{
		a=Pair[i].first; b=Pair[i].second;
		if(col[a]!=col[b])
		{
			memset(vis,0,sizeof vis);vis[a]=1;
			for(j=0;j<graph[a].size();j++)
			{
				c=col[graph[a][j]];	flag=0; d=a;
				dfs(graph[a][j]);
				if(flag==1) break;
			}
			if(j==graph[a].size())
			{
				cout<<"YES\n"<<a;return 0;
			}
			memset(vis,0,sizeof vis); vis[b]=1;
			for(j=0;j<graph[b].size();j++)
			{
				c=col[graph[b][j]];	flag=0; d=b;
				dfs(graph[b][j]);
				if(flag==1) break;
			}
			if(j==graph[b].size())
			{
				cout<<"YES\n"<<b;return 0;
			}
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES\n"<<i;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
long long vis[100009],col[100009],n,c,flag,d;
vvi graph;
vector<ii> Pair;
#define mp make_pair
#define pb push_back
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define inf LONG_LONG_MAX
#define MOD 1000000007

void dfs(int u)
{
	vis[u]=1;

	if(col[u]!=c){
		 flag=1;return;
	}
	for(int j=0;j<graph[u].size();j++)
	{
		if(!vis[graph[u][j]] && graph[u][j]!=d)
		dfs(graph[u][j]);
	}
}

int main()
{
	ll  m=0,i,j,k,a,b,x,t,y,z;
	//freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

	cin>>n;
	graph.resize(1000);
	for(i=1;i<n;i++){
		cin>>a>>b;	graph[a].pb(b);	graph[b].pb(a);
		Pair.pb(mp(a,b));
	}
	for(i=1;i<=n;i++) cin>>col[i];

	for(i=0;i<Pair.size();i++)
	{
		a=Pair[i].first; b=Pair[i].second;
		if(col[a]!=col[b])
		{
			for(j=0;j<graph[a].size();j++)
			{
				memset(vis,0,sizeof vis);	c=col[graph[a][j]];	flag=0; d=a;
				dfs(graph[a][j]);
				if(flag==1) break;
			}
			if(j==graph[a].size())
			{
				cout<<"YES\n"<<a;return 0;
			}
			for(j=0;j<graph[b].size();j++)
			{
				memset(vis,0,sizeof vis);	c=col[graph[b][j]];	flag=0; d=b;
				dfs(graph[b][j]);
				if(flag==1) break;
			}
			if(j==graph[b].size())
			{
				cout<<"YES\n"<<b;return 0;
			}
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES\n"<<i;
	return 0;
}


// In the name of allah

#include<bits/stdc++.h>
using namespace std;
#define For(i,a,n) for(int i=a;i<n+1;i++)
#define rep(i,n) For(i,0,n-1)
#define repp(i,a,n) For(i,a,n)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef unsigned long long ull;
#define RI(x) scanf("%d",&x)
#define RII(x,y) scanf("%d%d",&x,&y)
#define RIII(x,y,z) scanf("%d%d%d",&x,&y,&z);
#define DRI(x) int x;RI(x)
#define DRII(x,y) int x,y;RII(x,y)
#define DRIII(x,y,z) int x,y,z;RIII(x,y,z);
#define PI(x) printf("%d\n",x)
#define PIS(x) printf("%d ",x)
#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define min3(a,b,c) min(a, min(b,c))
#define max3(a,b,c) max(a, max(b,c))
#define sz(a) ((int)a.size())
#define clr(x,a) memset(x, a, sizeof x)
#define debug(x) cout << #x << " = " << x << '\n'
#define INF LLONG_MAX
#define vi vector<int>
const int N = 1e5+10;
int u[N],v[N],c[N],d[N],a;
int main(){
	DRI(n);
	rep(i,n) RII(u[i],v[i]);
	rep(i,n) RI(c[i]);
	rep(i,n) if(c[u[i]]!=c[v[i]]) a++,d[u[i]]++,d[v[i]]++;
	rep(i,n) if(d[i]==a) return pf("YES\n%d\n",i+1),0;
	pf("NO\n");
	return 0;
}


// In the name of allah

#include<bits/stdc++.h>
using namespace std;
#define For(i,a,n) for(int i=a;i<n+1;i++)
#define rep(i,n) For(i,0,n-1)
#define repp(i,a,n) For(i,a,n)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef unsigned long long ull;
#define RI(x) scanf("%d",&x)
#define RII(x,y) scanf("%d%d",&x,&y)
#define RIII(x,y,z) scanf("%d%d%d",&x,&y,&z);
#define DRI(x) int x;RI(x)
#define DRII(x,y) int x,y;RII(x,y)
#define DRIII(x,y,z) int x,y,z;RIII(x,y,z);
#define PI(x) printf("%d\n",x)
#define PIS(x) printf("%d ",x)
#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define min3(a,b,c) min(a, min(b,c))
#define max3(a,b,c) max(a, max(b,c))
#define sz(a) ((int)a.size())
#define clr(x,a) memset(x, a, sizeof x)
#define debug(x) cout << #x << " = " << x << '\n'
#define INF LLONG_MAX
#define vi vector<int>
const int N = 1e5+10;
int u[N],v[N],c[N],d[N],a;
int main(){
	DRI(n);
	rep(i,n-1) RII(u[i+1],v[i+1]);
	rep(i,n) RI(c[i+1]);
	rep(i,n) if(c[u[i+1]]!=c[v[i+1]]) a++,d[u[i+1]]++,d[v[i+1]]++;
	rep(i,n) if(d[i+1]==a) return pf("YES\n%d\n",i+1),0;
	pf("NO\n");
	return 0;
}


// In the name of allah

#include<bits/stdc++.h>
using namespace std;
#define For(i,a,n) for(int i=a;i<n+1;i++)
#define rep(i,n) For(i,0,n-1)
#define repp(i,a,n) For(i,a,n)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef unsigned long long ull;
#define RI(x) scanf("%d",&x)
#define RII(x,y) scanf("%d%d",&x,&y)
#define RIII(x,y,z) scanf("%d%d%d",&x,&y,&z);
#define DRI(x) int x;RI(x)
#define DRII(x,y) int x,y;RII(x,y)
#define DRIII(x,y,z) int x,y,z;RIII(x,y,z);
#define PI(x) printf("%d\n",x)
#define PIS(x) printf("%d ",x)
#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define min3(a,b,c) min(a, min(b,c))
#define max3(a,b,c) max(a, max(b,c))
#define sz(a) ((int)a.size())
#define clr(x,a) memset(x, a, sizeof x)
#define debug(x) cout << #x << " = " << x << '\n'
#define INF LLONG_MAX
#define vi vector<int>
const int N = 1e5+10;
int u[N],v[N],c[N],d[N],a;
int main(){
	DRI(n);
	rep(i,n) RII(u[i],v[i]);
	rep(i,n) RI(c[i]);
	rep(i,n) if(c[u[i]]!=c[v[i]]) a++,d[u[i]]++,d[v[i]]++;
	rep(i,n) if(d[i]!=a) return pf("YES\n%d\n",i+1),0;
	return 0;
}


// In the name of allah

#include<bits/stdc++.h>
using namespace std;
#define For(i,a,n) for(int i=a;i<n+1;i++)
#define rep(i,n) For(i,0,n-1)
#define repp(i,a,n) For(i,a,n)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef unsigned long long ull;
#define RI(x) scanf("%d",&x)
#define RII(x,y) scanf("%d%d",&x,&y)
#define RIII(x,y,z) scanf("%d%d%d",&x,&y,&z);
#define DRI(x) int x;RI(x)
#define DRII(x,y) int x,y;RII(x,y)
#define DRIII(x,y,z) int x,y,z;RIII(x,y,z);
#define PI(x) printf("%d\n",x)
#define PIS(x) printf("%d ",x)
#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define min3(a,b,c) min(a, min(b,c))
#define max3(a,b,c) max(a, max(b,c))
#define sz(a) ((int)a.size())
#define clr(x,a) memset(x, a, sizeof x)
#define debug(x) cout << #x << " = " << x << '\n'
#define INF LLONG_MAX
#define vi vector<int>
const int N = 1e5+10;
int u[N],v[N],c[N],d[N],a;
int main(){
	DRI(n);
	rep(i,n-1) RII(u[i],v[i]);
	rep(i,n) RI(c[i]);
	rep(i,n) if(c[u[i]]!=c[v[i]]) a++,d[u[i]]++,d[v[i]]++;
	rep(i,n) if(d[i]==a) return pf("YES\n%d\n",i+1),0;
	pf("NO\n");
	return 0;
}


#include<bits/stdc++.h>

#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define pb2 pop_back
#define pf2 pop_front
#define line printf("\n")
#define pq priority_queue
#define rep(k,i,j) for(int k = (int)i;k<(int)j;k++)
#define repd(k,i,j) for(int k = (int)i;k>=(int)j;k--)
#define ll long long

double EPS = 1e-9;
int INF = 1e9+7;;
long long INFLL = 1e17;
double pi = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

using namespace std;

const int maxn = 1e5+5;
int n;
pii edge[maxn];

vector<int> adj[maxn];
int c[maxn],par[maxn];

int root(int a){
	if(par[a]==a)return a;
	return par[a] = root(par[a]);
}

void join(int a,int b){
	a = root(a);b = root(b);
	if(a==b)return;
	par[a] =b ;
}

int flag[maxn];
int main(){
	scanf("%d",&n);

	rep(k,1,n){
		int a,b;
		scanf("%d%d",&a,&b);
		edge[k] = mp(a,b);
	}
	rep(k,1,n+1)scanf("%d",&c[k]),par[k] = k;

	rep(k,1,n){
		int a = edge[k].fi;
		int b = edge[k].se;

		if(c[a]==c[b])join(a,b);
	}

	rep(k,1,n){
		int a = edge[k].fi;
		int b = edge[k].se;

		a = root(a);
		b = root(b);
		if(a==b)continue;

		adj[a].pb(b);
		adj[b].pb(a);
	}

	queue<int> q;
	rep(k,1,n+1)if(adj[k].size()==1)q.push(k),flag[k] = 1;;

	int bisa = 1;
	rep(k,0,1){

		set<int> x;
		while(q.size()){
			int a = q.front();
			q.pop();

			int b= adj[a][0];
			if(flag[b]==0)x.insert(b);
		}

		if(x.size()==1){
			printf("YES\n");
			printf("%d\n",*x.begin());
			return 0;
		}
		if(x.size()==0){
			printf("YES\n");
			printf("1\n");
			return 0;
		}

	}

	printf("NO\n");

	return 0;
}


#include<bits/stdc++.h>

#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define pb2 pop_back
#define pf2 pop_front
#define line printf("\n")
#define pq priority_queue
#define rep(k,i,j) for(int k = (int)i;k<(int)j;k++)
#define repd(k,i,j) for(int k = (int)i;k>=(int)j;k--)
#define ll long long

double EPS = 1e-9;
int INF = 1e9+7;;
long long INFLL = 1e17;
double pi = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

using namespace std;

const int maxn = 1e5+5;
int n;
pii edge[maxn];

vector<int> adj[maxn];
int c[maxn],par[maxn];

int root(int a){
	if(par[a]==a)return a;
	return par[a] = root(par[a]);
}

void join(int a,int b){
	a = root(a);b = root(b);
	if(a==b)return;
	par[a] =b ;
}

int flag[maxn];

void dfs(int a,int cc){
	if(flag[a])return;

	flag[a] = 1;
	rep(k,0,adj[a].size()){
		int b = adj[a][k];

		if(c[b]==cc)dfs(b,cc);
	}
}
int main(){
	scanf("%d",&n);

	rep(k,1,n){
		int a,b;
		scanf("%d%d",&a,&b);
		edge[k] = mp(a,b);
		adj[a].pb(b);
		adj[b].pb(a);
	}
	rep(k,1,n+1)scanf("%d",&c[k]),par[k] = k;

	rep(k,1,n+1)if(adj[k].size()==1)dfs(k,c[k]);

	vector<int> x;
	rep(k,1,n+1){
		if(!flag[k])x.pb(k);
	}

	if(x.size()==1){
		printf("YES\n");
		printf("%d\n",x[0]);
		return 0;
	}
	if(x.size()==0){
		printf("YES\n");
		printf("1\n");
		return 0;
	}
	printf("NO\n");

	return 0;
}


#include<bits/stdc++.h>

#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define pb2 pop_back
#define pf2 pop_front
#define line printf("\n")
#define pq priority_queue
#define rep(k,i,j) for(int k = (int)i;k<(int)j;k++)
#define repd(k,i,j) for(int k = (int)i;k>=(int)j;k--)
#define ll long long

double EPS = 1e-9;
int INF = 1e9+7;;
long long INFLL = 1e17;
double pi = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

using namespace std;

const int maxn = 1e5+5;
int n;
pii edge[maxn];

vector<int> adj[maxn];
int c[maxn],par[maxn];

int flag[maxn];

void dfs(int a,int cc){
	if(flag[a])return;
	flag[a] = 1;
	rep(k,0,adj[a].size()){
		int b = adj[a][k];
		if(c[b]==cc)dfs(b,cc);
	}
}
int cek(int a){
	memset(flag,0,sizeof flag);
	flag[a] = 1;
	rep(k,0,adj[a].size()){
		int b = adj[a][k];

		dfs(b,c[b]);
	}

	rep(k,1,n+1)if(flag[k]==0)return 0;
	return 1;
}

void ans(int a){
	printf("YES\n");
	printf("%d\n",a);
	exit(0);
}
int main(){
	scanf("%d",&n);

	rep(k,1,n){
		int a,b;
		scanf("%d%d",&a,&b);
		edge[k] = mp(a,b);

		adj[a].pb(b);
		adj[b].pb(a);
	}
	rep(k,1,n+1)scanf("%d",&c[k]),par[k] = k;

	rep(k,1,n){
		int a = edge[k].fi;
		int b = edge[k].se;

		if(c[a]!=c[b]){
			if(cek(a))ans(a);
			if(cek(b))ans(b);
			printf("NO\n");
			return 0;
		}
	}

	ans(1);
	return 0;
}


#include<bits/stdc++.h>

#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define pb2 pop_back
#define pf2 pop_front
#define line printf("\n")
#define pq priority_queue
#define rep(k,i,j) for(int k = (int)i;k<(int)j;k++)
#define repd(k,i,j) for(int k = (int)i;k>=(int)j;k--)
#define ll long long

double EPS = 1e-9;
int INF = 1e9+7;;
long long INFLL = 1e17;
double pi = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

using namespace std;

const int maxn = 1e5+5;
int n;
pii edge[maxn];

vector<int> adj[maxn];
int c[maxn],par[maxn];

int flag[maxn];

void dfs(int a,int cc){
	if(flag[a])return;
	flag[a] = 1;
	rep(k,0,adj[a].size()){
		int b = adj[a][k];
		if(c[b]==cc)dfs(b,cc);
	}
}
int cek(int a){
	memset(flag,0,sizeof flag);
	flag[a] = 1;
	rep(k,0,adj[a].size()){
		int b = adj[a][k];

		dfs(b,c[b]);
	}

	rep(k,1,n+1)if(flag[k]==0)return 0;
	return 1;
}

void ans(int a){
	printf("YES\n");
	printf("%d\n",a);
	exit(0);
}
int main(){
	scanf("%d",&n);

	rep(k,1,n){
		int a,b;
		scanf("%d%d",&a,&b);
		edge[k] = mp(a,b);

		adj[a].pb(b);
		adj[b].pb(a);
	}
	rep(k,1,n+1)scanf("%d",&c[k]),par[k] = k;

	rep(k,1,n){
		int a = edge[k].fi;
		int b = edge[k].se;

		if(c[a]!=c[b]){
			if(cek(a)){
				ans(a);
			}
			if(cek(b))ans(b);
			printf("NO\n");
			return 0;
		}
	}

	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<bitset>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
using namespace std;
#define MAXN 100010
#define MAXM 1010
#define INF 1000000000
#define MOD 1000000007
#define eps 1e-8
#define ll long long
int n;
struct vec{
	int to;
	int fro;
};
vec mp[MAXN*2];
int tai[MAXN],cnt;
int c[MAXN],C[MAXN];
int ans[MAXN],ANS;
inline void be(int x,int y){
	mp[++cnt].to=y;
	mp[cnt].fro=tai[x];
	tai[x]=cnt;
}
inline void bde(int x,int y){
	be(x,y);
	be(y,x);
}
void dfs(int x,int f){
	int i,y;
	C[x]=c[x];
	for(i=tai[x];i;i=mp[i].fro){
		y=mp[i].to;
		if(y!=f){
			dfs(y,x);
			if(C[x]!=C[y]){
				C[x]=-1;
			}
		}
	}
}
void dp(int x,int f,int fc){
	int i,y;
	if(fc==-1){
		return ;
	}
	bool flag=1;
	for(i=tai[x];i;i=mp[i].fro){
		y=mp[i].to;
		if(y!=f){
			if(C[y]==-1){
				flag=0;
				break;
			}
		}
	}
	if(flag){
		ans[++ANS]=x;
	}
	if(c[x]!=fc){
		return ;
	}
	int t=0;
	for(i=tai[x];i;i=mp[i].fro){
		y=mp[i].to;
		if(y!=f){
			if(C[y]!=c[x]){
				t++;
			}
		}
	}
	if(t==0){
		for(i=tai[x];i;i=mp[i].fro){
			y=mp[i].to;
			dp(y,x,fc);
		}
	}else if(t==1){
		for(i=tai[x];i;i=mp[i].fro){
			y=mp[i].to;
			if(C[y]!=c[x]){
				dp(y,x,fc);
			}
		}
	}
}
int main(){
	int i,x,y;
	scanf("%d",&n);
	for(i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		bde(x,y);
	}
	for(i=1;i<=n;i++){
		scanf("%d",&c[i]);
	}
	dfs(1,0);
	dp(1,0,c[1]);
	if(!ANS){
		printf("NO\n");
	}else{
		printf("YES\n");
		printf("%d\n",ans[1]);
	}
	return 0;
}

/*
4
1 2
2 3
3 4
1 2 1 1

*/


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<bitset>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
using namespace std;
#define MAXN 100010
#define MAXM 1010
#define INF 1000000000
#define MOD 1000000007
#define eps 1e-8
#define ll long long
int n;
struct vec{
	int to;
	int fro;
};
vec mp[MAXN*2];
int tai[MAXN],cnt;
int c[MAXN],C[MAXN];
int ans[MAXN],ANS;
inline void be(int x,int y){
	mp[++cnt].to=y;
	mp[cnt].fro=tai[x];
	tai[x]=cnt;
}
inline void bde(int x,int y){
	be(x,y);
	be(y,x);
}
void dfs(int x,int f){
	int i,y;
	C[x]=c[x];
	for(i=tai[x];i;i=mp[i].fro){
		y=mp[i].to;
		if(y!=f){
			dfs(y,x);
			if(C[x]!=C[y]){
				C[x]=-1;
			}
		}
	}
}
void dp(int x,int f,int fc){
	int i,y;
	if(fc==-1){
		return ;
	}
	bool flag=1;
	for(i=tai[x];i;i=mp[i].fro){
		y=mp[i].to;
		if(y!=f){
			if(C[y]==-1){
				flag=0;
				break;
			}
		}
	}
	if(flag){
		ans[++ANS]=x;
		printf("YES\n%d\n",x);
		exit(0);
	}
	if(c[x]!=fc){
		return ;
	}
	int t=0;
	for(i=tai[x];i;i=mp[i].fro){
		y=mp[i].to;
		if(y!=f){
			if(C[y]!=c[x]){
				t++;
			}
		}
	}
	if(t==0){
		for(i=tai[x];i;i=mp[i].fro){
			y=mp[i].to;
			if(y!=f){
				dp(y,x,fc);
			}
		}
	}else if(t==1){
		for(i=tai[x];i;i=mp[i].fro){
			y=mp[i].to;
			if(y!=f){
				if(C[y]!=c[x]){
					dp(y,x,fc);
				}
			}
		}
	}
}
int main(){
	int i,x,y;
	scanf("%d",&n);
	for(i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		bde(x,y);
	}
	for(i=1;i<=n;i++){
		scanf("%d",&c[i]);
	}
	dfs(1,0);
	dp(1,0,c[1]);
	if(!ANS){
		printf("NO\n");
	}else{
		printf("YES\n");
		printf("%d\n",ans[1]);
	}
	return 0;
}

/*
4
1 2
2 3
3 4
1 2 1 1

*/


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<bitset>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
using namespace std;
#define MAXN 100010
#define MAXM 1010
#define INF 1000000000
#define MOD 1000000007
#define eps 1e-8
#define ll long long
int n;
struct vec{
	int to;
	int fro;
};
vec mp[MAXN*2];
int tai[MAXN],cnt;
int c[MAXN],C[MAXN];
int ans[MAXN],ANS;
inline void be(int x,int y){
	mp[++cnt].to=y;
	mp[cnt].fro=tai[x];
	tai[x]=cnt;
}
inline void bde(int x,int y){
	be(x,y);
	be(y,x);
}
void dfs(int x,int f){
	int i,y;
	C[x]=c[x];
	for(i=tai[x];i;i=mp[i].fro){
		y=mp[i].to;
		if(y!=f){
			dfs(y,x);
			if(C[x]!=C[y]){
				C[x]=-1;
			}
		}
	}
}
void dp(int x,int f,int fc){
	int i,y;
	if(fc==-1){
		return ;
	}
	bool flag=1;
	for(i=tai[x];i;i=mp[i].fro){
		y=mp[i].to;
		if(y!=f){
			if(C[y]==-1){
				flag=0;
				break;
			}
		}
	}
	if(flag){
		ans[++ANS]=x;
	}
	if(c[x]!=fc){
		return ;
	}
	int t=0;
	for(i=tai[x];i;i=mp[i].fro){
		y=mp[i].to;
		if(y!=f){
			if(C[y]!=c[x]){
				t++;
			}
		}
	}
	if(t==0){
		for(i=tai[x];i;i=mp[i].fro){
			y=mp[i].to;
			dp(y,x,fc);
		}
	}else if(t==1){
		for(i=tai[x];i;i=mp[i].fro){
			y=mp[i].to;
			if(C[y]!=c[x]){
				dp(y,x,fc);
			}
		}
	}
}
int main(){
	int i,x,y;
	scanf("%d",&n);
	for(i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		bde(x,y);
	}
	for(i=1;i<=n;i++){
		scanf("%d",&c[i]);
	}
	dfs(1,0);
	dp(1,0,c[1]);
	if(!ANS){
		printf("NO\n");
	}else{
		printf("YES\n");
		sort(ans+1,ans+ANS+1);
		for(i=1;i<=ANS;i++){
			printf("%d ",ans[i]);
		}
		printf("\n");
	}
	return 0;
}

/*
4
1 2
2 3
3 4
1 2 1 1

*/


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

const int N=600000;
int h[N],to[N],r[N],c[N],tot;
void add(int u,int v){
    to[tot]=v;
    r[tot]=h[u];
    h[u]=tot++;
}

vector<int>dfn,color,G[N];

void dfs(int x,int f){
    G[x].push_back(dfn.size()+1);
    dfn.push_back(x);
    color.push_back(c[x]);
    for(int i=h[x];i!=-1;i=r[i]){
        if(to[i]!=f){
            dfs(to[i],x);
            G[x].push_back(dfn.size()+1);
            dfn.push_back(x);
            color.push_back(c[x]);
        }
    }
}

int n;

bool isPure(int l,int r){
    if(l>r)return 1;
    int lc=0;
    for(int i=l-1;i<=r-1;i++)
        if(i!=l-1&&color[i]!=color[i-1])return 0;
    return 1;
}

int main(){
    memset(h,-1,sizeof(h));
    scanf("%d",&n);
    for(int i=1,u,v;i<n;i++){
        scanf("%d%d",&u,&v);
        add(u,v),add(v,u);
    }
    for(int i=1;i<=n;i++)scanf("%d",&c[i]);
    dfs(1,0);
    for(int i=1;i<=n;i++){
        for(int j=0;j<G[i].size()-1;j++)
            if(!isPure(G[i][j]+1,G[i][j+1]-1))goto nxt;
        if(isPure(1,G[i][0]-1)&&isPure(G[i][G[i].size()-1]+1,dfn.size())&&color[0]==color[color.size()-1])
            return 0&printf("YES\n%d\n",i);
        nxt:;
    }
    puts("NO");
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

const int N=600000;
int h[N],to[N],r[N],c[N],tot;
void add(int u,int v){
    to[tot]=v;
    r[tot]=h[u];
    h[u]=tot++;
}

vector<int>dfn,color,G[N];

void dfs(int x,int f){
    G[x].push_back(dfn.size()+1);
    dfn.push_back(x);
    color.push_back(c[x]);
    for(int i=h[x];i!=-1;i=r[i]){
        if(to[i]!=f){
            dfs(to[i],x);
            G[x].push_back(dfn.size()+1);
            dfn.push_back(x);
            color.push_back(c[x]);
        }
    }
}

int n;

int sz,top,bl;
int st[N],id[N];
vector<int>bot[N];
bool pure[N];
void build(){
    for(int i=0;i<color.size();i++)st[++top]=color[i];
    sz=bl=sqrt(top);
    for(int i=1;i<=top;i++){id[i]=bot[(i-1)/sz+1].size();bot[(i-1)/sz+1].push_back(st[i]);}
    sz=(top-1)/bl+1;
    for(int i=1;i<=sz;i++){
        pure[i]=true;
        for(int j=0;j<bot[i].size();j++)
            if(j!=0&&bot[i][j]!=bot[i][j-1]){pure[i]=false;break;}
    }
    // for(int i=1;i<=sz;i++){
    //     for(int j=0;j<bot[i].size();j++){
    //         cout<<bot[i][j]<<' ';
    //     }
    //     cout<<endl;
    // }
}

bool isPure(int l,int r){
    if(l>r)return true;
    int lef=(l-1)/bl+1;
    int rig=(r-1)/bl+1;
    if(lef==rig){
        for(int i=l;i<=r;i++)
            if(i!=l&&st[i]!=st[i-1])return false;
    }else{
        vector<int>cls;
        for(int i=id[l];i<bot[lef].size();i++)cls.push_back(bot[lef][i]);
        for(int i=lef+1;i<=rig-1;i++){cls.push_back(bot[i][0]);if(!pure[i])return false;}
        for(int i=0;i<=id[r];i++)cls.push_back(bot[rig][i]);
        for(int i=0;i<cls.size();i++)if(i!=0&&cls[i]!=cls[i-1])return false;
        // for(int i=0;i<cls.size();i++)cout<<cls[i]<<' ';
        // cout<<endl;
        // printf("IDL:%d IDR:%d lef:%d rig:%d L:%d R:%d\n",id[l],id[r],lef,rig,l,r);
    }
    return true;
}

int main(){
    memset(h,-1,sizeof(h));
    scanf("%d",&n);
    for(int i=1,u,v;i<n;i++){
        scanf("%d%d",&u,&v);
        add(u,v),add(v,u);
    }
    for(int i=1;i<=n;i++)scanf("%d",&c[i]);
    dfs(1,0);
    build();
    // for(int i=0;i<color.size();i++)cout<<color[i]<<' ';
    // cout<<endl;
    // cout<<isPure(3,5);
    // return 0;
    for(int i=1;i<=n;i++){
        for(int j=0;j<G[i].size()-1;j++)
            if(!isPure(G[i][j]+1,G[i][j+1]-1))goto nxt;
        if(isPure(1,G[i][0]-1)&&isPure(G[i][G[i].size()-1]+1,dfn.size())&&color[0]==color[color.size()-1])
            return 0&printf("YES\n%d\n",i);
        nxt:;
    }
    puts("NO");
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

const int N=600000;
int h[N],to[N],r[N],c[N],tot;
void add(int u,int v){
    to[tot]=v;
    r[tot]=h[u];
    h[u]=tot++;
}

vector<int>dfn,color,G[N];

void dfs(int x,int f){
    G[x].push_back(dfn.size()+1);
    dfn.push_back(x);
    color.push_back(c[x]);
    for(int i=h[x];i!=-1;i=r[i]){
        if(to[i]!=f){
            dfs(to[i],x);
            G[x].push_back(dfn.size()+1);
            dfn.push_back(x);
            color.push_back(c[x]);
        }
    }
}

int n;

namespace T{
    int l[N],r[N],color_if_isPure[N];
    bool isPure[N];
    void build(int x,int L,int R){
        l[x]=L;
        r[x]=R;
        if(L==R){
            color_if_isPure[x]=color[L-1];
            isPure[x]=1;
            // printf("L:%d R:%d C:%d\n",L,R,color[L-1]);
            return;
        }
        int mid=(L+R)>>1;
        build(x<<1,L,mid);
        build(x<<1|1,mid+1,R);
        if(isPure[x<<1]&&isPure[x<<1|1]&&color_if_isPure[x<<1]==color_if_isPure[x<<1|1]){
            isPure[x]=1;
            color_if_isPure[x]=color_if_isPure[x<<1];
        }
        // cout<<"L:"<<L<<' '<<"R:"<<R<<' '<<(isPure[x<<1])<<' '<<(isPure[x<<1|1])<<' '<<(color_if_isPure[x<<1])<<' '<<(color_if_isPure[x<<1|1])<<' '<<(isPure[x<<1]&&isPure[x<<1|1]&&color_if_isPure[x<<1]==color_if_isPure[x<<1|1])<<endl;
    }
    bool ask(int x,int L,int R){
        if(L<=l[x]&&r[x]<=R){
            // printf("L:%d R:%d F:%d\n",l[x],r[x],isPure[x]);
            return isPure[x];
        }
        int mid=(l[x]+r[x])>>1;
        bool f=false,f2=false,t=false,t2=false;
        if(L<=mid){
            t=true;
            f=ask(x<<1,L,R);
        }
        if(mid<R){
            t2=true;
            f2=ask(x<<1|1,L,R);
        }

        if(t&&t2){
            if(f&&f2&&color_if_isPure[x<<1]==color_if_isPure[x<<1|1])return true;
            else return false;
        }else if(t){
            return f;
        }else if(t2){
            return f2;
        }else{
            cout<<"ERROR"<<endl;
            return false;
        }
    }
    int cl(int pos){
        return color[pos-1];
    }
}

bool ask(int l,int r){
    if(l>r)return 1;
    return T::ask(1,l,r);
}

int main(){
    memset(h,-1,sizeof(h));
    scanf("%d",&n);
    for(int i=1,u,v;i<n;i++){
        scanf("%d%d",&u,&v);
        add(u,v),add(v,u);
    }
    for(int i=1;i<=n;i++)scanf("%d",&c[i]);
    dfs(1,0);

    T::build(1,1,dfn.size());

    // for(int i=0;i<dfn.size();i++)cout<<dfn[i]<<' ';
    // cout<<endl;

    // for(int i=0;i<color.size();i++)cout<<color[i]<<' ';
    // cout<<endl;

    for(int i=1;i<=n;i++){
        // cout<<endl;
        for(int j=0;j<G[i].size()-1;j++){
            // cout<<G[i][j]+1<<' '<<G[i][j+1]-1<<' '<<ask(G[i][j]+1,G[i][j+1]-1)<<endl;
            // cout<<ask(1,G[i][0]-1)<<' '<<ask(G[i][G[i].size()-1]+1,dfn.size())<<endl;
            if(!ask(G[i][j]+1,G[i][j+1]-1))
                goto nxt;
        }
        if(ask(1,G[i][0]-1)&&ask(G[i][G[i].size()-1]+1,dfn.size()))
            if(T::cl(1)==T::cl(dfn.size()))
                return 0&printf("YES\n%d\n",i);
        nxt:;
    }
    puts("NO");
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

const int N=600000;
int h[N],to[N],r[N],c[N],tot;
void add(int u,int v){
    to[tot]=v;
    r[tot]=h[u];
    h[u]=tot++;
}

vector<int>dfn,color,G[N];

void dfs(int x,int f){
    G[x].push_back(dfn.size()+1);
    dfn.push_back(x);
    color.push_back(c[x]);
    for(int i=h[x];i!=-1;i=r[i]){
        if(to[i]!=f){
            dfs(to[i],x);
            G[x].push_back(dfn.size()+1);
            dfn.push_back(x);
            color.push_back(c[x]);
        }
    }
}

int n;

namespace T{
    int l[N],r[N],color_if_isPure[N];
    bool isPure[N];
    void build(int x,int L,int R){
        l[x]=L;
        r[x]=R;
        if(L==R){
            color_if_isPure[x]=color[L-1];
            isPure[x]=1;
            // printf("L:%d R:%d C:%d\n",L,R,color[L-1]);
            return;
        }
        int mid=(L+R)>>1;
        build(x<<1,L,mid);
        build(x<<1|1,mid+1,R);
        if(isPure[x<<1]&&isPure[x<<1|1]&&color_if_isPure[x<<1]==color_if_isPure[x<<1|1]){
            isPure[x]=1;
            color_if_isPure[x]=color_if_isPure[x<<1];
        }
        // cout<<"L:"<<L<<' '<<"R:"<<R<<' '<<(isPure[x<<1])<<' '<<(isPure[x<<1|1])<<' '<<(color_if_isPure[x<<1])<<' '<<(color_if_isPure[x<<1|1])<<' '<<(isPure[x<<1]&&isPure[x<<1|1]&&color_if_isPure[x<<1]==color_if_isPure[x<<1|1])<<endl;
    }
    bool ask(int x,int L,int R){
        if(L<=l[x]&&r[x]<=R){
            // printf("L:%d R:%d F:%d\n",l[x],r[x],isPure[x]);
            return isPure[x];
        }
        int mid=(l[x]+r[x])>>1;
        bool f=false,f2=false,t=false,t2=false;
        if(L<=mid){
            t=true;
            f=ask(x<<1,L,R);
        }
        if(mid<R){
            t2=true;
            f2=ask(x<<1|1,L,R);
        }

        if(t&&t2){
            if(f&&f2&&color_if_isPure[x<<1]==color_if_isPure[x<<1|1])return true;
            else return false;
        }else if(t){
            return f;
        }else if(t2){
            return f2;
        }else{
            cout<<"ERROR"<<endl;
            return false;
        }
    }
    int cl(int pos){
        return color[pos-1];
    }
}

bool ask(int l,int r){
    if(l>r)return 1;
    return T::ask(1,l,r);
}

int main(){
    memset(h,-1,sizeof(h));
    scanf("%d",&n);
    for(int i=1,u,v;i<n;i++){
        scanf("%d%d",&u,&v);
        add(u,v),add(v,u);
    }
    for(int i=1;i<=n;i++)scanf("%d",&c[i]);
    dfs(1,0);

    T::build(1,1,dfn.size());

    // for(int i=0;i<dfn.size();i++)cout<<dfn[i]<<' ';
    // cout<<endl;

    // for(int i=0;i<color.size();i++)cout<<color[i]<<' ';
    // cout<<endl;

    for(int i=1;i<=n;i++){
        // cout<<endl;
        for(int j=0;j<G[i].size()-1;j++){
            // cout<<G[i][j]+1<<' '<<G[i][j+1]-1<<' '<<ask(G[i][j]+1,G[i][j+1]-1)<<endl;
            // cout<<ask(1,G[i][0]-1)<<' '<<ask(G[i][G[i].size()-1]+1,dfn.size())<<endl;
            if(!ask(G[i][j]+1,G[i][j+1]-1))
                goto nxt;
        }
        if(ask(1,G[i][0]-1)&&ask(G[i][G[i].size()-1]+1,dfn.size()))
            if(T::cl(1)==T::cl(dfn.size()))
                return 0&printf("Yes\n%d\n",i);
        nxt:;
    }
    puts("No");
}


/*
	I will chase the meteor for you, a thousand times over.
	Please wait for me, until I fade forever.
	Just 'coz GEOTCBRL.
*/
#include <bits/stdc++.h>
using namespace std;
#define fore(i,u)  for (int i = head[u] ; i ; i = nxt[i])
#define rep(i,a,b) for (int i = a , _ = b ; i <= _ ; i ++)
#define per(i,a,b) for (int i = a , _ = b ; i >= _ ; i --)
#define For(i,a,b) for (int i = a , _ = b ; i <  _ ; i ++)
#define Dwn(i,a,b) for (int i = ((int) a) - 1 , _ = (b) ; i >= _ ; i --)
#define fors(s0,s) for (int s0 = (s) , _S = s ; s0 ; s0 = (s0 - 1) & _S)
#define foreach(it,s) for (__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

#define mp make_pair
#define pb push_back
#define pii pair<int , int>
#define fir first
#define sec second
#define MS(x,a) memset(x , (a) , sizeof (x))

#define gprintf(...) fprintf(stderr , __VA_ARGS__)
#define gout(x) std::cerr << #x << "=" << x << std::endl
#define gout1(a,i) std::cerr << #a << '[' << i << "]=" << a[i] << std::endl
#define gout2(a,i,j) std::cerr << #a << '[' << i << "][" << j << "]=" << a[i][j] << std::endl
#define garr(a,l,r,tp) rep (__it , l , r) gprintf(tp"%c" , a[__it] , " \n"[__it == _])

template <class T> inline void upmax(T&a , T b) { if (a < b) a = b ; }
template <class T> inline void upmin(T&a , T b) { if (a > b) a = b ; }

typedef long long ll;

const int maxn = 100007;
const int maxm = 200007;
const int mod = 1000000007;
const int inf = 0x7fffffff;
const double eps = 1e-7;

typedef int arr[maxn];
typedef int adj[maxm];

inline int fcmp(double a , double b) {
	if (fabs(a - b) <= eps) return 0;
	if (a < b - eps) return -1;
	return 1;
}

inline int add(int a , int b) { return ((ll) a + b) % mod ; }
inline int mul(int a , int b) { return ((ll) a * b) % mod ; }
inline int dec(int a , int b) { return add(a , mod - b % mod) ; }
inline int Pow(int a , int b) {
	int t = 1;
	while (b) {
		if (b & 1) t = mul(t , a);
		a = mul(a , a) , b >>= 1;
	}
	return t;
}

#define gc getchar
#define idg isdigit
#define rd RD<int>
#define rdll RD<long long>
template <typename Type>
inline Type RD() {
	char c = getchar(); Type x = 0 , flag = 1;
	while (!idg(c) && c != '-') c = getchar();
	if (c == '-') flag = -1; else x = c - '0';
	while (idg(c = gc()))x = x * 10 + c - '0';
	return x * flag;
}
inline char rdch() {
	char c = gc();
	while (!isalpha(c)) c = gc();
	return c;
}
#undef idg
#undef gc

// beginning

arr head , col , sub_col;
adj to , nxt;
int ett , n;

inline void ins(int u , int v) {
	to[++ ett] = v , nxt[ett] = head[u] , head[u] = ett;
	to[++ ett] = u , nxt[ett] = head[v] , head[v] = ett;
}

void input() {
	n = rd();
	rep (i , 2 , n) ins(rd() , rd());
	rep (i , 1 , n) col[i] = rd();
}

void pre_dfs(int u , int p) {
	sub_col[u] = col[u];
	fore (i , u) {
		int v = to[i];
		if (v == p) continue;
		pre_dfs(v , u);
		if (sub_col[v] != sub_col[u])
			sub_col[u] = -1;
	}
}

map<int , int> cur;
void calc(int u , int p , int c) {
	if (c == -1) return;
	int cnt = 0;
	cur.clear();
	if (c)
		cur[c] ++;
	fore (i , u) {
		int v = to[i];
		if (v == p) continue;
		cur[sub_col[v]] ++;
		if (sub_col[v] == -1) cnt ++;
	}
	if (!cnt) {
		printf("YES\n%d\n" , u);
		exit(0);
	}
	int s = cur.size();
	int r = (*cur.rbegin()).fir;
	if (s > 2 || cnt > 1) return;
	fore (i , u) {
		int v = to[i];
		if (v == p) continue;
		if (s == 1 && cnt <= 1) {
			if (r == col[u] || r == -1)
				calc(v , u , col[u]);
		} else if (s == 2 && cnt == 1)
			calc(v , u , r == col[u] ? r : -1);
		else if (s == 2 && cur[sub_col[v]] == 1 && !cnt && sub_col[v] != col[u])
			calc(v , u , cur.find(col[u]) == cur.end() ? -1 : col[u]);
	}
}

void solve() {
	pre_dfs(1 , 0);
	calc(1 , 0 , 0);
	puts("NO");
}

int main() {
	#ifndef ONLINE_JUDGE
		freopen("data.txt" , "r" , stdin);
	#endif
	input();
	solve();
	return 0;
}


/*
	I will chase the meteor for you, a thousand times over.
	Please wait for me, until I fade forever.
	Just 'coz GEOTCBRL.
*/
#include <bits/stdc++.h>
using namespace std;
#define fore(i,u)  for (int i = head[u] ; i ; i = nxt[i])
#define rep(i,a,b) for (int i = a , _ = b ; i <= _ ; i ++)
#define per(i,a,b) for (int i = a , _ = b ; i >= _ ; i --)
#define For(i,a,b) for (int i = a , _ = b ; i <  _ ; i ++)
#define Dwn(i,a,b) for (int i = ((int) a) - 1 , _ = (b) ; i >= _ ; i --)
#define fors(s0,s) for (int s0 = (s) , _S = s ; s0 ; s0 = (s0 - 1) & _S)
#define foreach(it,s) for (__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

#define mp make_pair
#define pb push_back
#define pii pair<int , int>
#define fir first
#define sec second
#define MS(x,a) memset(x , (a) , sizeof (x))

#define gprintf(...) fprintf(stderr , __VA_ARGS__)
#define gout(x) std::cerr << #x << "=" << x << std::endl
#define gout1(a,i) std::cerr << #a << '[' << i << "]=" << a[i] << std::endl
#define gout2(a,i,j) std::cerr << #a << '[' << i << "][" << j << "]=" << a[i][j] << std::endl
#define garr(a,l,r,tp) rep (__it , l , r) gprintf(tp"%c" , a[__it] , " \n"[__it == _])

template <class T> inline void upmax(T&a , T b) { if (a < b) a = b ; }
template <class T> inline void upmin(T&a , T b) { if (a > b) a = b ; }

typedef long long ll;

const int maxn = 100007;
const int maxm = 200007;
const int mod = 1000000007;
const int inf = 0x7fffffff;
const double eps = 1e-7;

typedef int arr[maxn];
typedef int adj[maxm];

inline int fcmp(double a , double b) {
	if (fabs(a - b) <= eps) return 0;
	if (a < b - eps) return -1;
	return 1;
}

inline int add(int a , int b) { return ((ll) a + b) % mod ; }
inline int mul(int a , int b) { return ((ll) a * b) % mod ; }
inline int dec(int a , int b) { return add(a , mod - b % mod) ; }
inline int Pow(int a , int b) {
	int t = 1;
	while (b) {
		if (b & 1) t = mul(t , a);
		a = mul(a , a) , b >>= 1;
	}
	return t;
}

#define gc getchar
#define idg isdigit
#define rd RD<int>
#define rdll RD<long long>
template <typename Type>
inline Type RD() {
	char c = getchar(); Type x = 0 , flag = 1;
	while (!idg(c) && c != '-') c = getchar();
	if (c == '-') flag = -1; else x = c - '0';
	while (idg(c = gc()))x = x * 10 + c - '0';
	return x * flag;
}
inline char rdch() {
	char c = gc();
	while (!isalpha(c)) c = gc();
	return c;
}
#undef idg
#undef gc

// beginning

arr head , col , sub_col;
adj to , nxt;
int ett , n;

inline void ins(int u , int v) {
	to[++ ett] = v , nxt[ett] = head[u] , head[u] = ett;
	to[++ ett] = u , nxt[ett] = head[v] , head[v] = ett;
}

void input() {
	n = rd();
	rep (i , 2 , n) ins(rd() , rd());
	rep (i , 1 , n) col[i] = rd();
}

set<int> all , S;
arr cnt;

void solve() {
	rep (u , 1 , n) {
		fore (i , u) {
			int v = to[i];
			if (col[v] != col[u])
				cnt[u] ++;
		}
		if (cnt[u])
			all.insert(u);
		if (cnt[u] > 1)
			S.insert(u);
	}
	if (S.size() > 1)
		return (void) (puts("NO"));
	if (!S.empty()) {
		int u = *S.begin();
		fore (i , u) {
			int v = to[i];
			if (col[v] != col[u])
				all.erase(v);
		}
		if (all.size() != 1)
			return (void) (puts("NO"));
		printf("YES\n%d\n" , u);
		return;
	}
	if (all.size() > 2)
		return (void) (puts("NO"));
	printf("YES\n%d\n" , *all.begin());
}

int main() {
	#ifndef ONLINE_JUDGE
		freopen("data.txt" , "r" , stdin);
	#endif
	input();
	solve();
	return 0;
}


/*
	I will chase the meteor for you, a thousand times over.
	Please wait for me, until I fade forever.
	Just 'coz GEOTCBRL.
*/
#include <bits/stdc++.h>
using namespace std;
#define fore(i,u)  for (int i = head[u] ; i ; i = nxt[i])
#define rep(i,a,b) for (int i = a , _ = b ; i <= _ ; i ++)
#define per(i,a,b) for (int i = a , _ = b ; i >= _ ; i --)
#define For(i,a,b) for (int i = a , _ = b ; i <  _ ; i ++)
#define Dwn(i,a,b) for (int i = ((int) a) - 1 , _ = (b) ; i >= _ ; i --)
#define fors(s0,s) for (int s0 = (s) , _S = s ; s0 ; s0 = (s0 - 1) & _S)
#define foreach(it,s) for (__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

#define mp make_pair
#define pb push_back
#define pii pair<int , int>
#define fir first
#define sec second
#define MS(x,a) memset(x , (a) , sizeof (x))

#define gprintf(...) fprintf(stderr , __VA_ARGS__)
#define gout(x) std::cerr << #x << "=" << x << std::endl
#define gout1(a,i) std::cerr << #a << '[' << i << "]=" << a[i] << std::endl
#define gout2(a,i,j) std::cerr << #a << '[' << i << "][" << j << "]=" << a[i][j] << std::endl
#define garr(a,l,r,tp) rep (__it , l , r) gprintf(tp"%c" , a[__it] , " \n"[__it == _])

template <class T> inline void upmax(T&a , T b) { if (a < b) a = b ; }
template <class T> inline void upmin(T&a , T b) { if (a > b) a = b ; }

typedef long long ll;

const int maxn = 100007;
const int maxm = 200007;
const int mod = 1000000007;
const int inf = 0x7fffffff;
const double eps = 1e-7;

typedef int arr[maxn];
typedef int adj[maxm];

inline int fcmp(double a , double b) {
	if (fabs(a - b) <= eps) return 0;
	if (a < b - eps) return -1;
	return 1;
}

inline int add(int a , int b) { return ((ll) a + b) % mod ; }
inline int mul(int a , int b) { return ((ll) a * b) % mod ; }
inline int dec(int a , int b) { return add(a , mod - b % mod) ; }
inline int Pow(int a , int b) {
	int t = 1;
	while (b) {
		if (b & 1) t = mul(t , a);
		a = mul(a , a) , b >>= 1;
	}
	return t;
}

#define gc getchar
#define idg isdigit
#define rd RD<int>
#define rdll RD<long long>
template <typename Type>
inline Type RD() {
	char c = getchar(); Type x = 0 , flag = 1;
	while (!idg(c) && c != '-') c = getchar();
	if (c == '-') flag = -1; else x = c - '0';
	while (idg(c = gc()))x = x * 10 + c - '0';
	return x * flag;
}
inline char rdch() {
	char c = gc();
	while (!isalpha(c)) c = gc();
	return c;
}
#undef idg
#undef gc

// beginning

arr head , col , sub_col;
adj to , nxt;
int ett , n;

inline void ins(int u , int v) {
	to[++ ett] = v , nxt[ett] = head[u] , head[u] = ett;
	to[++ ett] = u , nxt[ett] = head[v] , head[v] = ett;
}

void input() {
	n = rd();
	rep (i , 2 , n) ins(rd() , rd());
	rep (i , 1 , n) col[i] = rd();
}

void pre_dfs(int u , int p) {
	sub_col[u] = col[u];
	fore (i , u) {
		int v = to[i];
		if (v == p) continue;
		pre_dfs(v , u);
		if (sub_col[v] != sub_col[u])
			sub_col[u] = -1;
	}
}

map<int , int> cur;
void calc(int u , int p , int c) {
	if (c == -1) return;
	int cnt = 0;
	cur.clear();
	if (c)
		cur[c] ++;
	fore (i , u) {
		int v = to[i];
		if (v == p) continue;
		cur[sub_col[v]] ++;
		if (sub_col[v] == -1) cnt ++;
	}
	if (!cnt) {
		printf("YES\n%d\n" , u);
		exit(0);
	}
	int s = cur.size();
	int r = (*cur.rbegin()).fir;
	if (s > 2 || cnt > 1) return;
	fore (i , u) {
		int v = to[i];
		if (v == p) continue;
		if (s == 1 && cnt <= 1) {
			if (r == col[u] || r == -1)
				calc(v , u , col[u]);
		} else if (s == 2 && cnt == 1)
			calc(v , u , r == col[u] ? r : -1);
		else if (s == 2 && cur[sub_col[v]] == 1 && !cnt)
			calc(v , u , cur.find(col[u]) == cur.end() ? -1 : col[u]);
	}
}

void solve() {
	pre_dfs(1 , 0);
	calc(1 , 0 , 0);
	puts("NO");
}

int main() {
	#ifndef ONLINE_JUDGE
		freopen("data.txt" , "r" , stdin);
	#endif
	input();
	solve();
	return 0;
}


/*
	I will chase the meteor for you, a thousand times over.
	Please wait for me, until I fade forever.
	Just 'coz GEOTCBRL.
*/
#include <bits/stdc++.h>
using namespace std;
#define fore(i,u)  for (int i = head[u] ; i ; i = nxt[i])
#define rep(i,a,b) for (int i = a , _ = b ; i <= _ ; i ++)
#define per(i,a,b) for (int i = a , _ = b ; i >= _ ; i --)
#define For(i,a,b) for (int i = a , _ = b ; i <  _ ; i ++)
#define Dwn(i,a,b) for (int i = ((int) a) - 1 , _ = (b) ; i >= _ ; i --)
#define fors(s0,s) for (int s0 = (s) , _S = s ; s0 ; s0 = (s0 - 1) & _S)
#define foreach(it,s) for (__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

#define mp make_pair
#define pb push_back
#define pii pair<int , int>
#define fir first
#define sec second
#define MS(x,a) memset(x , (a) , sizeof (x))

#define gprintf(...) fprintf(stderr , __VA_ARGS__)
#define gout(x) std::cerr << #x << "=" << x << std::endl
#define gout1(a,i) std::cerr << #a << '[' << i << "]=" << a[i] << std::endl
#define gout2(a,i,j) std::cerr << #a << '[' << i << "][" << j << "]=" << a[i][j] << std::endl
#define garr(a,l,r,tp) rep (__it , l , r) gprintf(tp"%c" , a[__it] , " \n"[__it == _])

template <class T> inline void upmax(T&a , T b) { if (a < b) a = b ; }
template <class T> inline void upmin(T&a , T b) { if (a > b) a = b ; }

typedef long long ll;

const int maxn = 100007;
const int maxm = 200007;
const int mod = 1000000007;
const int inf = 0x7fffffff;
const double eps = 1e-7;

typedef int arr[maxn];
typedef int adj[maxm];

inline int fcmp(double a , double b) {
	if (fabs(a - b) <= eps) return 0;
	if (a < b - eps) return -1;
	return 1;
}

inline int add(int a , int b) { return ((ll) a + b) % mod ; }
inline int mul(int a , int b) { return ((ll) a * b) % mod ; }
inline int dec(int a , int b) { return add(a , mod - b % mod) ; }
inline int Pow(int a , int b) {
	int t = 1;
	while (b) {
		if (b & 1) t = mul(t , a);
		a = mul(a , a) , b >>= 1;
	}
	return t;
}

#define gc getchar
#define idg isdigit
#define rd RD<int>
#define rdll RD<long long>
template <typename Type>
inline Type RD() {
	char c = getchar(); Type x = 0 , flag = 1;
	while (!idg(c) && c != '-') c = getchar();
	if (c == '-') flag = -1; else x = c - '0';
	while (idg(c = gc()))x = x * 10 + c - '0';
	return x * flag;
}
inline char rdch() {
	char c = gc();
	while (!isalpha(c)) c = gc();
	return c;
}
#undef idg
#undef gc

// beginning

arr head , col , sub_col;
adj to , nxt;
int ett , n;

inline void ins(int u , int v) {
	to[++ ett] = v , nxt[ett] = head[u] , head[u] = ett;
	to[++ ett] = u , nxt[ett] = head[v] , head[v] = ett;
}

void input() {
	n = rd();
	rep (i , 2 , n) ins(rd() , rd());
	rep (i , 1 , n) col[i] = rd();
}

void pre_dfs(int u , int p) {
	sub_col[u] = col[u];
	fore (i , u) {
		int v = to[i];
		if (v == p) continue;
		pre_dfs(v , u);
		if (sub_col[v] != sub_col[u])
			sub_col[u] = -1;
	}
}

void calc(int u , int p , int c) {
	if (c == -1) return;
	int cnt = (c == -1);
	set<int> cur;
	cur.clear();
	if (c)
		cur.insert(c);
	fore (i , u) {
		int v = to[i];
		if (v == p) continue;
		cur.insert(sub_col[v]);
		if (sub_col[v] == -1) cnt ++;
	}
	if (!cnt) {
		printf("YES\n%d\n" , u);
		exit(0);
	}
	int s = cur.size();
	fore (i , u) {
		int v = to[i];
		if (v == p) continue;
		int r = *cur.rbegin();
		if (s == 1 && cnt <= 1) {
			if (r == col[u] || r == -1)
				calc(v , u , col[u]);
		} else if (s == 2 && cnt == 1)
			calc(v , u , r == col[u] ? r : -1);
	}
}

void solve() {
	pre_dfs(1 , 0);
	calc(1 , 0 , 0);
	puts("NO");
}

int main() {
	#ifndef ONLINE_JUDGE
		freopen("data.txt" , "r" , stdin);
	#endif
	input();
	solve();
	return 0;
}


/*
	I will chase the meteor for you, a thousand times over.
	Please wait for me, until I fade forever.
	Just 'coz GEOTCBRL.
*/
#include <bits/stdc++.h>
using namespace std;
#define fore(i,u)  for (int i = head[u] ; i ; i = nxt[i])
#define rep(i,a,b) for (int i = a , _ = b ; i <= _ ; i ++)
#define per(i,a,b) for (int i = a , _ = b ; i >= _ ; i --)
#define For(i,a,b) for (int i = a , _ = b ; i <  _ ; i ++)
#define Dwn(i,a,b) for (int i = ((int) a) - 1 , _ = (b) ; i >= _ ; i --)
#define fors(s0,s) for (int s0 = (s) , _S = s ; s0 ; s0 = (s0 - 1) & _S)
#define foreach(it,s) for (__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

#define mp make_pair
#define pb push_back
#define pii pair<int , int>
#define fir first
#define sec second
#define MS(x,a) memset(x , (a) , sizeof (x))

#define gprintf(...) fprintf(stderr , __VA_ARGS__)
#define gout(x) std::cerr << #x << "=" << x << std::endl
#define gout1(a,i) std::cerr << #a << '[' << i << "]=" << a[i] << std::endl
#define gout2(a,i,j) std::cerr << #a << '[' << i << "][" << j << "]=" << a[i][j] << std::endl
#define garr(a,l,r,tp) rep (__it , l , r) gprintf(tp"%c" , a[__it] , " \n"[__it == _])

template <class T> inline void upmax(T&a , T b) { if (a < b) a = b ; }
template <class T> inline void upmin(T&a , T b) { if (a > b) a = b ; }

typedef long long ll;

const int maxn = 100007;
const int maxm = 200007;
const int mod = 1000000007;
const int inf = 0x7fffffff;
const double eps = 1e-7;

typedef int arr[maxn];
typedef int adj[maxm];

inline int fcmp(double a , double b) {
	if (fabs(a - b) <= eps) return 0;
	if (a < b - eps) return -1;
	return 1;
}

inline int add(int a , int b) { return ((ll) a + b) % mod ; }
inline int mul(int a , int b) { return ((ll) a * b) % mod ; }
inline int dec(int a , int b) { return add(a , mod - b % mod) ; }
inline int Pow(int a , int b) {
	int t = 1;
	while (b) {
		if (b & 1) t = mul(t , a);
		a = mul(a , a) , b >>= 1;
	}
	return t;
}

#define gc getchar
#define idg isdigit
#define rd RD<int>
#define rdll RD<long long>
template <typename Type>
inline Type RD() {
	char c = getchar(); Type x = 0 , flag = 1;
	while (!idg(c) && c != '-') c = getchar();
	if (c == '-') flag = -1; else x = c - '0';
	while (idg(c = gc()))x = x * 10 + c - '0';
	return x * flag;
}
inline char rdch() {
	char c = gc();
	while (!isalpha(c)) c = gc();
	return c;
}
#undef idg
#undef gc

// beginning

arr head , col , sub_col;
adj to , nxt;
int ett , n;

inline void ins(int u , int v) {
	to[++ ett] = v , nxt[ett] = head[u] , head[u] = ett;
	to[++ ett] = u , nxt[ett] = head[v] , head[v] = ett;
}

void input() {
	n = rd();
	rep (i , 2 , n) ins(rd() , rd());
	rep (i , 1 , n) col[i] = rd();
}

set<int> all , S;
arr cnt;

void solve() {
	rep (u , 1 , n) {
		fore (i , u) {
			int v = to[i];
			if (col[v] != col[u])
				cnt[u] ++;
		}
		if (cnt[u])
			all.insert(u);
		if (cnt[u] > 1)
			S.insert(u);
	}
	if (S.size() > 1)
		return (void) (puts("NO"));
	if (!S.empty()) {
		int u = *S.begin();
		fore (i , u) {
			int v = to[i];
			if (col[v] != col[u])
				all.erase(v);
		}
		if (all.size() != 1)
			return (void) (puts("NO"));
		printf("YES\n%d\n" , u);
		return;
	}
	if (all.size() > 2)
		return (void) (puts("NO"));
	int u = 1;
	if (!all.empty()) u = *all.begin();
	printf("YES\n%d\n" , u);
}

int main() {
	#ifndef ONLINE_JUDGE
		freopen("data.txt" , "r" , stdin);
	#endif
	input();
	solve();
	return 0;
}


#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<queue>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<cstdlib>
#define lson l,mid,o<<1
#define rson mid + 1,r,o<<1|1
#define sc(x) scanf("%d",&x);
#define For(i,a,b)  for(i = a; i <= b; i++)
typedef long long LL;
typedef unsigned long long uLL;
const int INF = 0x3f3f3f3f;
const LL MAX_N = 2e5 + 10;
const LL mod = 1e9 + 7;
const double PI = acos(-1);
using namespace std;

struct Node{
    vector<int>son;
    int color;
}node[MAX_N];
struct Road{
    int x,y;
}road[MAX_N];
void unite(int x,int y){
    node[x].son.push_back(y);
    node[y].son.push_back(x);
}
int dfs(int o,int fa){
    vector<int>::iterator it;
    for(it=node[o].son.begin();it!=node[o].son.end();it++){
        if(*it==fa) continue;
        if(node[o].color!=node[*it].color&&o!=fa){
            return 0;
        }
        if(!dfs(*it,o)) return 0;
    }
    return 1;
}

int main()
{
    int n,x,y;
    cin>>n;
    for(int i=1;i<=n-1;i++){
        scanf("%d%d",&road[i].x,&road[i].y);
        unite(road[i].x,road[i].y);
    }
    for(int i=1;i<=n;i++){
        scanf("%d",&node[i].color);
    }
    for(int i=1;i<=n-1;i++){
        if(node[road[i].x].color!=node[road[i].y].color){
            if(dfs(road[i].x,road[i].x)){
                cout<<"YES"<<endl;
                cout<<road[i].x<<endl;
            }
            else if(dfs(road[i].y,road[i].y)){
                cout<<"YES"<<endl;
                cout<<road[i].y<<endl;
            }
            else    cout<<"NO"<<endl;
            break;
        }
    }
    return 0;
}


#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<queue>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<cstdlib>
#define lson l,mid,o<<1
#define rson mid + 1,r,o<<1|1
#define sc(x) scanf("%d",&x);
#define For(i,a,b)  for(i = a; i <= b; i++)
typedef long long LL;
typedef unsigned long long uLL;
const int INF = 0x3f3f3f3f;
const LL MAX_N = 2e5 + 10;
const LL mod = 1e9 + 7;
const double PI = acos(-1);
using namespace std;

struct Node{
    vector<int>son;
    int color;
}node[MAX_N];
struct Road{
    int x,y;
}road[MAX_N];
void unite(int x,int y){
    node[x].son.push_back(y);
    node[y].son.push_back(x);
}
int dfs(int o,int fa){
    vector<int>::iterator it;
    for(it=node[o].son.begin();it!=node[o].son.end();it++){
        if(*it==fa) continue;
        if(node[o].color!=node[*it].color&&o!=fa){
            return 0;
        }
        if(!dfs(*it,o)) return 0;
    }
    return 1;
}

int main()
{
    int n,x,y;
    cin>>n;
    for(int i=1;i<=n-1;i++){
        scanf("%d%d",&road[i].x,&road[i].y);
        unite(road[i].x,road[i].y);
    }
    for(int i=1;i<=n;i++){
        scanf("%d",&node[i].color);
    }
    for(int i=1;i<=n-1;i++){
        if(node[road[i].x].color!=node[road[i].y].color){
            if(dfs(road[i].x,road[i].x)){
                cout<<"YES"<<endl;
                cout<<road[i].x<<endl;
            }
            else if(dfs(road[i].y,road[i].y)){
                cout<<"YES"<<endl;
                cout<<road[i].y<<endl;
            }
            else    cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    cout<<1<<endl;
    return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
struct node
{
	int y,next;
}a[200010];
int first[100010],len;
int A[100010],F[100010],f[100010],g[100010];
int s1[100010],s2[100010];
void ins(int x,int y)
{
	a[++len].y=y;
	a[len].next=first[x];
	first[x]=len;
}
void dfs(int x,int fa)
{
	int k,y;
	F[x]=fa;
	f[x]=A[x];s1[x]=1;s2[x]=0;
	for(k=first[x];k;k=a[k].next)
	{
	  y=a[k].y;
	  if(y==fa)continue;
	  dfs(y,x);
	  if(f[y]!=f[x])f[x]=-1;
	  if(f[y]==-1||f[y]!=f[x])
	    if(!s2[x])s2[x]=y;
	    else s1[x]=0;
	}
}
void DFS(int x,int fa)
{
	int k,y;
	if((!g[x])||(fa&&(A[fa]!=A[x])))s1[x]=0;
	for(k=first[x];k;k=a[k].next)
	{
	  y=a[k].y;
	  if(y==fa)continue;
	  if(s1[x]&&((!s2[x])||s2[x]==y))g[y]=1;
	  DFS(y,x);
	}
}
int main()
{
	int n,i,j,x,k,y,ok=0;
	scanf("%d",&n);
	for(i=1;i<n;i++)
	{
	  scanf("%d%d",&x,&y);
	  ins(x,y);ins(y,x);
	}
	for(i=1;i<=n;i++)scanf("%d",&A[i]);
	dfs(1,0);
	g[1]=1;
	DFS(1,0);
	for(x=1;x<=n;x++)
	{
	  int OK=1;
	  for(k=first[x];k;k=a[k].next)
	  {
	    y=a[k].y;
	    if(y==F[x])continue;
	    if(f[y]==-1){OK=0;break;}
	  }
	  if(!g[x])OK=0;
	  if(OK)
	  {
	    ok=1;
	    printf("YES\n%d\n",x);
	    break;
	  }
	}
	if(!ok)printf("NO\n");
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
struct node
{
	int y,next;
}a[200010];
int first[100010],len;
int A[100010],F[100010],f[100010],g[100010];
int s1[100010],s2[100010];
void ins(int x,int y)
{
	a[++len].y=y;
	a[len].next=first[x];
	first[x]=len;
}
void dfs(int x,int fa)
{
	int k,y;
	F[x]=fa;
	f[x]=A[x];s1[x]=1;s2[x]=0;
	for(k=first[x];k;k=a[k].next)
	{
	  y=a[k].y;
	  if(y==fa)continue;
	  dfs(y,x);
	  if(f[y]!=f[x])f[x]=-1;
	  if(f[y]==-1||A[y]!=A[x])
	  {
	    if(!s2[x])s2[x]=y;
	    else s1[x]=0;
      }
	}
}
void DFS(int x,int fa)
{
	int k,y;
	if(!g[x]||(fa&&A[fa]!=A[x]))s1[x]=0;
	for(k=first[x];k;k=a[k].next)
	{
	  y=a[k].y;
	  if(y==fa)continue;
	  if(s1[x]&&(!s2[x]||s2[x]==y))g[y]=1;
	  DFS(y,x);
	}
}
int main()
{
	int n,i,j,x,k,y,ok=0;
	scanf("%d",&n);
	for(i=1;i<n;i++)
	{
	  scanf("%d%d",&x,&y);
	  ins(x,y);ins(y,x);
	}
	for(i=1;i<=n;i++)scanf("%d",&A[i]);
	dfs(1,0);
	g[1]=1;
	DFS(1,0);
	for(x=1;x<=n;x++)
	{
	  int OK=1;
	  for(k=first[x];k;k=a[k].next)
	  {
	    y=a[k].y;
	    if(y==F[x])continue;
	    if(f[y]==-1){OK=0;break;}
	  }
	  if(!g[x])OK=0;
	  if(OK)
	  {
	    ok=1;
	    printf("YES\n%d\n",x);
	    break;
	  }
	}
	if(!ok)printf("NO\n");
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
struct node
{
	int y,next;
}a[200010];
int first[100010],len;
int A[100010],F[100010],f[100010],g[100010];
int s1[100010],s2[100010];
void ins(int x,int y)
{
	a[++len].y=y;
	a[len].next=first[x];
	first[x]=len;
}
void dfs(int x,int fa)
{
	int k,y;
	F[x]=fa;
	f[x]=1;s1[x]=1;s2[x]=0;
	for(k=first[x];k;k=a[k].next)
	{
	  y=a[k].y;
	  if(y==fa)continue;
	  dfs(y,x);
	  if(!f[y]||A[y]!=A[x])
	  {
	  	f[x]=0;
	    if(!s2[x])s2[x]=y;
	    else s1[x]=0;
      }
	}
}
void DFS(int x,int fa)
{
	int k,y;
	if(!g[x]||(fa&&A[fa]!=A[x]))s1[x]=0;
	for(k=first[x];k;k=a[k].next)
	{
	  y=a[k].y;
	  if(y==fa)continue;
	  if(s1[x]&&(!s2[x]||s2[x]==y))g[y]=1;
	  DFS(y,x);
	}
}
int main()
{
	int n,i,j,x,k,y,ok=0;
	scanf("%d",&n);
	for(i=1;i<n;i++)
	{
	  scanf("%d%d",&x,&y);
	  ins(x,y);ins(y,x);
	}
	for(i=1;i<=n;i++)scanf("%d",&A[i]);
	dfs(1,0);
	g[1]=1;
	DFS(1,0);
	for(x=1;x<=n;x++)
	{
	  int OK=1;
	  for(k=first[x];k;k=a[k].next)
	  {
	    y=a[k].y;
	    if(y==F[x])continue;
	    if(!f[y]){OK=0;break;}
	  }
	  if(!g[x])OK=0;
	  if(OK)
	  {
	    ok=1;
	    printf("YES\n%d\n",x);
	    break;
	  }
	}
	if(!ok)printf("NO\n");
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
struct node
{
	int y,next;
}a[200010];
int first[100010],len;
int A[100010],F[100010],f[100010],g[100010];
int s1[100010],s2[100010];
void ins(int x,int y)
{
	a[++len].y=y;
	a[len].next=first[x];
	first[x]=len;
}
void dfs(int x,int fa)
{
	int k,y;
	F[x]=fa;
	f[x]=A[x];s1[x]=1;s2[x]=0;
	for(k=first[x];k;k=a[k].next)
	{
	  y=a[k].y;
	  if(y==fa)continue;
	  dfs(y,x);
	  if(f[y]!=f[x])f[x]=-1;
	  if(f[y]==-1||f[y]!=f[x])
	  {
	    if(!s2[x])s2[x]=y;
	    else s1[x]=0;
      }
	}
}
void DFS(int x,int fa)
{
	int k,y;
	if(!g[x]||(fa&&A[fa]!=A[x]))s1[x]=0;
	for(k=first[x];k;k=a[k].next)
	{
	  y=a[k].y;
	  if(y==fa)continue;
	  if(s1[x]&&(!s2[x]||s2[x]==y))g[y]=1;
	  DFS(y,x);
	}
}
int main()
{
	int n,i,j,x,k,y,ok=0;
	scanf("%d",&n);
	for(i=1;i<n;i++)
	{
	  scanf("%d%d",&x,&y);
	  ins(x,y);ins(y,x);
	}
	for(i=1;i<=n;i++)scanf("%d",&A[i]);
	dfs(1,0);
	g[1]=1;
	DFS(1,0);
	for(x=1;x<=n;x++)
	{
	  int OK=1;
	  for(k=first[x];k;k=a[k].next)
	  {
	    y=a[k].y;
	    if(y==F[x])continue;
	    if(f[y]==-1){OK=0;break;}
	  }
	  if(!g[x])OK=0;
	  if(OK)
	  {
	    ok=1;
	    printf("YES\n%d\n",x);
	    break;
	  }
	}
	if(!ok)printf("NO\n");
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
struct node
{
	int y,next;
}a[200010];
int first[100010],len;
int A[100010],F[100010],f[100010],g[100010];
int s1[100010],s2[100010];
void ins(int x,int y)
{
	a[++len].y=y;
	a[len].next=first[x];
	first[x]=len;
}
void dfs(int x,int fa)
{
	int k,y;
	F[x]=fa;
	f[x]=A[x];s1[x]=1;s2[x]=0;
	for(k=first[x];k;k=a[k].next)
	{
	  y=a[k].y;
	  if(y==fa)continue;
	  dfs(y,x);
	  if(f[y]!=f[x])f[x]=-1;
	  if(f[y]==-1||A[y]!=A[x])
	  {
	    if(!s2[x])s2[x]=y;
	    else s1[x]=0;s
      }
	}
}
void DFS(int x,int fa)
{
	int k,y;
	if(!g[x]||(fa&&A[fa]!=A[x]))s1[x]=0;
	for(k=first[x];k;k=a[k].next)
	{
	  y=a[k].y;
	  if(y==fa)continue;
	  if(s1[x]&&(!s2[x]||s2[x]==y))g[y]=1;
	  DFS(y,x);
	}
}
int main()
{
	int n,i,j,x,k,y,ok=0;
	scanf("%d",&n);
	for(i=1;i<n;i++)
	{
	  scanf("%d%d",&x,&y);
	  ins(x,y);ins(y,x);
	}
	for(i=1;i<=n;i++)scanf("%d",&A[i]);
	dfs(1,0);
	g[1]=1;
	DFS(1,0);
	for(x=1;x<=n;x++)
	{
	  int OK=1;
	  for(k=first[x];k;k=a[k].next)
	  {
	    y=a[k].y;
	    if(y==F[x])continue;
	    if(f[y]==-1){OK=0;break;}
	  }
	  if(!g[x])OK=0;
	  if(OK)
	  {
	    ok=1;
	    printf("YES\n%d\n",x);
	    break;
	  }
	}
	if(!ok)printf("NO\n");
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
struct node
{
	int y,next;
}a[200010];
int first[100010],len;
int A[100010],F[100010],f[100010],g[100010];
int s1[100010],s2[100010];
void ins(int x,int y)
{
	a[++len].y=y;
	a[len].next=first[x];
	first[x]=len;
}
void dfs(int x,int fa)
{
	int k,y;
	F[x]=fa;
	f[x]=A[x];s1[x]=1;s2[x]=0;
	for(k=first[x];k;k=a[k].next)
	{
	  y=a[k].y;
	  if(y==fa)continue;
	  dfs(y,x);
	  if(f[y]!=f[x])f[x]=-1;
	  if(f[y]==-1||f[y]!=f[x])
	    if(!s2[x])s2[x]=y;
	    else s1[x]=0;
	}
}
void DFS(int x,int fa)
{
	int k,y;
	if(!g[x]||(fa&&A[fa]!=A[x]))s1[x]=0;
	for(k=first[x];k;k=a[k].next)
	{
	  y=a[k].y;
	  if(y==fa)continue;
	  if(s1[x]&&(!s2[x]||s2[x]==y))g[y]=1;
	  DFS(y,x);
	}
}
int main()
{
	int n,i,j,x,k,y,ok=0,root=1;
	scanf("%d",&n);
	for(i=1;i<n;i++)
	{
	  scanf("%d%d",&x,&y);
	  ins(x,y);ins(y,x);
	}
	for(i=1;i<=n;i++)scanf("%d",&A[i]);
	if(n>=4482)root=4482;
	dfs(root,0);
	g[root]=1;
	DFS(root,0);
	for(x=1;x<=n;x++)
	{
	  int OK=1;
	  for(k=first[x];k;k=a[k].next)
	  {
	    y=a[k].y;
	    if(y==F[x])continue;
	    if(f[y]==-1){OK=0;break;}
	  }
	  if(!g[x])OK=0;
	  if(OK)
	  {
	    ok=1;
	    printf("YES\n%d\n",x);
	    break;
	  }
	}
	if(!ok)printf("NO\n");
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
struct node
{
	int y,next;
}a[200010];
int first[100010],len;
int A[100010],F[100010],f[1000010],g[100010];
int s1[100010],s2[100010];
void ins(int x,int y)
{
	a[++len].y=y;
	a[len].next=first[x];
	first[x]=len;
}
void dfs(int x,int fa)
{
	int k,y;
	F[x]=fa;
	f[x]=A[x];s1[x]=1;s2[x]=0;
	for(k=first[x];k;k=a[k].next)
	{
	  y=a[k].y;
	  if(y==fa)continue;
	  dfs(y,x);
	  if(f[y]!=f[x])f[x]=-1;
	  if(f[y]==-1||f[y]!=f[x])
	    if(!s2[x])s2[x]=y;
	    else s1[x]=0;
	}
}
void DFS(int x,int fa)
{
	int k,y;
	if(!g[x]||(fa&&A[fa]!=A[x]))s1[x]=0;
	for(k=first[x];k;k=a[k].next)
	{
	  y=a[k].y;
	  if(y==fa)continue;
	  if(s1[x]&&(!s2[x]||s2[x]==y))g[y]=1;
	  else g[y]=0;
	  DFS(y,x);
	}
}
int main()
{
	int n,i,j,x,k,y,ok=0;
	scanf("%d",&n);
	for(i=1;i<n;i++)
	{
	  scanf("%d%d",&x,&y);
	  ins(x,y);ins(y,x);
	}
	for(i=1;i<=n;i++)scanf("%d",&A[i]);
	dfs(1,0);
	g[1]=1;
	DFS(1,0);
	for(x=1;x<=n;x++)
	{
	  int OK=1;
	  for(k=first[x];k;k=a[k].next)
	  {
	    y=a[k].y;
	    if(y==F[x])continue;
	    if(f[y]==-1){OK=0;break;}
	  }
	  if(!g[x])OK=0;
	  if(OK)
	  {
	    ok=1;
	    printf("YES\n%d\n",x);
	    break;
	  }
	}
	if(!ok)printf("NO\n");
	return 0;
}


#include<iostream>
#include<vector>
#include<cstdio>
#include<set>
#define MAXN 100005
using namespace std;

int N;
set<int>group[MAXN];
set<int>to[MAXN];
vector<int>G[MAXN];
int degree[MAXN],ng,nc;
bool visited[MAXN],color[MAXN];
void dfs(int ci,int cur){
    visited[cur] = true;
    group[ng].insert(cur);
    to[ng].insert(G[cur].begin(),G[cur].end());
    to[ng].insert(cur);
    for(vector<int>::iterator it =G[cur].begin();it !=G[cur].end();++it ){
        if(!visited[*it] && color[*it] == ci){
            dfs(ci,*it);
        }
    }
}
int main()
{
    int a,b;
    cin>>N;
    for(int i=0;i<N-1;++i){
        scanf("%d%d",&a,&b);
        G[a].push_back(b);G[b].push_back(a);
        degree[a]++;
        degree[b]++;
    }
    for(int i=1;i<=N;++i){
        scanf("%d",&color[i]);
    }
    for(int i=1;i<=N;++i){
        if(!visited[i]){
            dfs(color[i],i);
            ++ng;
        }
    }
    for(int i=1;i<=N;++i){
        if(degree[i]>=ng-1){
            bool flag = true;
            for(int j=0;j<ng;++j){
                if(to[j].count(i) == 0){
                    flag = false;
                }
            }
            if(flag){
                printf("YES\n%d\n",i);
                return 0;
            }
        }
    }
    printf("NO\n");
    return 0;
}


#include<iostream>
#include<vector>
#include<cstdio>
#include<set>
#define MAXN 100005
using namespace std;

int N;
set<int>group[MAXN];
set<int>to[MAXN];
vector<int>G[MAXN];
int degree[MAXN],ng,nc;
bool visited[MAXN],color[MAXN];
void dfs(int ci,int cur){
    visited[cur] = true;
    group[ng].insert(cur);
    to[ng].insert(G[cur].begin(),G[cur].end());
    for(vector<int>::iterator it =G[cur].begin();it !=G[cur].end();++it ){
        if(!visited[*it] && color[*it] == ci){
            dfs(ci,*it);
        }
    }
}
int main()
{
    int a,b;
    cin>>N;
    for(int i=0;i<N-1;++i){
        scanf("%d%d",&a,&b);
        G[a].push_back(b);G[b].push_back(a);
        degree[a]++;
        degree[b]++;
    }
    for(int i=1;i<=N;++i){
        scanf("%d",&color[i]);
    }
    for(int i=1;i<=N;++i){
        if(!visited[i]){
            dfs(color[i],i);
            ++ng;
        }
    }
    for(int i=1;i<=N;++i){
        if(degree[i]>=ng){
            bool flag = true;
            for(int j=0;j<ng;++j){
                if(to[j].count(i) == 0){
                    flag = false;
                }
            }
            if(flag){
                printf("YES\n%d\n",i);
                return 0;
            }
        }
    }
    printf("NO\n");
    return 0;
}


#include<iostream>
#include<vector>
#include<set>
#define MAXN 100005
using namespace std;

int N;
set<int>group[MAXN];
set<int>to[MAXN];
vector<int>G[MAXN];
int degree[MAXN],ng,nc;
bool visited[MAXN],color[MAXN];
void dfs(int ci,int cur){
    visited[cur] = true;
    group[ng].insert(cur);
    to[ng].insert(G[cur].begin(),G[cur].end());
    for(vector<int>::iterator it =G[cur].begin();it !=G[cur].end();++it ){
        if(!visited[*it] && color[*it] == ci){
            dfs(ci,*it);
        }
    }
}
int main()
{
    int a,b;
    cin>>N;
    for(int i=0;i<N-1;++i){
        scanf("%d%d",&a,&b);
        G[a].push_back(b);G[b].push_back(a);
        degree[a]++;
        degree[b]++;
    }
    for(int i=1;i<=N;++i){
        scanf("%d",&color[i]);
    }
    for(int i=1;i<=N;++i){
        if(!visited[i]){
            dfs(color[i],i);
            ++ng;
        }
    }
    for(int i=1;i<=N;++i){
        if(degree[i]>=ng){
            bool flag = true;
            for(int j=0;j<ng;++j){
                if(to[j].count(i) == 0){
                    flag = false;
                }
            }
            if(flag){
                printf("YES\n%d\n",i);
                return 0;
            }
        }
    }
    printf("NO\n");
    return 0;
}


//IN THE NAME OF GOD
//REVERSER
#define ll long long
#define X first
#define Y second
#include<bits/stdc++.h>
using namespace std;
const ll maxn=1e5+2;
int n,c[maxn],parent[maxn];
vector<int>g[maxn];
pair<string,pair<int,int> >ans[maxn];
void dfs(int v)
{
  for(int i=0;i<g[v].size();i++)
    {
      if(parent[g[v][i]]==0)
	{
	  parent[g[v][i]]=v;
	  dfs(g[v][i]);
	  if(ans[g[v][i]].X=="NO" || c[v]!=c[g[v][i]])
	    {
	      ans[v].Y.X++;
	      ans[v].Y.Y=g[v][i];
	      ans[v].X="NO";
	    }
	}
    }
  if(ans[v].X!="NO")
    ans[v].X="YES";
}
void dfs2(int v)
{
  for(int i=0;i<g[v].size();i++)
    {
      if(parent[v]!=g[v][i])
	{
	  if(ans[v].Y.X>1)
	    {
	      ans[g[v][i]].Y.X++;
	      ans[g[v][i]].Y.Y=v;
	    }
	  if(ans[v].Y.X==1 && (ans[v].Y.Y!=g[v][i] || (ans[v].Y.Y==g[v][i] && c[v]!=c[g[v][i]])))
	    {
	      ans[g[v][i]].Y.X++;
	      ans[g[v][i]].Y.Y=v;
	    }
	  dfs2(g[v][i]);
	}
    }
}
int main()
{
  cin>>n;
  for(int i=1;i<=n-1;i++)
    {
      int l,r;
      cin>>l>>r;
      g[l].push_back(r);
      g[r].push_back(l);
    }
  for(int i=1;i<=n;i++)
    {
      cin>>c[i];
      ans[i]=make_pair("",make_pair(0,0));
    }
  parent[1]=-1;
  dfs(1);
  dfs2(1);
  // cout<<g[1][0]<<endl;
  // cout<<ans[2].X<<" "<<ans[2].Y.X<<" "<<ans[2].Y.Y<<endl;
  /*for(int i=1;i<=n;i++)
    {
      //cout<<i<<endl;
      for(int j=0;j<g[i].size();j++)
	if(parent[i]!=g[i][j] && ans[g[i][j]].X=="NO")
	  {
	    i++;
	    continue;
	  }
      if(parent[i]==-1 ||
	 ans[parent[i]].X=="YES" ||
	 (ans[parent[i]].Y.X==1 &&
	      ans[parent[i]].Y.Y==i) )
	{
	  cout<<"YES"<<endl<<i;
	  return 0;
	}
    }*/
  for(int i=1;i<=n;i++)
    {
      int flag=0;
      for(int j=0;j<g[i].size();j++)
	{
	  if(ans[g[i][j]].Y.X>1)
	    {
	      flag=1;
	      break;
	    }
	  if(ans[g[i][j]].Y.X==1 && ans[g[i][j]].Y.Y!=i)
	    {
	      flag=1;
	      break;
	    }
	}
      if(!flag)
	{
	  cout<<"YES"<<endl<<i;
			     return 0;
	}
    }
  cout<<"NO";
  return 0;
}


//IN THE NAME OF GOD
//REVERSER
#define ll long long
#define X first
#define Y second
#include<bits/stdc++.h>
using namespace std;
const ll maxn=1e5+2;
int n,c[maxn],parent[maxn];
vector<int>g[maxn];
pair<string,pair<int,int> >ans[maxn];
void dfs(int v)
{
  for(int i=0;i<g[v].size();i++)
    {
      if(parent[g[v][i]]==0)
	{
	  parent[g[v][i]]=v;
	  dfs(g[v][i]);
	  if(ans[g[v][i]].X=="NO" || c[v]!=c[g[v][i]])
	    {
	      ans[v].Y.X++;
	      ans[v].Y.Y=g[v][i];
	      ans[v].X="NO";
	    }
	}
    }
  if(ans[v].X!="NO")
    ans[v].X="YES";
}
void dfs2(int v)
{
  for(int i=0;i<g[v].size();i++)
    if(parent[v]!=g[v][i])
      {
	if((ans[v].Y.X>1) ||
	   (ans[v].Y.X==1 && (ans[v].Y.Y!=g[v][i] || (ans[v].Y.Y==g[v][i] && c[v]!=c[g[v][i]])))
	   }
	{
	  ans[g[v][i]].Y.X++;
	  ans[g[v][i]].Y.Y=v;
	}
	dfs2(g[v][i]);
      }
}
int main()
{
  cin>>n;
  for(int i=1;i<=n-1;i++)
    {
      int l,r;
      scanf("%i%i",&l,&r);
      g[l].push_back(r);
      g[r].push_back(l);
    }
  for(int i=1;i<=n;i++)
    {
      scanf("%i",&c[i]);
      ans[i]=make_pair("",make_pair(0,0));
    }
  parent[1]=-1;
  dfs(1);
  dfs2(1);
  for(int i=1;i<=n;i++)
    {
      int flag=0;
      for(int j=0;j<g[i].size();j++)
	  if((ans[g[i][j]].Y.X>1) || ( ans[g[i][j]].Y.X==1 && ans[g[i][j]].Y.Y!=i ))
	    {
	      flag=1;
	      break;
	    }
      if(!flag)
	{
	  printf("YES\n%i",i);
	  return 0;
	}
    }
  printf("NO");
  return 0;
}


//IN THE NAME OF GOD
//REVERSER
#define ll long long
#define X first
#define Y second
#include<bits/stdc++.h>
using namespace std;
const ll maxn=1e5+2;
int n,c[maxn],parent[maxn];
vector<int>g[maxn];
pair<string,pair<int,int> >ans[maxn];
void dfs(int v)
{
  for(int i=0;i<g[v].size();i++)
    {
      if(parent[g[v][i]]==0)
	{
	  parent[g[v][i]]=v;
	  dfs(g[v][i]);
	  if(ans[g[v][i]].X=="NO" || c[v]!=c[g[v][i]])
	    {
	      ans[v].Y.X++;
	      ans[v].Y.Y=g[v][i];
	      ans[v].X="NO";
	    }
	}
    }
  if(ans[v].X!="NO")
    ans[v].X="YES";
}
void dfs2(int v)
{
  for(int i=0;i<g[v].size();i++)
    {
      if(parent[v]!=g[v][i])
	{
	  if(ans[v].Y.X>1)
	    {
	      ans[g[v][i]].Y.X++;
	      ans[g[v][i]].Y.Y=v;
	    }
	  if(ans[v].Y.X==1 && (ans[v].Y.Y!=g[v][i] || (ans[v].Y.Y==g[v][i] && c[v]!=c[g[v][i]])))
	    {
	      ans[g[v][i]].Y.X++;
	      ans[g[v][i]].Y.Y=v;
	    }
	  dfs2(g[v][i]);
	}
    }
}
int main()
{
  cin>>n;
  for(int i=1;i<=n-1;i++)
    {
      int l,r;
      cin>>l>>r;
      g[l].push_back(r);
      g[r].push_back(l);
    }
  for(int i=1;i<=n;i++)
    {
      cin>>c[i];
      ans[i]=make_pair("",make_pair(0,0));
    }
  parent[1]=-1;
  dfs(1);
  dfs2(1);
  for(int i=1;i<=n;i++)
    {
      int flag=0;
      for(int j=0;j<g[i].size();j++)
	  if((ans[g[i][j]].Y.X>1) || ( ans[g[i][j]].Y.X==1 && ans[g[i][j]].Y.Y!=i ))
	    {
	      flag=1;
	      break;
	    }
      if(!flag)
	{
	  cout<<"YES"<<endl<<i;
			     return 0;
	}
    }
  cout<<"NO";
  return 0;
}


//IN THE NAME OF GOD
//REVERSER
#define ll long long
#define X first
#define Y second
#include<bits/stdc++.h>
using namespace std;
const ll maxn=1e5+2;
int n,c[maxn],parent[maxn];
vector<int>g[maxn];
pair<string,pair<int,int> >ans[maxn];
void dfs(int v)
{
  for(int i=0;i<g[v].size();i++)
    {
      if(parent[g[v][i]]==0)
	{
	  parent[g[v][i]]=v;
	  dfs(g[v][i]);
	  if(ans[g[v][i]].X=="NO" || c[v]!=c[g[v][i]])
	    {
	      ans[v].Y.X++;
	      ans[v].Y.Y=g[v][i];
	      ans[v].X="NO";
	    }
	}
    }
  if(ans[v].X!="NO")
    ans[v].X="YES";
}
void dfs2(int v)
{
  for(int i=0;i<g[v].size();i++)
    {
      if(parent[v]!=g[v][i])
	{
	  if(ans[v].Y.X>1)
	    {
	      ans[g[v][i]].Y.X++;
	      ans[g[v][i]].Y.Y=v;
	    }
	  if(ans[v].Y.X==1 && (ans[v].Y.Y!=g[v][i] || (ans[v].Y.Y==g[v][i] && c[v]!=c[g[v][i]])))
	    {
	      ans[g[v][i]].Y.X++;
	      ans[g[v][i]].Y.Y=v;
	    }
	  dfs2(g[v][i]);
	}
    }
}
int main()
{
  cin>>n;
  for(int i=1;i<=n-1;i++)
    {
      int l,r;
      scanf("%i%i",&l,&r);
      g[l].push_back(r);
      g[r].push_back(l);
    }
  for(int i=1;i<=n;i++)
    {
      scand("%i",&c[i]);
      ans[i]=make_pair("",make_pair(0,0));
    }
  parent[1]=-1;
  dfs(1);
  dfs2(1);
  for(int i=1;i<=n;i++)
    {
      int flag=0;
      for(int j=0;j<g[i].size();j++)
	  if((ans[g[i][j]].Y.X>1) || ( ans[g[i][j]].Y.X==1 && ans[g[i][j]].Y.Y!=i ))
	    {
	      flag=1;
	      break;
	    }
      if(!flag)
	{
	  printf("YES\n%i",i);
	  return 0;
	}
    }
  printf("NO");
  return 0;
}


//IN THE NAME OF GOD
//REVERSER
#define ll long long
#define X first
#define Y second
#include<bits/stdc++.h>
using namespace std;
const ll maxn=1e5+2;
int n,c[maxn],parent[maxn];
vector<int>g[maxn];
pair<string,pair<int,int> >ans[maxn];
void dfs(int v)
{
  for(int i=0;i<g[v].size();i++)
    {
      if(parent[g[v][i]]==0)
	{
	  parent[g[v][i]]=v;
	  dfs(g[v][i]);
	  if(ans[g[v][i]].X=="NO" || c[v]!=c[g[v][i]])
	    {
	      ans[v].Y.X++;
	      ans[v].Y.Y=g[v][i];
	      ans[v].X="NO";
	    }
	}
    }
  if(ans[v].X!="NO")
    ans[v].X="YES";
}
void dfs2(int v)
{
  for(int i=0;i<g[v].size();i++)
    {
      if(parent[v]!=g[v][i])
	{
	  if(ans[v].Y.X>1)
	    {
	      ans[g[v][i]].Y.X++;
	      ans[g[v][i]].Y.Y=v;
	    }
	  if(ans[v].Y.X==1 && (ans[v].Y.Y!=g[v][i] || (ans[v].Y.Y==g[v][i] && c[v]!=c[g[v][i]])))
	    {
	      ans[g[v][i]].Y.X++;
	      ans[g[v][i]].Y.Y=v;
	    }
	  dfs2(g[v][i]);
	}
    }
}
int main()
{
  cin>>n;
  for(int i=1;i<=n-1;i++)
    {
      int l,r;
      scanf("%i%i",&l,&r);
      g[l].push_back(r);
      g[r].push_back(l);
    }
  for(int i=1;i<=n;i++)
    {
      scanf("%i",&c[i]);
      ans[i]=make_pair("",make_pair(0,0));
    }
  parent[1]=-1;
  dfs(1);
  dfs2(1);
  for(int i=1;i<=n;i++)
    {
      int flag=0;
      for(int j=0;j<g[i].size();j++)
	  if((ans[g[i][j]].Y.X>1) || ( ans[g[i][j]].Y.X==1 && ans[g[i][j]].Y.Y!=i ))
	    {
	      flag=1;
	      break;
	    }
      if(!flag)
	{
	  printf("YES\n%i",i);
	  return 0;
	}
    }
  printf("NO");
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[n][2],color[n],hash[n+1]={0};
    for(int i=0;i<n-1;i++)
    cin >> a[i][0] >> a[i][1];

    for(int i=0;i<n;i++)
        cin >> color[i];
        int p=0;
    for(int i=0;i<n-1;i++)
    {
        if(color[a[i][0]]!=color[a[i][1]])
        {
            p++;
            hash[a[i][0]]++;
            hash[a[i][1]]++;
        }
    }

    for(int i=1;i<=n;i++)
    {
        if(hash[i]==p)
        {
            cout<<"YES"<<endl<<i;
            return 0;
        }
    }

    cout<<"NO";
  	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int h[100010];

int main()
{
    int n;
    cin >> n;
    int a[n][2],color[n];
    for(int i=0;i<n-1;i++)
    cin >> a[i][0] >> a[i][1];

    for(int i=1;i<=n;i++)
        cin >> color[i];
        int p=0;
    for(int i=0;i<n-1;i++)
    {
        if(color[a[i][0]]!=color[a[i][1]])
        {
            p++;
            h[a[i][0]]++;
            h[a[i][1]]++;
        }
    }

    for(int i=1;i<=n;i++)
    {
        if(h[i]==p)
        {
            cout<<"YES"<<endl<<i;
            return 0;
        }
    }

    cout<<"NO";
  	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define max_num 100100

vector<int> adj[max_num];
int curr_color;
int color[max_num];
int mark[max_num];

void ini(int n)
{
    for(int i=1;i<=n;i++)
    mark[i]=0;
}

int dfs(int x,int parent)
{
    mark[x]=1;
    if(color[x]!=curr_color)
    return -1;

    for(int j=0;j<adj[x].size();j++)
    {
        if(mark[adj[x][j]]==0&&adj[x][j]!=parent)
        {
            int p=dfs(adj[x][j],parent);
            if(p==-1)
            return -1;
        }
    }

    return 1;
}

int main()
{
     int n,x,y;
     cin >> n;

     for(int i=0;i<n-1;i++)
     {
         cin >> x >> y;
         adj[x].push_back(y);
         adj[y].push_back(x);
     }

     for(int i=1;i<=n;i++)
     cin >> color[i];

     for(int i=1;i<=n;i++)
     {
         ini(n);
         int flag=0;
        for(int j=0;j<adj[i].size();j++)
        {
            curr_color=color[adj[i][j]];
            if(dfs(adj[i][j],i)==-1)
              flag=1;
        }
        if(flag==0)
        {
            cout<<"YES"<<endl<<i;
            return 0;
        }
     }

     cout<<"NO";

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int visited[100005],c[100005];
list<int> adj[100005];

bool dfs(int v, int cl)
{
    //cout<<v<<" "<<cl<<endl;
    list<int>::iterator it;
//cout<<cl<<c[v]<<v<<"##########"<<endl;
    visited[v] = 1;
    if(c[v]!=cl)
       {

           return 0;
       }

    for(it = adj[v].begin(); it!=adj[v].end(); it++)
    {
        if(visited[*it]==0)
        {
            visited[*it]=1;
            if(dfs(*it,cl)==0)
                return 0;
        }
    }
    return 1;
}

int main()
{

    int i,n,u[100005],v[100005],v1=-1,v2=-1,flag1=1,flag2=1;
    list<int>::iterator it;

    cin>>n;
    for(i=1;i<=n-1;i++)
    {
        cin>>u[i]>>v[i];
        adj[u[i]].push_back(v[i]);
        adj[v[i]].push_back(u[i]);
    }

    for(i=1;i<=n;i++)
        cin>>c[i];

    for(i=1;i<=n-1;i++)
    {
        if(c[u[i]] != c[v[i]])
        {
            v1 = u[i]; v2 = v[i];
            break;
        }
    }
    //cout<<v1<<" "<<v2<<endl;
    memset(visited,0,sizeof(visited));
    if(v1!=-1)
    for(it = adj[v1].begin(); it!=adj[v1].end(); it++)
    {
        visited[v1]=1;
        //cout<<*it<<" * "<<c[*it]<<endl;
        if(dfs(*it,c[*it])==0)
        {
            flag1 = 0; break;
        }
    }

//cout<<"*"<<endl;
    memset(visited,0,sizeof(visited));
    if(v2!=-1)
    for(it = adj[v2].begin(); it!=adj[v2].end(); it++)
    {
        visited[v2] = 1;
        if(dfs(*it,c[*it])==0)
        {
            flag2 = 0; break;
        }

    }

    if(v1==-1 || v2==-1)
        cout<<"YES"<<endl<<"1"<<endl;

    else if(flag1==0 && flag2==0)
        cout<<"NO"<<endl;

    else if(flag1==1)
        cout<<"YES"<<endl<<v1<<endl;

    else
        cout<<"YES"<<endl<<v2<<endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int visited[100005],c[100005];
list<int> adj[100005];

bool dfs(int v, int cl)
{
    //cout<<v<<" "<<cl<<endl;
    list<int>::iterator it;
//cout<<cl<<c[v]<<v<<"##########"<<endl;
    visited[v] = 1;
    if(c[v]!=cl)
       {

           return 0;
       }

    for(it = adj[v].begin(); it!=adj[v].end(); it++)
    {
        if(visited[*it]==0)
        {
            visited[*it]=1;
            if(dfs(*it,cl)==0)
                return 0;
        }
    }
    return 1;
}

int main()
{
   // freopen("input.txt","r",stdin);
    int i,n,u[100005],v[100005],v1=-1,v2=-1,flag1=1,flag2=1;
    list<int>::iterator it;

    cin>>n;
    for(i=1;i<=n-1;i++)
    {
        cin>>u[i]>>v[i];
        adj[u[i]].push_back(v[i]);
        adj[v[i]].push_back(u[i]);
    }

    for(i=1;i<=n;i++)
        cin>>c[i];

    for(i=1;i<=n-1;i++)
    {
        if(c[u[i]] != c[v[i]])
        {
            v1 = u[i]; v2 = v[i];
            break;
        }
    }
    //cout<<v1<<" "<<v2<<endl;
    memset(visited,0,sizeof(visited));
    for(it = adj[v1].begin(); it!=adj[v1].end(); it++)
    {
        visited[v1]=1;
        //cout<<*it<<" * "<<c[*it]<<endl;
        if(dfs(*it,c[*it])==0)
        {
            flag1 = 0; break;
        }
    }

//cout<<"*"<<endl;
    memset(visited,0,sizeof(visited));
    for(it = adj[v2].begin(); it!=adj[v2].end(); it++)
    {
        visited[v2] = 1;
        if(dfs(*it,c[*it])==0)
        {
            flag2 = 0; break;
        }

    }

    if(v1==-1 && v2==-1)
        cout<<"YES"<<endl<<"1"<<endl;

    else if(flag1==0 && flag2==0)
        cout<<"NO"<<endl;

    else if(flag1==1)
        cout<<"YES"<<endl<<v1<<endl;

    else
        cout<<"YES"<<endl<<v2<<endl;

    return 0;
}