/*#include <assert.h>
#include <map>
#include <limits>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <string>
#include <cstring>
#include <set>
#include <sstream>
#include <algorithm>
#include <utility>
#include <ctime>
#include <stack>
using namespace std;
const long long INF = 1000000000;
const double eps = 0.00000000001;
bool can(int speed,int ltime, int time, int x){
	if (((x + 0.0) / speed) <= time && ((x + 0.0) / speed) >= ltime){
			return true;
		}
		else
		return false;
}
int main(){
	int a, b, x;
	cin >> a >> b >> x;
	double res1 = 10010.0;
	double res2 = 10010.0;
	int time1 = 0;
	int time2 = 0;
	int it1 = 0;
	int it2 = 0;
	double l = 0.0;
	double r = 1000.0;
	int ltime1 = 0;
	int ltime2 = 0;
	while (res1 - 1000>eps && time1<=100){
		if (it1 != 0){
			ltime1 += time1;
		}
		if (it1 % 2 == 0){
			time1 += a;
		}
		else{
			time1 += b;
		}
		++it1;
		bool f1 = false;
		while (r - l > eps){
			double m = (l + r) / 2;
			if (can(m, ltime1, time1, x)){
				r = m;
				f1 = true;
			}
			else{
				l = m;
			}
		}
		if (f1){
			res1 = (l + r) / 2;
		}

	}
	l = 0.0;
	r = 1000.0;
	while (res2- 1000>eps && time2<=100){
		if (it2 != 0){
			ltime2 += time2;
		}
		if (it2 % 2 == 0){
			time2 += b;
		}
		else{
			time2 += a;
		}
		++it2;
		bool f2 = false;
		while (r - l > eps){
			double m = (l + r) / 2;
			if (can(m, ltime2, time2, x)){
				r = m;
				f2 = true;
			}
			else{
				l = m;
			}
		}
		if (f2){
			res2 = (l + r) / 2;
		}
	}
	cout.setf(ios::fixed);

	if (res1 > 1000){
		res1 = 0;
	}
	if (res2 > 1000){
		res2 = 0;
	}
	if (res1 < res2){
		cout.precision(10);
		cout << res2;
	}
	else{
		cout.precision(10);
		cout << res1;
	}
	return 0;
	/*int a, b, x;
	cin >> a >> b >> x;
	double res1 = 10010.0;
	double res2 = 10010.0;
	int time1 = 0;
	int time2 = 0;
	int it1 = 0;
	int it2 = 0;
	while (res1 > 1000){
		if (it1 % 2 == 0){
			time1 += a;
		}
		else{
			time1 += b;
		}
		++it1;
		res1 = (x + 0.0) / time1;
	}
	while (res2 > 1000){
		if (it2 % 2 == 0){
			time2 += b;
		}
		else{
			time2 += a;
		}
		++it2;
		res2 = (x + 0.0) / time2;
	}
	cout.setf(ios::fixed);

	if (res1 > res2){
		cout.precision(10);
		cout << res1;
	}
	else{
		cout.precision(10);
		cout << res2;
	}
	return 0;*/
//}
#include <assert.h>
#include <map>
#include <limits>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <string>
#include <cstring>
#include <set>
#include <sstream>
#include <algorithm>
#include <utility>
#include <ctime>
#include <stack>
using namespace std;
const long long INF = 1000000000;
const double eps = 0.000000001;

void dfs(int s, vector<char>& used, vector<vector<int>>& gr, vector <int>c, int pred, const int start, bool &can){

	if (used[s] != 0){
		return ;
	}
	++used[s];
	if (pred != 0 && pred != start){
		if (c[s - 1] != c[pred - 1]){
			can = false;
			//return;
		}
	}
	for (int i = 0; i < gr[s].size(); ++i){

		dfs(gr[s][i], used, gr, c,s,start,can);

	}
}
int main(){
	int n, m,z,u,v;
	cin >> n;
	vector <int> c;
	vector <vector <int> > gr(n+13);
	for (int i = 1; i < n; ++i){
		cin >> u >> v;
		gr[v].push_back(u);
		gr[u].push_back(v);
	}
	vector <char> used(n + 13);
	for (int i = 0; i < n; ++i){
		cin >> z;
		c.push_back(z);
	}
	pair <int, int> diff;
	bool IsSame = true;
	for (int i = 1; i < n; ++i){
		for (int j = 0; j < gr[i].size(); ++j){
			if (c[i - 1] != c[gr[i][j] - 1]){
				IsSame = false;
				diff.first = i;
				diff.second = gr[i][j];
				break;
			}
		}
		if (!IsSame)break;
	}
	if (IsSame){
		cout << "YES" << endl;
		cout << 1;
		return 0;
	}

	bool can1 = true;
	bool can2 = true;
	IsSame = false;
	vector <char> used1(n + 13);
	vector <char> used2(n + 13);
	dfs(diff.first, used1, gr, c, 0, diff.first, can1);
	dfs(diff.second, used2, gr, c, 0, diff.second, can2);
	if (can1||can2){
		cout << "YES"<<endl;
		if (can1)cout << diff.first;
		else cout << diff.second;
		return 0;
	}
	cout << "NO";

	return 0;
}
/*
4
1 2
2 3
3 4
1 2 1 2
*/


#include <assert.h>
#include <map>
#include <limits>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <string>
#include <cstring>
#include <set>
#include <sstream>
#include <algorithm>
#include <utility>
#include <ctime>
#include <stack>
using namespace std;
const long long INF = 1000000000;
const double eps = 0.000000001;
void dfs(int s, vector<char>& used, vector<vector<int>> gr, vector <int>c,int pred,const int start,bool &can){
	if (used[s] != 0){
		return ;
	}
	++used[s];
	if (pred != 0 && pred != start){
		if (c[s - 1] != c[pred - 1]){
			can = false;
			//return;
		}
	}
	for (int i = 0; i < gr[s].size(); ++i){

		dfs(kst,gr[s][i], used, gr, c,s,start,can);

	}
}
int main(){
	int n, m,z,u,v;
	cin >> n;
	vector <vector<int> > gr(n + 13);
	vector <int> c;
	for (int i = 1; i < n; ++i){
		cin >> u >> v;
		gr[v].push_back(u);
		gr[u].push_back(v);
	}
	vector <char> used(n + 13, 0);
	for (int i = 0; i < n; ++i){
		cin >> z;
		c.push_back(z);
	}
	pair <int, int> diff;
	bool IsSame = true;
	for (int i = 1; i < n; ++i){
		for (int j = 0; j < gr[i].size(); ++j){
			if (c[i - 1] != c[gr[i][j] - 1]){
				IsSame = false;
				diff.first = i;
				diff.second = gr[i][j];
				break;
			}
		}
		if (!IsSame)break;
	}
	if (IsSame){
		cout << "YES" << endl;
		cout << 1;
		return 0;
	}

	bool can1 = true;
	bool can2 = true;
	IsSame = false;
	vector <char> used1(n + 13, 0);
	vector <char> used2(n + 13, 0);
	dfs(diff.first, used1, gr, c, 0, diff.first, can1);
	dfs(diff.second, used2, gr, c, 0, diff.second, can2);
	if (can1||can2){
		cout << "YES"<<endl;
		if (can1)cout << diff.first;
		else cout << diff.second;
		return 0;
	}
	cout << "NO";

	return 0;
}


#include <assert.h>
#include <map>
#include <limits>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <string>
#include <cstring>
#include <set>
#include <sstream>
#include <algorithm>
#include <utility>
#include <ctime>
#include <stack>
using namespace std;
const long long INF = 1000000000;
const double eps = 0.000000001;
vector <vector <int> > gr(100013);
vector <char> used1(100013);
vector <char> used2(100013);
void dfs1(int s, vector <int>c, int pred, const int start, bool &can){

	if (used1[s] != 0){
		return;
	}
	++used1[s];
	if (pred != 0 && pred != start){
		if (c[s - 1] != c[pred - 1]){
			can = false;
			//return;
		}
	}
	for (int i = 0; i < gr[s].size(); ++i){

		dfs1(gr[s][i], c, s, start, can);

	}
}
void dfs2(int s, vector <int>c, int pred, const int start, bool &can){

	if (used2[s] != 0){
		return;
	}
	++used2[s];
	if (pred != 0 && pred != start){
		if (c[s - 1] != c[pred - 1]){
			can = false;
			//return;
		}
	}
	for (int i = 0; i < gr[s].size(); ++i){

		dfs2(gr[s][i], c, s, start, can);

	}
}
int main(){
	int n, m, z, u, v;
	cin >> n;
	vector <int> c;

	for (int i = 1; i < n; ++i){
		cin >> u >> v;
		gr[v].push_back(u);
		gr[u].push_back(v);
	}
	vector <char> used(n + 13);
	for (int i = 0; i < n; ++i){
		cin >> z;
		c.push_back(z);
	}
	pair <int, int> diff;
	bool IsSame = true;
	for (int i = 1; i < n; ++i){
		for (int j = 0; j < gr[i].size(); ++j){
			if (c[i - 1] != c[gr[i][j] - 1]){
				IsSame = false;
				diff.first = i;
				diff.second = gr[i][j];
				break;
			}
		}
		if (!IsSame)break;
	}
	if (IsSame){
		cout << "YES" << endl;
		cout << 1;
		return 0;
	}

	bool can1 = true;
	bool can2 = true;
	IsSame = false;

	dfs1(diff.first,  c, 0, diff.first, can1);
	dfs2(diff.second,  c, 0, diff.second, can2);
	if (can1 || can2){
		cout << "YES" << endl;
		if (can1)cout << diff.first;
		else cout << diff.second;
		return 0;
	}
	cout << "NO";

	return 0;
}


/*#include <assert.h>
#include <map>
#include <limits>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <string>
#include <cstring>
#include <set>
#include <sstream>
#include <algorithm>
#include <utility>
#include <ctime>
#include <stack>
using namespace std;
const long long INF = 1000000000;
const double eps = 0.00000000001;
bool can(int speed,int ltime, int time, int x){
	if (((x + 0.0) / speed) <= time && ((x + 0.0) / speed) >= ltime){
			return true;
		}
		else
		return false;
}
int main(){
	int a, b, x;
	cin >> a >> b >> x;
	double res1 = 10010.0;
	double res2 = 10010.0;
	int time1 = 0;
	int time2 = 0;
	int it1 = 0;
	int it2 = 0;
	double l = 0.0;
	double r = 1000.0;
	int ltime1 = 0;
	int ltime2 = 0;
	while (res1 - 1000>eps && time1<=100){
		if (it1 != 0){
			ltime1 += time1;
		}
		if (it1 % 2 == 0){
			time1 += a;
		}
		else{
			time1 += b;
		}
		++it1;
		bool f1 = false;
		while (r - l > eps){
			double m = (l + r) / 2;
			if (can(m, ltime1, time1, x)){
				r = m;
				f1 = true;
			}
			else{
				l = m;
			}
		}
		if (f1){
			res1 = (l + r) / 2;
		}

	}
	l = 0.0;
	r = 1000.0;
	while (res2- 1000>eps && time2<=100){
		if (it2 != 0){
			ltime2 += time2;
		}
		if (it2 % 2 == 0){
			time2 += b;
		}
		else{
			time2 += a;
		}
		++it2;
		bool f2 = false;
		while (r - l > eps){
			double m = (l + r) / 2;
			if (can(m, ltime2, time2, x)){
				r = m;
				f2 = true;
			}
			else{
				l = m;
			}
		}
		if (f2){
			res2 = (l + r) / 2;
		}
	}
	cout.setf(ios::fixed);

	if (res1 > 1000){
		res1 = 0;
	}
	if (res2 > 1000){
		res2 = 0;
	}
	if (res1 < res2){
		cout.precision(10);
		cout << res2;
	}
	else{
		cout.precision(10);
		cout << res1;
	}
	return 0;
	/*int a, b, x;
	cin >> a >> b >> x;
	double res1 = 10010.0;
	double res2 = 10010.0;
	int time1 = 0;
	int time2 = 0;
	int it1 = 0;
	int it2 = 0;
	while (res1 > 1000){
		if (it1 % 2 == 0){
			time1 += a;
		}
		else{
			time1 += b;
		}
		++it1;
		res1 = (x + 0.0) / time1;
	}
	while (res2 > 1000){
		if (it2 % 2 == 0){
			time2 += b;
		}
		else{
			time2 += a;
		}
		++it2;
		res2 = (x + 0.0) / time2;
	}
	cout.setf(ios::fixed);

	if (res1 > res2){
		cout.precision(10);
		cout << res1;
	}
	else{
		cout.precision(10);
		cout << res2;
	}
	return 0;*/
//}
#include <assert.h>
#include <map>
#include <limits>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <string>
#include <cstring>
#include <set>
#include <sstream>
#include <algorithm>
#include <utility>
#include <ctime>
#include <stack>
using namespace std;
const long long INF = 1000000000;
const double eps = 0.000000001;
void dfs(int s, vector<char>& used, vector<vector<int>> gr, vector <int>c,int pred,const int start,bool &can){
	if (used[s] != 0){
		return ;
	}
	++used[s];
	if (pred != 0 && pred != start){
		if (c[s - 1] != c[pred - 1]){
			can = false;
			return;
		}
	}
	for (int i = 0; i < gr[s].size(); ++i){

		dfs(gr[s][i], used, gr, c,s,start,can);

	}

}
int main(){
	int n, m,z,u,v;
	cin >> n;
	vector <vector<int> > gr(n + 13);
	vector <int> c;
	for (int i = 1; i < n; ++i){
		cin >> u >> v;
		gr[v].push_back(u);
		gr[u].push_back(v);
	}
	vector <char> used(n + 13, 0);
	for (int i = 0; i < n; ++i){
		cin >> z;
		c.push_back(z);
	}
	for (int i = 1; i <= n; ++i){
		bool can = true;
		vector <char> used(n + 13, 0);
		dfs(i, used, gr, c, 0, i, can);
		if (can){
			cout << "YES"<<endl;
			cout << i;
			return 0;
		}
	}
	cout << "NO";

	return 0;
}
/*
4
1 2
2 3
3 4
1 2 1 2
*/


/*#include <assert.h>
#include <map>
#include <limits>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <string>
#include <cstring>
#include <set>
#include <sstream>
#include <algorithm>
#include <utility>
#include <ctime>
#include <stack>
using namespace std;
const long long INF = 1000000000;
const double eps = 0.00000000001;
bool can(int speed,int ltime, int time, int x){
	if (((x + 0.0) / speed) <= time && ((x + 0.0) / speed) >= ltime){
			return true;
		}
		else
		return false;
}
int main(){
	int a, b, x;
	cin >> a >> b >> x;
	double res1 = 10010.0;
	double res2 = 10010.0;
	int time1 = 0;
	int time2 = 0;
	int it1 = 0;
	int it2 = 0;
	double l = 0.0;
	double r = 1000.0;
	int ltime1 = 0;
	int ltime2 = 0;
	while (res1 - 1000>eps && time1<=100){
		if (it1 != 0){
			ltime1 += time1;
		}
		if (it1 % 2 == 0){
			time1 += a;
		}
		else{
			time1 += b;
		}
		++it1;
		bool f1 = false;
		while (r - l > eps){
			double m = (l + r) / 2;
			if (can(m, ltime1, time1, x)){
				r = m;
				f1 = true;
			}
			else{
				l = m;
			}
		}
		if (f1){
			res1 = (l + r) / 2;
		}

	}
	l = 0.0;
	r = 1000.0;
	while (res2- 1000>eps && time2<=100){
		if (it2 != 0){
			ltime2 += time2;
		}
		if (it2 % 2 == 0){
			time2 += b;
		}
		else{
			time2 += a;
		}
		++it2;
		bool f2 = false;
		while (r - l > eps){
			double m = (l + r) / 2;
			if (can(m, ltime2, time2, x)){
				r = m;
				f2 = true;
			}
			else{
				l = m;
			}
		}
		if (f2){
			res2 = (l + r) / 2;
		}
	}
	cout.setf(ios::fixed);

	if (res1 > 1000){
		res1 = 0;
	}
	if (res2 > 1000){
		res2 = 0;
	}
	if (res1 < res2){
		cout.precision(10);
		cout << res2;
	}
	else{
		cout.precision(10);
		cout << res1;
	}
	return 0;
	/*int a, b, x;
	cin >> a >> b >> x;
	double res1 = 10010.0;
	double res2 = 10010.0;
	int time1 = 0;
	int time2 = 0;
	int it1 = 0;
	int it2 = 0;
	while (res1 > 1000){
		if (it1 % 2 == 0){
			time1 += a;
		}
		else{
			time1 += b;
		}
		++it1;
		res1 = (x + 0.0) / time1;
	}
	while (res2 > 1000){
		if (it2 % 2 == 0){
			time2 += b;
		}
		else{
			time2 += a;
		}
		++it2;
		res2 = (x + 0.0) / time2;
	}
	cout.setf(ios::fixed);

	if (res1 > res2){
		cout.precision(10);
		cout << res1;
	}
	else{
		cout.precision(10);
		cout << res2;
	}
	return 0;*/
//}
#include <assert.h>
#include <map>
#include <limits>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <string>
#include <cstring>
#include <set>
#include <sstream>
#include <algorithm>
#include <utility>
#include <ctime>
#include <stack>
using namespace std;
const long long INF = 1000000000;
const double eps = 0.000000001;
void dfs(int s, vector<char>& used, vector<vector<int>> gr, vector <int>c,int pred,const int start,bool &can){
	if (used[s] != 0){
		return ;
	}
	++used[s];
	if (pred != 0 && pred != start){
		if (c[s - 1] != c[pred - 1]){
			can = false;
			return;
		}
	}
	for (int i = 0; i < gr[s].size(); ++i){

		dfs(gr[s][i], used, gr, c,s,start,can);

	}

}
int main(){
	int n, m,z,u,v;
	cin >> n;
	vector <vector<int> > gr(n + 13);
	vector <int> c;
	for (int i = 1; i < n; ++i){
		cin >> u >> v;
		gr[v].push_back(u);
		gr[u].push_back(v);
	}
	vector <char> used(n + 13, 0);
	for (int i = 0; i < n; ++i){
		cin >> z;
		c.push_back(z);
	}
	pair <int, int> diff;
	bool IsSame = true;
	for (int i = 1; i < n; ++i){
		for (int j = 0; j < gr[i].size(); ++j){
			if (c[i - 1] != c[gr[i][j] - 1]){
				IsSame = false;
				diff.first = i;
				diff.second = gr[i][j];
				break;
			}
		}
		if (!IsSame)break;
	}
	if (IsSame){
		cout << "YES" << endl;
		cout << 1;
		return 0;
	}

	bool can1 = true;
	bool can2 = true;
	IsSame = false;
	vector <char> used1(n + 13, 0);
	vector <char> used2(n + 13, 0);
	dfs(diff.first, used1, gr, c, 0, diff.first, can1);
	dfs(diff.second, used2, gr, c, 0, diff.second, can2);
	if (can1||can2){
		cout << "YES"<<endl;
		if (can1)cout << diff.first;
		else cout << diff.second;
		return 0;
	}
	cout << "NO";

	return 0;
}
/*
4
1 2
2 3
3 4
1 2 1 2
*/


#include <assert.h>
#include <map>
#include <limits>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <string>
#include <cstring>
#include <set>
#include <sstream>
#include <algorithm>
#include <utility>
#include <ctime>
#include <stack>
using namespace std;
const long long INF = 1000000000;
const double eps = 0.000000001;
void dfs(int s, vector<char>& used, vector<vector<int>> gr, vector <int>c,int pred,const int start,bool &can){

	if (used[s] != 0){
		return ;
	}
	++used[s];
	if (pred != 0 && pred != start){
		if (c[s - 1] != c[pred - 1]){
			can = false;
			//return;
		}
	}
	for (int i = 0; i < gr[s].size(); ++i){

		dfs(gr[s][i], used, gr, c,s,start,can);

	}
}
int main(){
	int n, m,z,u,v;
	cin >> n;
	vector <vector<int> > gr(n + 13);
	vector <int> c;
	for (int i = 1; i < n; ++i){
		cin >> u >> v;
		gr[v].push_back(u);
		gr[u].push_back(v);
	}
	vector <char> used(n + 13);
	for (int i = 0; i < n; ++i){
		cin >> z;
		c.push_back(z);
	}
	pair <int, int> diff;
	bool IsSame = true;
	for (int i = 1; i < n; ++i){
		for (int j = 0; j < gr[i].size(); ++j){
			if (c[i - 1] != c[gr[i][j] - 1]){
				IsSame = false;
				diff.first = i;
				diff.second = gr[i][j];
				break;
			}
		}
		if (!IsSame)break;
	}
	if (IsSame){
		cout << "YES" << endl;
		cout << 1;
		return 0;
	}

	bool can1 = true;
	bool can2 = true;
	IsSame = false;
	vector <char> used1(n + 13);
	vector <char> used2(n + 13);
	dfs(diff.first, used1, gr, c, 0, diff.first, can1);
	dfs(diff.second, used2, gr, c, 0, diff.second, can2);
	if (can1||can2){
		cout << "YES"<<endl;
		if (can1)cout << diff.first;
		else cout << diff.second;
		return 0;
	}
	cout << "NO";

	return 0;
}
/*
4
1 2
2 3
3 4
1 2 1 2
*/


/*#include <assert.h>
#include <map>
#include <limits>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <string>
#include <cstring>
#include <set>
#include <sstream>
#include <algorithm>
#include <utility>
#include <ctime>
#include <stack>
using namespace std;
const long long INF = 1000000000;
const double eps = 0.00000000001;
bool can(int speed,int ltime, int time, int x){
	if (((x + 0.0) / speed) <= time && ((x + 0.0) / speed) >= ltime){
			return true;
		}
		else
		return false;
}
int main(){
	int a, b, x;
	cin >> a >> b >> x;
	double res1 = 10010.0;
	double res2 = 10010.0;
	int time1 = 0;
	int time2 = 0;
	int it1 = 0;
	int it2 = 0;
	double l = 0.0;
	double r = 1000.0;
	int ltime1 = 0;
	int ltime2 = 0;
	while (res1 - 1000>eps && time1<=100){
		if (it1 != 0){
			ltime1 += time1;
		}
		if (it1 % 2 == 0){
			time1 += a;
		}
		else{
			time1 += b;
		}
		++it1;
		bool f1 = false;
		while (r - l > eps){
			double m = (l + r) / 2;
			if (can(m, ltime1, time1, x)){
				r = m;
				f1 = true;
			}
			else{
				l = m;
			}
		}
		if (f1){
			res1 = (l + r) / 2;
		}

	}
	l = 0.0;
	r = 1000.0;
	while (res2- 1000>eps && time2<=100){
		if (it2 != 0){
			ltime2 += time2;
		}
		if (it2 % 2 == 0){
			time2 += b;
		}
		else{
			time2 += a;
		}
		++it2;
		bool f2 = false;
		while (r - l > eps){
			double m = (l + r) / 2;
			if (can(m, ltime2, time2, x)){
				r = m;
				f2 = true;
			}
			else{
				l = m;
			}
		}
		if (f2){
			res2 = (l + r) / 2;
		}
	}
	cout.setf(ios::fixed);

	if (res1 > 1000){
		res1 = 0;
	}
	if (res2 > 1000){
		res2 = 0;
	}
	if (res1 < res2){
		cout.precision(10);
		cout << res2;
	}
	else{
		cout.precision(10);
		cout << res1;
	}
	return 0;
	/*int a, b, x;
	cin >> a >> b >> x;
	double res1 = 10010.0;
	double res2 = 10010.0;
	int time1 = 0;
	int time2 = 0;
	int it1 = 0;
	int it2 = 0;
	while (res1 > 1000){
		if (it1 % 2 == 0){
			time1 += a;
		}
		else{
			time1 += b;
		}
		++it1;
		res1 = (x + 0.0) / time1;
	}
	while (res2 > 1000){
		if (it2 % 2 == 0){
			time2 += b;
		}
		else{
			time2 += a;
		}
		++it2;
		res2 = (x + 0.0) / time2;
	}
	cout.setf(ios::fixed);

	if (res1 > res2){
		cout.precision(10);
		cout << res1;
	}
	else{
		cout.precision(10);
		cout << res2;
	}
	return 0;*/
//}
#include <assert.h>
#include <map>
#include <limits>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <string>
#include <cstring>
#include <set>
#include <sstream>
#include <algorithm>
#include <utility>
#include <ctime>
#include <stack>
using namespace std;
const long long INF = 1000000000;
const double eps = 0.000000001;
void dfs(int s, vector<char>& used, vector<vector<int>> gr, vector <int>c,int pred,const int start,bool &can){
	if (used[s] != 0){
		return ;
	}
	++used[s];
	if (pred != 0 && pred != start){
		if (c[s - 1] != c[pred - 1]){
			can = false;
			return;
		}
	}
	for (int i = 0; i < gr[s].size(); ++i){

		dfs(gr[s][i], used, gr, c,s,start,can);

	}

}
int main(){
	int n, m,z,u,v;
	cin >> n;
	vector <vector<int> > gr(n + 13);
	vector <int> c;
	for (int i = 1; i < n; ++i){
		cin >> u >> v;
		gr[v].push_back(u);
		gr[u].push_back(v);
	}
	vector <char> used(n + 13, 0);
	for (int i = 0; i < n; ++i){
		cin >> z;
		c.push_back(z);
	}
	int l = 1, r = n;
	bool IsSame = true;
	for (int i = 2; i <= n; ++i){
		bool can = true;
		vector <char> used(n + 13, 0);
		if (c[i] != c[i - 1]){
			IsSame = false;
			dfs(i, used, gr, c, 0, i, can);
		}
		if (can){
			cout << "YES"<<endl;
			cout << i;
			return 0;
		}
	}
	if (IsSame){
		cout << "YES"<<endl;
		cout << 1;
	}
	cout << "NO";

	return 0;
}
/*
4
1 2
2 3
3 4
1 2 1 2
*/


# include <iostream>
# include <sstream>
# include <cstdio>
# include <cstdlib>
# include <algorithm>
# include <string>
# include <cstring>
# include <cmath>
# include <stack>
# include <queue>
# include <vector>
# include <list>
# include <map>
# include <set>
# include <deque>
# include <iterator>
# include <functional>
# include <bitset>
# include <climits>
# include <ctime>
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define odd(x) (x&1)
typedef long long ll;
typedef long double ld;
const ll oo = 2 * 1000 * 1000 * 1000;
const int _cnt = 1000 * 1000;
const int _p = 1000 * 1000 * 1000 + 7;
ll o(ll x) { return x%_p; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a*b / gcd(a, b); }
using namespace std;

void file_put() {
	freopen("filename.in", "r", stdin);
	freopen("filename.out", "w", stdout);
}

int n, a[100005], x[100005], y[100005], x0[100005], Y[100005], total = 0, ans;
int home[100005], c[100005], cnt[100005], p, q;
int h[100005], degree[100005];

int _find(int x) {
	if (home[x] == x) return x;
	return home[x] = _find(home[x]);
}

int main() {
	//file_put();

	scanf("%d", &n);
	for (int i = 1; i <= n; i++) home[i] = i;
	for (int i = 1; i <= n; i++) cnt[i] = 1;
	for (int i = 1; i <= n - 1; i++) scanf("%d%d", &x[i], &y[i]);
	for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
	ans = n;
	for (int i = 1; i <= n - 1; i++) {
		if (c[x[i]] == c[y[i]]) {
			p = _find(x[i]);
			q = _find(y[i]);
			ans--;
			home[p] = q;
			cnt[q] += cnt[p];
			cnt[p] = 0;
			continue;
		}
		x0[++total] = x[i];
		Y[total] = y[i];
	}
	for (int i=1; i<=n; i++)
		if (home[i] == i) {
			h[++h[0]] = i;
		}
	for (int i = 1; i <= total; i++) {
		degree[_find(x0[i])]++;
		degree[_find(Y[i])]++;
	}
	for (int i=1; i<=h[0]; i++)
		if (cnt[h[i]] == 1 && degree[h[i]] == h[0] - 1) {
			printf("YES\n");
			printf("%d\n", h[i]);
			return 0;
		}
	printf("NO\n");

	return 0;
}


# include <iostream>
# include <sstream>
# include <cstdio>
# include <cstdlib>
# include <algorithm>
# include <string>
# include <cstring>
# include <cmath>
# include <stack>
# include <queue>
# include <vector>
# include <list>
# include <map>
# include <set>
# include <deque>
# include <iterator>
# include <functional>
# include <bitset>
# include <climits>
# include <ctime>
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define odd(x) (x&1)
typedef long long ll;
typedef long double ld;
const ll oo = 2 * 1000 * 1000 * 1000;
const int _cnt = 1000 * 1000;
const int _p = 1000 * 1000 * 1000 + 7;
ll o(ll x) { return x%_p; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a*b / gcd(a, b); }
using namespace std;

void file_put() {
	freopen("filename.in", "r", stdin);
	freopen("filename.out", "w", stdout);
}

int n, a[100005], x[100005], y[100005], x0[100005], Y[100005], total = 0, ans;
int home[100005], c[100005], cnt[100005], p, q;
int h[100005], degree[100005];

int _find(int x) {
	if (home[x] == x) return x;
	return home[x] = _find(home[x]);
}

int main() {
	//file_put();

	scanf("%d", &n);
	for (int i = 1; i <= n; i++) home[i] = i;
	for (int i = 1; i <= n; i++) cnt[i] = 1;
	for (int i = 1; i <= n - 1; i++) scanf("%d%d", &x[i], &y[i]);
	for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
	ans = n;
	for (int i = 1; i <= n - 1; i++) {
		if (c[x[i]] == c[y[i]]) {
			p = _find(x[i]);
			q = _find(y[i]);
			ans--;
			home[p] = q;
			cnt[q] += cnt[p];
			cnt[p] = 0;
			continue;
		}
		x0[++total] = x[i];
		Y[total] = y[i];
	}
	for (int i=1; i<=n; i++)
		if (home[i] == i) {
			h[++h[0]] = i;
		}
	for (int i = 1; i <= total; i++) {
		degree[_find(x0[i])]++;
		degree[_find(Y[i])]++;
	}
	if (h[0] == 1) {
		printf("YES\n");
		printf("%d\n", 1);
		return 0;
	}
	for (int i=1; i<=h[0]; i++)
		if (cnt[h[i]] == 1 && degree[h[i]] == h[0] - 1) {
			printf("YES\n");
			printf("%d\n", h[i]);
			return 0;
		}
	int root[100005];
	root[0] = 0;
	for (int i = 1; i <= h[0]; i++)
		if (degree[h[i]] == h[0] - 1)
			root[++root[0]] = h[i];
	if (root[0] == 0 || root[0]>1) {
		printf("NO\n");
		return 0;
	}
	int r = root[1], a[100005];
	root[0] = a[0] = 0;
	for (int i = 1; i <= n; i++)
		if (_find(i) == r)
			root[++root[0]] = i;
	for (int i = 1; i <= total; i++) {
		if (_find(x0[i]) == r) {
			a[++a[0]] = x0[i];
		}
		if (_find(Y[i]) == r) {
			a[++a[0]] = Y[i];
		}
	}
	if (a[0] > 1) {
		printf("NO\n");
		return 0;
	}
	if (a[0] == 1) {
		printf("YES\n");
		printf("%d\n", a[1]);
		return 0;
	}
	printf("NO\n");

	return 0;
}


# include <iostream>
# include <sstream>
# include <cstdio>
# include <cstdlib>
# include <algorithm>
# include <string>
# include <cstring>
# include <cmath>
# include <stack>
# include <queue>
# include <vector>
# include <list>
# include <map>
# include <set>
# include <deque>
# include <iterator>
# include <functional>
# include <bitset>
# include <climits>
# include <ctime>
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define odd(x) (x&1)
typedef long long ll;
typedef long double ld;
const ll oo = 2 * 1000 * 1000 * 1000;
const int _cnt = 1000 * 1000;
const int _p = 1000 * 1000 * 1000 + 7;
ll o(ll x) { return x%_p; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a*b / gcd(a, b); }
using namespace std;

void file_put() {
	freopen("filename.in", "r", stdin);
	freopen("filename.out", "w", stdout);
}

int n, a[100005], x[100005], y[100005], x0[100005], Y[100005], total = 0, ans;
int home[100005], c[100005], cnt[100005], p, q;
int h[100005], degree[100005];

int _find(int x) {
	if (home[x] == x) return x;
	return home[x] = _find(home[x]);
}

int main() {
	//file_put();

	scanf("%d", &n);
	for (int i = 1; i <= n; i++) home[i] = i;
	for (int i = 1; i <= n; i++) cnt[i] = 1;
	for (int i = 1; i <= n - 1; i++) scanf("%d%d", &x[i], &y[i]);
	for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
	ans = n;
	for (int i = 1; i <= n - 1; i++) {
		if (c[x[i]] == c[y[i]]) {
			p = _find(x[i]);
			q = _find(y[i]);
			ans--;
			home[p] = q;
			cnt[q] += cnt[p];
			cnt[p] = 0;
			continue;
		}
		x0[++total] = x[i];
		Y[total] = y[i];
	}
	for (int i=1; i<=n; i++)
		if (home[i] == i) {
			h[++h[0]] = i;
		}
	for (int i = 1; i <= total; i++) {
		degree[_find(x0[i])]++;
		degree[_find(Y[i])]++;
	}
	if (h[0] == 1) {
		printf("YES\n");
		printf("%d\n", 1);
		return 0;
	}
	for (int i=1; i<=h[0]; i++)
		if (cnt[h[i]] == 1 && degree[h[i]] == h[0] - 1) {
			printf("YES\n");
			printf("%d\n", h[i]);
			return 0;
		}
	int root[100005];
	root[0] = 0;
	for (int i = 1; i <= h[0]; i++)
		if (degree[h[i]] == h[0] - 1)
			root[++root[0]] = h[i];
	if (root[0] == 0 ) {
		printf("NO\n");
		return 0;
	}
	int r = root[1];
	root[0] = 0;
	map <int, int> a;
	for (int i = 1; i <= n; i++)
		if (_find(i) == r)
			root[++root[0]] = i;
	for (int i = 1; i <= total; i++) {
		if (_find(x0[i]) == r) {
			a[x0[i]]++;
		}
		if (_find(Y[i]) == r) {
			a[Y[i]]++;
		}
	}
	if (a.size() > 1) {
		printf("NO\n");
		return 0;
	}
	if (a.size() == 1) {
		printf("YES\n");
		printf("%d\n", a.begin()->first);
		return 0;
	}
	printf("NO\n");

	return 0;
}


# include <iostream>
# include <sstream>
# include <cstdio>
# include <cstdlib>
# include <algorithm>
# include <string>
# include <cstring>
# include <cmath>
# include <stack>
# include <queue>
# include <vector>
# include <list>
# include <map>
# include <set>
# include <deque>
# include <iterator>
# include <functional>
# include <bitset>
# include <climits>
# include <ctime>
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define odd(x) (x&1)
typedef long long ll;
typedef long double ld;
const ll oo = 2 * 1000 * 1000 * 1000;
const int _cnt = 1000 * 1000;
const int _p = 1000 * 1000 * 1000 + 7;
ll o(ll x) { return x%_p; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a*b / gcd(a, b); }
using namespace std;

void file_put() {
	freopen("filename.in", "r", stdin);
	freopen("filename.out", "w", stdout);
}

int n, a[100005], x[100005], y[100005], x0[100005], Y[100005], total = 0, ans;
int home[100005], c[100005], cnt[100005], p, q;
int h[100005], degree[100005];

int _find(int x) {
	if (home[x] == x) return x;
	return home[x] = _find(home[x]);
}

int main() {
	//file_put();

	scanf("%d", &n);
	for (int i = 1; i <= n; i++) home[i] = i;
	for (int i = 1; i <= n; i++) cnt[i] = 1;
	for (int i = 1; i <= n - 1; i++) scanf("%d%d", &x[i], &y[i]);
	for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
	ans = n;
	for (int i = 1; i <= n - 1; i++) {
		if (c[x[i]] == c[y[i]]) {
			p = _find(x[i]);
			q = _find(y[i]);
			ans--;
			home[p] = q;
			cnt[q] += cnt[p];
			cnt[p] = 0;
			continue;
		}
		x0[++total] = x[i];
		Y[total] = y[i];
	}
	for (int i=1; i<=n; i++)
		if (home[i] == i) {
			h[++h[0]] = i;
		}
	for (int i = 1; i <= total; i++) {
		degree[_find(x0[i])]++;
		degree[_find(Y[i])]++;
	}
	if (h[0] == 1) {
		printf("YES\n");
		printf("%d\n", 1);
		return 0;
	}
	for (int i=1; i<=h[0]; i++)
		if (cnt[h[i]] == 1 && degree[h[i]] == h[0] - 1) {
			printf("YES\n");
			printf("%d\n", h[i]);
			return 0;
		}
	int root[100005];
	root[0] = 0;
	for (int i = 1; i <= h[0]; i++)
		if (degree[h[i]] == h[0] - 1)
			root[++root[0]] = h[i];
	if (root[0] == 0 ) {
		printf("NO\n");
		return 0;
	}
	int r = root[1], a[100005];
	root[0] = a[0] = 0;
	for (int i = 1; i <= n; i++)
		if (_find(i) == r)
			root[++root[0]] = i;
	for (int i = 1; i <= total; i++) {
		if (_find(x0[i]) == r) {
			a[++a[0]] = x0[i];
		}
		if (_find(Y[i]) == r) {
			a[++a[0]] = Y[i];
		}
	}
	if (a[0] > 1) {
		printf("NO\n");
		return 0;
	}
	if (a[0] == 1) {
		printf("YES\n");
		printf("%d\n", a[1]);
		return 0;
	}
	printf("NO\n");

	return 0;
}


# include <iostream>
# include <sstream>
# include <cstdio>
# include <cstdlib>
# include <algorithm>
# include <string>
# include <cstring>
# include <cmath>
# include <stack>
# include <queue>
# include <vector>
# include <list>
# include <map>
# include <set>
# include <deque>
# include <iterator>
# include <functional>
# include <bitset>
# include <climits>
# include <ctime>
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define odd(x) (x&1)
typedef long long ll;
typedef long double ld;
const ll oo = 2 * 1000 * 1000 * 1000;
const int _cnt = 1000 * 1000;
const int _p = 1000 * 1000 * 1000 + 7;
ll o(ll x) { return x%_p; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a*b / gcd(a, b); }
using namespace std;

void file_put() {
	freopen("filename.in", "r", stdin);
	freopen("filename.out", "w", stdout);
}

int n, a[100005], x[100005], y[100005], x0[100005], Y[100005], total = 0, ans;
int home[100005], c[100005], cnt[100005], p, q;
int h[100005], degree[100005];

int _find(int x) {
	if (home[x] == x) return x;
	return home[x] = _find(home[x]);
}

int main() {
	//file_put();

	scanf("%d", &n);
	for (int i = 1; i <= n; i++) home[i] = i;
	for (int i = 1; i <= n; i++) cnt[i] = 1;
	for (int i = 1; i <= n - 1; i++) scanf("%d%d", &x[i], &y[i]);
	for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
	ans = n;
	for (int i = 1; i <= n - 1; i++) {
		if (c[x[i]] == c[y[i]]) {
			p = _find(x[i]);
			q = _find(y[i]);
			ans--;
			home[p] = q;
			cnt[q] += cnt[p];
			cnt[p] = 0;
			continue;
		}
		x0[++total] = x[i];
		Y[total] = y[i];
	}
	for (int i=1; i<=n; i++)
		if (home[i] == i) {
			h[++h[0]] = i;
		}
	for (int i = 1; i <= total; i++) {
		degree[_find(x0[i])]++;
		degree[_find(Y[i])]++;
	}
	if (h[0] == 1) {
		printf("YES\n");
		printf("%d\n", 1);
		return 0;
	}
	for (int i=1; i<=h[0]; i++)
		if (cnt[h[i]] == 1 && degree[h[i]] == h[0] - 1) {
			printf("YES\n");
			printf("%d\n", h[i]);
			return 0;
		}
	int root[100005];
	root[0] = 0;
	for (int i = 1; i <= h[0]; i++)
		if (degree[h[i]] == h[0] - 1)
			root[++root[0]] = h[i];
	if (root[0] == 0 || root[0]>1) {
		printf("NO\n");
		return 0;
	}
	int r = root[1], a[100005];
	root[0] = 0;
	for (int i = 1; i <= n; i++)
		if (_find(i) == r)
			root[++root[0]] = i;
	for (int i = 1; i <= total; i++) {
		if (_find(x0[i]) == r) {
			a[++a[0]] == x0[i];
		}
		if (_find(Y[i]) == r) {
			a[++a[0]] == Y[i];
		}
	}
	if (a[0] > 1) {
		printf("NO\n");
		return 0;
	}
	if (a[0] == 1) {
		printf("YES\n");
		printf("%d\n", a[1]);
		return 0;
	}
	printf("NO\n");

	return 0;
}


#define _CRT_SECURE_NO_DEPRECATE
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<queue>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<time.h>
#include<cmath>
using namespace std;
#define x first
#define y second
#define pb push_back
#define mp make_pair
typedef long long int LL;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3fLL;
const int MAXN = 1e5 + 10;
int c[MAXN];
bool flag;
vector<int>G[MAXN];
void dfs(int u, int fa, int col){
	if (!flag){ return; }
	for (int i = 0; i < G[u].size(); i++){
		if (G[u][i] != fa){
			if (c[G[u][i]] != col){
				flag = false;
			}
			else{
				dfs(G[u][i], u, col);
			}
		}
	}
}
int solve(int x){
	flag = true;
	for (int i = 0; i < G[x].size()&&flag; i++){
		dfs(G[x][i], x, c[G[x][i]]);
	}
	if (flag){
		return x;
	}
	else{
		return -1;
	}
}
int main(){
//#ifdef kirito
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
//#endif
//	int start = clock();
	int n;
	while (~scanf("%d", &n)){
		for (int i = 0; i <= n; i++){
			G[i].clear();
		}
		for (int i = 1; i < n; i++){
			int u, v;
			scanf("%d%d", &u, &v);
			G[u].push_back(v);
			G[v].push_back(u);
		}
		for (int i = 1; i <= n; i++){
			scanf("%d", &c[i]);
		}
		int ans = -1;
		for (int i = 1; i <= n&&ans==-1; i++){
			ans=solve(i);
		}
		if (ans != -1){
			printf("YES\n%d\n", ans);
		}
		else{
			printf("NO\n");
		}
	}
//#ifdef LOCAL_TIME
//	cout << "[Finished in " << clock() - start << " ms]" << endl;
//#endif
	return 0;
}


#define _CRT_SECURE_NO_DEPRECATE
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<queue>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<time.h>
#include<cmath>
using namespace std;
#define x first
#define y second
#define pb push_back
#define mp make_pair
typedef long long int LL;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3fLL;
const int MAXN = 1e5 + 10;
int c[MAXN];
bool flag;
vector<int>G[MAXN];
void dfs(int u, int fa, int col){
	if (!flag){ return; }
	for (int i = 0; i < G[u].size(); i++){
		if (G[u][i] != fa){
			if (c[G[u][i]] != col){
				flag = false;
			}
			else{
				dfs(G[u][i], u, col);
			}
		}
	}
}
int solve(int x){
	flag = true;
	for (int i = 0; i < G[x].size()&&flag; i++){
		dfs(G[x][i], x, c[G[x][i]]);
	}
	if (flag){
		return x;
	}
	else{
		return -1;
	}
}
int main(){
//#ifdef kirito
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
//#endif
//	int start = clock();
	int n;
	while (~scanf("%d", &n)){
		for (int i = 0; i <= n; i++){
			G[i].clear();
		}
		for (int i = 1; i < n; i++){
			int u, v;
			scanf("%d%d", &u, &v);
			G[u].push_back(v);
			G[v].push_back(u);
		}
		for (int i = 1; i <= n; i++){
			scanf("%d", &c[i]);
		}
		int ans = -1; bool k = false;
		for (int i = 1; i <= n&&k==false; i++){
			for (int j = 0; j < G[i].size(); j++){
				if (c[i] != c[G[i][j]]){
					ans = solve(i);
					if (ans == -1){
						ans = solve(G[i][j]);
					}
					k = true;
					break;
				}
			}
		}
		if (ans != -1){
			printf("YES\n%d\n", ans);
		}
		else{
			printf("NO\n");
		}
	}
//#ifdef LOCAL_TIME
//	cout << "[Finished in " << clock() - start << " ms]" << endl;
//#endif
	return 0;
}


#define _CRT_SECURE_NO_DEPRECATE
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<queue>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<time.h>
#include<cmath>
using namespace std;
#define x first
#define y second
#define pb push_back
#define mp make_pair
typedef long long int LL;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3fLL;
const int MAXN = 1e5 + 10;
int c[MAXN];
bool flag;
vector<int>G[MAXN];
void dfs(int u, int fa, int col){
	if (!flag){ return; }
	for (int i = 0; i < G[u].size(); i++){
		if (G[u][i] != fa){
			if (c[G[u][i]] != col){
				flag = false;
			}
			else{
				dfs(G[u][i], u, col);
			}
		}
	}
}
int solve(int x){
	flag = true;
	for (int i = 0; i < G[x].size()&&flag; i++){
		dfs(G[x][i], x, c[G[x][i]]);
	}
	if (flag){
		return x;
	}
	else{
		return -1;
	}
}
int main(){
//#ifdef kirito
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
//#endif
//	int start = clock();
	int n;
	while (~scanf("%d", &n)){
		for (int i = 0; i <= n; i++){
			G[i].clear();
		}
		for (int i = 1; i < n; i++){
			int u, v;
			scanf("%d%d", &u, &v);
			G[u].push_back(v);
			G[v].push_back(u);
		}
		for (int i = 1; i <= n; i++){
			scanf("%d", &c[i]);
		}
		int ans = -1; bool k = false;
		for (int i = 1; i <= n&&k==false; i++){
			for (int j = 0; j < G[i].size(); j++){
				if (c[i] != c[G[i][j]]){
					ans = solve(i);
					if (ans == -1){
						ans = solve(G[i][j]);
					}
					k = true;
					break;
				}
			}
		}
		if (k == false){
			ans = 1;
		}
		if (ans != -1){
			printf("YES\n%d\n", ans);
		}
		else{
			printf("NO\n");
		}
	}
//#ifdef LOCAL_TIME
//	cout << "[Finished in " << clock() - start << " ms]" << endl;
//#endif
	return 0;
}


#include <iostream>
#include <fstream>
#include <math.h>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <string>
#include <deque>
#include <iomanip>
#include <functional>
const double PI = std::atan(1.0) * 4;
using namespace std;
#define mp make_pair
#define all(a) a.begin(),a.end()
//#pragma comment(linker, "/STACK:104857600")
//Please help!
vector<vector<int> > g;
vector<int> c;
vector<bool> vis;
vector<int> numdiff;
int numdiff2;
int num = 0, what = -1;
void dfs(int i)
{
	int j;
	vis[i] = 1;
	bool bo = true;
	for (j = 0; j < g[i].size(); j++)
	{
		if (vis[g[i][j]] == 0)
		{
			dfs(g[i][j]);
		}
		if (c[i] != c[g[i][j]])
		{
			bo = false;
			numdiff[i]++;
		}
	}
	if (bo == false)
	{
		numdiff2++;
	}
}
int main()
{
	/*ifstream in;
	ofstream out;
	in.open("input.txt");
	out.open("output.txt");*/
	int n, i, x, y, j, num;
	cin >> n;
	g.resize(n);
	vis.assign(n, 0);
	c.resize(n);
	vis.resize(n);
	numdiff.assign(n, 0);
	numdiff2 = 0;
	for (i = 0; i < n - 1; i++)
	{
		cin >> x >> y;
		x--, y--;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	for (i = 0; i < n; i++) cin >> c[i];
	dfs(0);
	bool bo, bigbo = false;
	if (numdiff2 == 0) cout << "YES\n" << 1;
	else
	{
		for (i = 0; i < n && !bigbo; i++)
		{
			bo = true;
			num = 0;
			for (j = 0; j < g[i].size(); j++)
			{
				if (c[i] != c[g[i][j]] && numdiff[g[i][j]] == 1) num++;
			}
			if (num == numdiff2 - 1)
			{
				bigbo = true;
				cout << "YES\n" << i + 1;
			}
		}
		if (bigbo == false) cout << "NO";
	}
}


#include <iostream>
#include <fstream>
#include <math.h>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <string>
#include <deque>
#include <iomanip>
#include <functional>
const double PI = std::atan(1.0) * 4;
using namespace std;
#define mp make_pair
#define all(a) a.begin(),a.end()
//#pragma comment(linker, "/STACK:104857600")
//Please help!
vector<vector<int> > g;
vector<int> c;
vector<bool> vis;
int num = 0, what = -1;
void dfs(int i)
{
	int j;
	vis[i] = 1;
	bool bo = true;
	for (j = 0; j < g[i].size(); j++) if (vis[g[i][j]] == 0)
	{
		dfs(g[i][j]);
		if (c[i] != c[g[i][j]]) bo = false;
	}
	if (g[i].size() > 1 && bo == false)
	{
		what = i;
		num++;
	}
}
int main()
{
	/*ifstream in;
	ofstream out;
	in.open("input.txt");
	out.open("output.txt");*/
	int n, i, x, y;
	cin >> n;
	g.resize(n);
	vis.assign(n, 0);
	c.resize(n);
	vis.resize(n);
	for (i = 0; i < n; i++)
	{
		cin >> x >> y;
		x--, y--;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	for (i = 0; i < n; i++) cin >> c[i];
	dfs(0);
	if (num == 0) cout << "YES\n" << 1;
	else if (num == 1) cout << "YES\n" << what + 1;
	else cout << "NO";
}


#include<set>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=1e5+50;
struct Node
{
    int u,v;
};
int n;
int d[maxn];
int col[maxn];
Node e[maxn];
int main()
{
    scanf("%d",&n);
    for(int i=1; i<n; i++)
        scanf("%d%d",&e[i].u,&e[i].v);
    for(int i=1; i<=n; i++)
        scanf("%d",&col[i]);
    int tot=0;
    for(int i=1; i<n; i++)
    {
        if(col[e[i].u]!=col[e[i].v])
        {
           tot++;
           d[e[i].u]++,d[e[i].v]++;
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(d[i]==tot)
        {
            printf("YES\n%d\n",i);
            return 0;
        }
    }
    printf("NO\n");
   return 0;
}


#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <ctime>
#include <string>
using namespace std;
struct edge {
	int from;
	int to;
	edge(int f, int t) {
		from = f;
		to = t;
	}
	edge() {
		from = 0;
		to = 0;
	}
};
edge es[100010];
int color[100010];
int main() {
	int n;
	cin >> n;
	int f, t;
	for (int i = 0; i < n - 1; i++) {
		scanf("%d %d", &f, &t);
		es[i] = edge(f, t);
	}
	for (int i = 1; i <= n; i++) {
		scanf("%d", color + i);
	}
	int a1, a2;
	bool is1 = 1;
	bool is2 = 1;
	for (int i = 0; i < n - 1; i++) {
		if (color[es[i].from] != color[es[i].to]) {
			a1 = es[i].from;
			a2 = es[i].to;
			for (int j = 0; j < n - 1; j++) {
				if (es[j].from == a1 || es[j].to == a1)
					continue;
				else {
					if (color[es[j].from] != color[es[j].to]) {
						is1 = 0;
						break;
					}
				}
			}
			for (int j = 0; j < n - 1; j++) {
				if (es[j].from == a2 || es[j].to == a2)
					continue;
				else {
					if (color[es[j].from] != color[es[j].to]) {
						is2 = 0;
						break;
					}
				}
			}
			break;
		}
	}
	if (is1 == 1 && is2 == 1)cout << "YES" << endl << a1 << endl;
	else if (is1 == 1 && is2 != 1) {
		cout << "YES" << endl << a1 << endl;
	}
	else if (is2 == 1 && is1 != 1) {
		cout << "YES" << endl << a2 << endl;
	}
	else
		cout << "NO"<<endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn = 2e5 + 5;
int u[maxn], v[maxn], cnt[maxn], c[maxn], sum = 0;
int main()
{
	int n;
	cin >> n;
	for (int i = 1; i < n; i++)
		cin >> u[i] >> v[i];
	for (int i = 1; i <= n; i++)
		cin >> c[i];
	for (int i = 1; i < n; i++)
	{
		if (c[u[i]] != c[v[i]])
			sum++, cnt[u[i]]++, cnt[v[i]]++;

	}
	for (int i = 1; i <= n; i++)
	{
		if (cnt[i] == sum)
		{
			cout << "YES\n" << i << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <string>
#include <set>
#include <algorithm>
#include <string.h>
#include <queue>
#include <stack>
#include <map>
#include <math.h>
#include <list>

using namespace std;
#define abs(a) ((a > 0)? (a):(-(a)))
#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
#define INF  1000000000
#define MAXN 100001
#define LOGMAXN 25

vector<int> g[MAXN];
vector<int> c(MAXN);
int  good[MAXN];
bool ans;
void DFS(int v, int p){
    bool gd = true;
    for(int i = 0; i < g[v].size(); i++){
        if(g[v][i] == p)
            continue;
		DFS(g[v][i],v);
		gd = gd && (c[g[v][i]] == c[v]) && good[g[v][i]];
    }
    good[v] = gd;
}

int DFSgood(int v, int p){
	int ngch = 0;
	int chind;
	int ngg = 0;
	for(int i = 0; i < g[v].size(); i++){
		if(g[v][i] == p)
            continue;
		if(!good[g[v][i]] || c[g[v][i]] != c[v]){
			ngch++;
			if(!good[g[v][i]])
				ngg++;
			chind = g[v][i];
		}
	}
	if(ngch == 0 || ngg == 0)
		return v;
	if(ngch == 1){
        if(c[chind] != c[v]){
            for(int i = 0; i < g[chind].size(); i++){
                if(g[chind][i] == v)
                    continue;
                if(!good[g[chind][i]])
                    return 0;
            }
            return chind;
        }
		return DFSgood(chind,v);
    }
    return 0;
}
int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n - 1; i++){
        int a,b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for(int i = 1; i <= n; i++){
        cin >> c[i];
    }
    DFS(1, - 1);
	int res = DFSgood(1,-1);

	if(res){
		cout<<"YES"<<endl;
		cout << res<<endl;
	}
	else
		cout<<"NO";
    return 0;
}
/*
	5
	1 2
	2 3
	1 4
	4 5
	1 1 1 3 2
*/


#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <utility>
#include <vector>
#include <fstream>
#include <iterator>
#include <functional>
#include <queue>

#define LONG long long
using namespace std;
int n;
int c[100000];
vector<vector<int> > g;
vector<int> dif; // Вершины смены цвета
vector<vector<int> > g2;
int was[100000];
int ccount = 0;
void bfs(int u)
{
	was[u] = 1;
	int k = g[u].size();
	for (int i = 0; i < k; i++)
	{
		int v = g[u][i];
		if (was[v] == 0)
		{
			if (c[v] != c[u])
			{
				g2[u].push_back(v);
				g2[v].push_back(u);
			}
			bfs(v);
		}
	}
}
void bfs2(int u)
{
	was[u] = 1;
	int k = g2[u].size();
	for (int i = 0; i < k; i++)
	{
		int v = g2[u][i];
		if (was[v] == 0)
		{
			bfs2(v);
		}
	}
}
int main()
{
#ifdef DEBUG
	freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout);
#endif
	cin >> n;
	g.resize(n);
	g2.resize(n);
	for (int i = 0; i < n-1; i++)
	{
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	for (int i = 0; i < n; i++)
		cin >> c[i];
	bfs(0);
	for (int i = 0; i < n; i++)
		was[i] = 0;
	for (int i = 0; i < n; i++)
	{
		if ((was[i] == 0)&&(g2[i].size()!=0))
		{
			bfs2(i);
			ccount++;
		}
	}
	for (int i = 0; i < g2.size(); i++)
	{
		if (g2[i].size() != 0)
			dif.push_back(i);
	}
	if (dif.size() == 0)
	{
		cout << "YES" << endl << 1;
		return 0;
	}
	else
	{
		if (ccount > 1)
		{
			cout << "NO";
			return 0;
		}
		else
		{
			int centr = -1;
			int rez = -1;
			int rezc = 0;
			for (int i = 0; i < n; i++)
			{
				if (g2[i].size()>1)
				{
					rez = i+1;
					rezc++;
				}
			}
			if (rezc > 1)
			{
				cout << "NO";
				return 0;
			}
			else
			{
				if (rez == -1)
				{
					int h = dif.size();
					for (int i = 0; i < h; i++)
					{
						int siz = 0;
						for (int ii = 0; ii < n; ii++)
							if (c[ii] == c[i])
								siz++;
						if (siz==1)
							rez = i+1;
					}
				}
				cout << "YES" << endl << rez;
				return 0;
			}
		}
	}
	return 0;
}


#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <utility>
#include <vector>
#include <fstream>
#include <iterator>
#include <functional>
#include <queue>

#define LONG long long
using namespace std;
int n;
int c[100000];
vector<vector<int> > g;
vector<int> dif; // Вершины смены цвета
vector<vector<int> > g2;
int was[100000];
int ccount = 0;
void bfs(int u)
{
	was[u] = 1;
	int k = g[u].size();
	for (int i = 0; i < k; i++)
	{
		int v = g[u][i];
		if (was[v] == 0)
		{
			if (c[v] != c[u])
			{
				g2[u].push_back(v);
				g2[v].push_back(u);
			}
			bfs(v);
		}
	}
}
void bfs2(int u)
{
	was[u] = 1;
	int k = g2[u].size();
	for (int i = 0; i < k; i++)
	{
		int v = g2[u][i];
		if (was[v] == 0)
		{
			bfs2(v);
		}
	}
}
int main()
{
#ifdef DEBUG
	freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout);
#endif
	cin >> n;
	g.resize(n);
	g2.resize(n);
	for (int i = 0; i < n-1; i++)
	{
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	for (int i = 0; i < n; i++)
		cin >> c[i];
	bfs(0);
	for (int i = 0; i < n; i++)
		was[i] = 0;
	for (int i = 0; i < n; i++)
	{
		if ((was[i] == 0)&&(g2[i].size()!=0))
		{
			bfs2(i);
			ccount++;
		}
	}
	for (int i = 0; i < g2.size(); i++)
	{
		if (g2[i].size() != 0)
			dif.push_back(i);
	}
	if (dif.size() == 0)
	{
		cout << "YES" << endl << 1;
		return 0;
	}
	else
	{
		if (ccount > 1)
		{
			cout << "NO";
			return 0;
		}
		else
		{
			int centr = -1;
			int rez = -1;
			int rezc = 0;
			for (int i = 0; i < n; i++)
			{
				if (g2[i].size()>1)
				{
					rez = i+1;
					rezc++;
				}
			}
			if (rezc > 1)
			{
				cout << "NO";
				return 0;
			}
			else
			{
				cout << "YES" << endl << rez;
				return 0;
			}
		}
	}
	return 0;
}


#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <utility>
#include <vector>
#include <fstream>
#include <iterator>
#include <functional>
#include <queue>

#define LONG long long
using namespace std;
int n;
int c[100000];
vector<vector<int> > g;
vector<int> dif; // Вершины смены цвета
vector<vector<int> > g2;
int was[100000];
int ccount = 0;
void bfs(int u)
{
	was[u] = 1;
	int k = g[u].size();
	for (int i = 0; i < k; i++)
	{
		int v = g[u][i];
		if (was[v] == 0)
		{
			if (c[v] != c[u])
			{
				g2[u].push_back(v);
				g2[v].push_back(u);
			}
			bfs(v);
		}
	}
}
void bfs2(int u)
{
	was[u] = 1;
	int k = g2[u].size();
	for (int i = 0; i < k; i++)
	{
		int v = g2[u][i];
		if (was[v] == 0)
		{
			bfs2(v);
		}
	}
}
int main()
{
#ifdef DEBUG
	freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout);
#endif
	cin >> n;
	g.resize(n);
	g2.resize(n);
	for (int i = 0; i < n-1; i++)
	{
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	for (int i = 0; i < n; i++)
		cin >> c[i];
	bfs(0);
	for (int i = 0; i < n; i++)
		was[i] = 0;
	for (int i = 0; i < n; i++)
	{
		if ((was[i] == 0)&&(g2[i].size()!=0))
		{
			bfs2(i);
			ccount++;
		}
	}
	for (int i = 0; i < g2.size(); i++)
	{
		if (g2[i].size() != 0)
			dif.push_back(i);
	}
	if (dif.size() == 0)
	{
		cout << "YES" << endl << 1;
		return 0;
	}
	else
	{
		if (ccount > 1)
		{
			cout << "NO";
			return 0;
		}
		else
		{
			int centr = -1;
			int rez = -1;
			int rezc = 0;
			for (int i = 0; i < n; i++)
			{
				if (g2[i].size()>1)
				{
					rez = i+1;
					rezc++;
				}
			}
			if (rezc > 1)
			{
				cout << "NO";
				return 0;
			}
			else
			{
				if (rez == -1)
				{
					int h = dif.size();
					for (int i = 0; i < h; i++)
					{
						int siz = 0;
						for (int ii = 0; ii < n; ii++)
							if (c[ii] == c[dif[i]])
								siz++;
						h = h;
						if (siz==1)
							rez = dif[i]+1;
					}
				}
				cout << "YES" << endl << rez;
				return 0;
			}
		}
	}
	return 0;
}


/*
 * A.cpp
 *
 *  Created on: 02.02.2017
 *      Author: nsv
 */

#pragma comment (linker, "/STACK:64000000")

#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <utility>
#include <vector>
#include <fstream>
#include <queue>
#include <complex>
#include <ctime>

using namespace std;

#define pi (3.1415926535897932384626433832795)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define tmin(x,y,z) (min(min((x),(y)),(z)))
#define tmax(x,y,z) (max(max((x),(y)),(z)))
#define sq(x) ((x)*(x))

typedef long double ld;
typedef unsigned long long ull;
typedef long long ll;

int t;
void solve();

int main()
{
	//freopen("input.txt", "rt", stdin); //freopen("output.txt", "wt", stdout);

	t = 1;
	for (int i = 0; i < t; ++i)
	{
		solve();
	}
}

const int MOD = 1e8;
vector<char>used;
vector<int>city;
vector < vector<int> > g;
int cntv = 0, cntr=0;

int GCD(int a, int b)
{
	return b? GCD(b, a%b) : a;
}

void solve(){
    int n, m, k,a,b, z,mx=0;
    cin >> n;
    vector< pair<int,int> >vp(n-1);
    vector <int> v(n);
    for(int i=0; i<n-1; ++i)
    {
    	cin >> a >> b;
    	vp[i] = make_pair(a,b);
    }
    for(int i=0; i<n; ++i)
    {
    	cin >> v[i];
    }
    int pr1 = -1, pr2=-1, i = 0, ans = -1;
    bool ctopud = false, no = false;
    while(!no && i<n-1)
    {
    	if( v[vp[i].first - 1] != v[vp[i].second-1])
    	{
    		//cout<<v[vp[i].first - 1]<<v[vp[i].second-1]<<"*";
    		if(pr1 == -1)
    		{
    			pr1 = vp[i].first;
    			pr2 = vp[i].second;
    		}
    		else
    		{
    			if(ctopud)
    			{
    				if( ans != vp[i].first && ans != vp[i].second )
    				{
    					no = true;
    				}
    			}
				else
				{
					if( pr1 == vp[i].first || pr2 == vp[i].first )
					{
						ans = vp[i].first;
						ctopud = true;
					}
					else if( pr1 == vp[i].second || pr2 == vp[i].second )
					{
						ans = vp[i].second;
						ctopud = true;
					}
					else
					{
						no =true;
					}
    			}
    		}
    	}
    	//cout << i <<" " << pr1 << " " << pr2 << " " <<ctopud << " " << no <<" "<<ans<< endl;
    	++i;
    }
    if(no)
    	cout << "NO";
    else
    	cout << "YES\n";
    	if(ans == -1)
    		if(pr1==-1)
    			cout << 1;
    		else
    			cout << pr1;
    	else
    		cout <<ans;
}


/*
 * A.cpp
 *
 *  Created on: 02.02.2017
 *      Author: nsv
 */

#pragma comment (linker, "/STACK:64000000")

#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <utility>
#include <vector>
#include <fstream>
#include <queue>
#include <complex>
#include <ctime>

using namespace std;

#define pi (3.1415926535897932384626433832795)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define tmin(x,y,z) (min(min((x),(y)),(z)))
#define tmax(x,y,z) (max(max((x),(y)),(z)))
#define sq(x) ((x)*(x))

typedef long double ld;
typedef unsigned long long ull;
typedef long long ll;

int t;
void solve();

int main()
{
	//freopen("input.txt", "rt", stdin); //freopen("output.txt", "wt", stdout);

	t = 1;
	for (int i = 0; i < t; ++i)
	{
		solve();
	}
}

const int MOD = 1e8;
vector<char>used;
vector<int>city;
vector < vector<int> > g;
int cntv = 0, cntr=0;

int GCD(int a, int b)
{
	return b? GCD(b, a%b) : a;
}

void solve(){
    int n, m, k,a,b, z,mx=0;
    cin >> n;
    vector< pair<int,int> >vp(n-1);
    vector <int> v(n);
    for(int i=0; i<n-1; ++i)
    {
    	cin >> a >> b;
    	vp[i] = make_pair(a,b);
    }
    for(int i=0; i<n; ++i)
    {
    	cin >> v[i];
    }
    int pr1 = -1, pr2=-1, i = 0, ans = -1;
    bool ctopud = false, no = false;
    while(!no && i<n-1)
    {
    	if( v[vp[i].first - 1] != v[vp[i].second-1])
    	{
    		//cout<<v[vp[i].first - 1]<<v[vp[i].second-1]<<"*";
    		if(pr1 == -1)
    		{
    			pr1 = vp[i].first;
    			pr2 = vp[i].second;
    		}
    		else
    		{
    			if(ctopud)
    			{
    				if( ans != vp[i].first && ans != vp[i].second )
    				{
    					no = true;
    				}
    			}
				else
				{
					if( pr1 == vp[i].first || pr2 == vp[i].first )
					{
						ans = vp[i].first;
						ctopud = true;
					}
					else if( pr1 == vp[i].second || pr2 == vp[i].second )
					{
						ans = vp[i].second;
						ctopud = true;
					}
					else
					{
						no =true;
					}
    			}
    		}
    	}
    	//cout << i <<" " << pr1 << " " << pr2 << " " <<ctopud << " " << no <<" "<<ans<< endl;
    	++i;
    }
    if(no)
    	cout << "NO";
    else
    {
    	cout << "YES\n";
    	if(ans == -1)
    	{
    		if(pr1==-1)
    		{
    			cout << 1;
    		}
    		else
    		{
    			cout << pr1;
    		}
    	}
    	else
    	{
    		cout <<ans;
    	}
    }
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <set>
#include <unordered_set>
#include <bitset>
#include <iostream>
#include <algorithm>
using namespace std;

# define M_PI           3.14159265358979323846

const int INF = 1e9;

struct abc
{
	long long a, b, s;
	int t;
};

int main()
{
	ios::sync_with_stdio(0);
	int n, a, b;
	scanf("%d", &n);

	vector<vector<int> > g(n);

	for (int i = 1; i < n; ++i)
	{
		scanf("%d%d", &a, &b);
		--a;
		--b;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	vector<int> color(n);

	for (int i = 0; i < n; ++i)
	{
		scanf("%d", &color[i]);
	}

	vector<pair<int, int> > v;

	for (int i = 0; i < n; ++i)
	{
		int color1 = color[i];

		for (int j = 0; j < g[i].size(); ++j)
		{
			int color2 = color[g[i][j]];
			if (color1 != color2)
			{
				v.push_back(make_pair(i, g[i][j]));
			}
		}
	}

	if (!v.size())
	{
		printf("YES\n1");
		return 0;
	}

	int num1 = v[0].first;
	int num2 = v[0].second;

	for (int i = 1; i < v.size(); ++i)
	{
		if (v[i].first != num1 && v[i].second != num1)
		{
			num1 = -1;
		}

		if (v[i].first != num2 && v[i].second != num2)
		{
			num2 = -1;
		}
	}

	if (num1 != -1)
	{
		printf("YES\n%d", num1 + 1);
	}
	else if (num2 != -1)
	{
		printf("YES\n%d", num2 + 1);
	}
	else
	{
		printf("NO");
	}

	return 0;
}


#include <iostream>
using namespace std;
int n,l[100002],r[100002],g[100002];
int main(){
    cin>>n;
    for(int i=1;i<n;i++)
        cin>>l[i]>>r[i];
    for(int i=1;i<=n;i++)
        cin>>g[i];
    int ar=0,er=0;
    for(int i=1;i<n;i++){
        if(g[l[i]]!=g[r[i]]){
            if(ar==0 && er==0){
                ar=l[i];
                er=r[i];
                if(ar<er)
                    swap(ar,er);
            }
            else{
                if(l[i]<r[i])
                    swap(l[i],r[i]);
                if(ar!=l[i] && ar!=r[i])
                    ar=-1;
                if(er!=l[i] && er!=r[i])
                    er=-1;
            }
        }
    }
    if(ar<er)
        swap(ar,er);
    if(ar==-1){
        cout<<"NO"<<endl;
        return 0;
    }
    cout<<"YES"<<endl<<(ar==0 ? 1 : ar)<<endl;
    return 0;
}


#include <iostream>
using namespace std;
int n,l[100002],r[100002],g[100002];
int main(){
    cin>>n;
    for(int i=1;i<n;i++)
        cin>>l[i]>>r[i];
    for(int i=1;i<=n;i++)
        cin>>g[i];
    int ar=0,er=0;
    for(int i=1;i<n;i++){
        if(g[l[i]]!=g[r[i]]){
            if(ar==0 && er==0){
                ar=l[i];
                er=r[i];
                if(ar<er)
                    swap(ar,er);
            }
            else{
                if(l[i]<r[i])
                    swap(l[i],r[i]);
                if(ar!=l[i] && ar!=r[i])
                    ar=-1;
                if(er!=l[i] && er!=r[i])
                    er=-1;
            }
        }
    }
    if(ar==-1){
        cout<<"NO"<<endl;
        return 0;
    }
    cout<<"YES"<<endl<<(ar==0 ? 1 : ar)<<endl;
    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
typedef long long ll;
typedef unsigned char byte;

#define MAXN 100004
#define MAXM 1

int n;
int color[MAXN];
std::vector<int> g[MAXN];

bool help[MAXN];
bool path[MAXN];

bool helpDfs(int x, int c)
{
	help[x] = true;

	for (int i = 0; i < g[x].size(); ++i)
	{
		if (help[g[x][i]])
			continue;

		if (color[g[x][i]] != c)
			return false;

		if (!helpDfs(g[x][i], c))
			return false;
	}

	return true;
}

bool dfs(int x, int out)
{
	memset(help, 0, sizeof(help));
	help[out] = true;
	return helpDfs(x, color[x]);
}

int main()
{
	std::cin >> n;
	for (int i = 1; i < n; ++i)
	{
		int x, y;
		std::cin >> x >> y;
		g[x].push_back(y);
		g[y].push_back(x);
	}

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

	int index = 1;

	while (true)
	{
		path[index] = true;

		std::vector<int> failed;

		for (int i = 0; i < g[index].size(); ++i)
		{
			if (!dfs(g[index][i], index))
				failed.push_back(g[index][i]);
		}

		if (failed.size() > 1)
		{
			std::cout << "NO" << std::endl;
			return 0;
		}
		else if (failed.size() == 0)
		{
			std::cout << "YES" << std::endl;
			std::cout << index << std::endl;
			return 0;
		}

		int f = failed[0];
		int c = color[index];
		for (int i = 0; i < g[index].size(); ++i)
		{
			int j = g[index][i];
			if (j != f)
			{
				if (color[j] != c)
				{
					std::cout << "NO" << std::endl;
					return 0;
				}
			}
		}

		if (path[f])
		{
			std::cout << "NO" << std::endl;
			return 0;
		}

		index = f;
	}

	return 0;
}


// rc.cpp : Defines the entry point for the console application.
//

#include <math.h>

#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <functional>
#include <iomanip>

using namespace std;

#define PI 3.14159265358979323846
#define EPS 1.E-8

typedef unsigned char uchar;
typedef unsigned int uint;
typedef unsigned long long uint64;
typedef long long sint64;

vector<uint> tr[100000];
uint v[100000],
     c[100000];

uint b[100000],
     nb;

uint cc;

void dfs(uint t)
{
    v[t] = 1;
    uint sz = tr[t].size();
    for (uint i = 0; i < sz; ++i) {
        uint nx = tr[t][i];

        if (c[nx] != cc)
            ++b[nx];

        if (v[nx] == false && c[nx] == cc)
            dfs(nx);
    }
}

int main(int argc, char* argv[])
{
    uint n;
    cin >> n;

    for (uint i = 1; i < n; ++i) {
        uint u, v;
        cin >> u >> v;
        --u, --v;
        tr[u].push_back(v);
        tr[v].push_back(u);
    }
    for (uint i = 0; i < n; ++i)
        cin >> c[i];

    for (uint i = 0; i < n; ++i) {
        if (!v[i]) {
            cc = c[i];
            dfs(i);
        }
    }

    bool ok = true;

    uint bi = -1;
    uint sb = 0;
    for (uint i = 0; i < n; ++i) {
        if (b[i] > 1) {
            if (bi == -1)
                bi = i;
            else {
                ok = false;
                break;
            }
        }
        else if (b[i] == 1)
            ++sb;
    }

    if (ok && sb != b[bi])
        ok = false;

    if (ok)
        cout << "YES\n" << bi + 1 << endl;
    else
        cout << "NO\n";
    return 0;
}


// rc.cpp : Defines the entry point for the console application.
//

#include <math.h>

#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <functional>
#include <iomanip>

using namespace std;

#define PI 3.14159265358979323846
#define EPS 1.E-8

typedef unsigned char uchar;
typedef unsigned int uint;
typedef unsigned long long uint64;
typedef long long sint64;

vector<uint> tr[100000];
uint v[100000],
     c[100000];

uint b[100000],
     nb;

uint cc;

void dfs(uint t)
{
    v[t] = 1;
    uint sz = tr[t].size();
    for (uint i = 0; i < sz; ++i) {
        uint nx = tr[t][i];

        if (c[nx] != cc)
            ++b[nx];

        if (v[nx] == false && c[nx] == cc)
            dfs(nx);
    }
}

int main(int argc, char* argv[])
{
    uint n;
    cin >> n;

    for (uint i = 1; i < n; ++i) {
        uint u, v;
        cin >> u >> v;
        --u, --v;
        tr[u].push_back(v);
        tr[v].push_back(u);
    }
    for (uint i = 0; i < n; ++i)
        cin >> c[i];

    for (uint i = 0; i < n; ++i) {
        if (!v[i]) {
            cc = c[i];
            dfs(i);
        }
    }

    bool ok = true;

    uint bi = -1;
    uint sb = 0;
    for (uint i = 0; i < n; ++i) {
        if (b[i] > 1) {
            if (bi == -1)
                bi = i;
            else {
                ok = false;
                break;
            }
        }
        else if (b[i] == 1)
            ++sb;
    }

    if (bi == -1) {
        if (sb == 0)
            bi = 0;
        else if (sb == 2) {
            for (uint i = 0; i < n; ++i) {
                if (b[i] == 1) {
                    bi = i;
                    break;
                }
            }
        }
        else
            ok = false;
    }
    else {
        if (ok && sb != b[bi])
            ok = false;
    }

    if (ok)
        cout << "YES\n" << bi + 1 << endl;
    else
        cout << "NO\n";
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#define ll long long
#define mp make_pair

using namespace std;

const int maxN = 100013;

vector<int> gr[maxN];
int n, c[maxN], d[maxN];
set<int> colors[maxN];
void dfs(int v, int num_tree = -1, int pr = -1){
	if(num_tree != -1){
		colors[num_tree].insert(c[v]);
	}
	for(int i = 0; i < gr[v].size(); i++){
		int to = gr[v][i];
		if(to == pr)continue;
		else{
			if(num_tree != -1)dfs(to, num_tree, v);
			else dfs(to, to, v);
		}
	}
}

bool check(int v){
	dfs(v);
	for(int i = 1; i <= n; i++){
		if(colors[i].size() > 1){return 0;}
		else{colors[i].clear();}
	}
	return 1;
}

int main (){
//	freopen("test.txt", "r", stdin);
	cin >> n;
	for(int i = 1; i < n; i++){
		int u, v;
		cin >> u >> v;
		gr[u].push_back(v);
		gr[v].push_back(u);
	}
	for(int i = 1; i <= n; ++i)
		cin >> c[i];
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < gr[i].size(); j++){
			int to = gr[i][j];
			if(c[to] != c[i]){
				bool ans = check(to);
				if(ans){
					cout << "YES \n";
					cout << to;
					return 0;
				}
				ans = check(i);
				if(ans){
					cout << "YES \n";
					cout << i;
					return 0;
				}
				cout << "NO";
				return 0;
			}
		}
	}
	cout << "YES\n" << 1;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#define ll long long
#define mp make_pair

using namespace std;

const int maxN = 100013;

vector<int> gr[maxN];
int n, c[maxN], d[maxN];
set<int> colors[maxN];
void dfs(int v, int num_tree = -1, int pr = -1){
	if(num_tree != -1){
		colors[num_tree].insert(c[v]);
	}
	for(int i = 0; i < gr[v].size(); i++){
		int to = gr[v][i];
		if(to == pr)continue;
		else{
			if(num_tree != -1)dfs(to, num_tree, v);
			else dfs(to, to, v);
		}
	}
}

bool check(int v){
	dfs(v);
	for(int i = 1; i <= n; i++){
		int ss = colors[i].size();
		colors[i].clear();
		if(ss > 1){return 0;}
	}
	return 1;
}

int main (){
	//freopen("test.txt", "r", stdin);
	cin >> n;
	for(int i = 1; i < n; i++){
		int u, v;
		cin >> u >> v;
		gr[u].push_back(v);
		gr[v].push_back(u);
	}
	for(int i = 1; i <= n; ++i)
		cin >> c[i];
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < gr[i].size(); j++){
			int to = gr[i][j];
			if(c[to] != c[i]){
				bool ans = check(to);
				if(ans){
					cout << "YES \n";
					cout << to;
					return 0;
				}
				ans = check(i);
				if(ans){
					cout << "YES \n";
					cout << i;
					return 0;
				}
				cout << "NO";
				return 0;
			}
		}
	}
	cout << "YES\n" << 1;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#define ll long long
#define mp make_pair

using namespace std;

const int maxN = 100013;

vector<int> gr[maxN];
int n, c[maxN], d[maxN];
set<int> colors[maxN];
void dfs(int v, int p = -1, int pr = -1){
	if(p == -1){d[v] = 0;}
	else{
		colors[p].insert(c[v]);
	}
	for(int i = 0; i < gr[v].size(); i++){
		int to = gr[v][i];
		if(to == pr)continue;
		else{
			d[to] = d[v] + 1;
			if(p!= -1)dfs(to, p, v);
			else dfs(to, to, v);
		}
	}
}

bool check(int v){
	dfs(v);
	for(int i = 1; i <= n; i++){
		if(colors[i].size() > 1){return 0;}
	}
	return 1;
}

int main (){
//	freopen("test.txt", "r", stdin);
	cin >> n;
	for(int i = 1; i < n; i++){
		int u, v;
		cin >> u >> v;
		gr[u].push_back(v);
		gr[v].push_back(u);
	}
	for(int i = 1; i <= n; ++i)
		cin >> c[i];
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < gr[i].size(); j++){
			int to = gr[i][j];
			if(c[to] != c[i]){
				bool ans = check(to);
				if(ans){
					cout << "YES \n";
					cout << to;
					return 0;
				}
				ans = check(i);
				if(ans){
					cout << "YES \n";
					cout << to;
					return 0;
				}
				cout << "NO";
				return 0;
			}
		}
	}
	cout << "YES\n" << 1;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#define ll long long
#define mp make_pair

using namespace std;

const int maxN = 100013;

vector<int> gr[maxN];
int n, c[maxN], d[maxN];
set<int> colors[maxN];
void dfs(int v, int p = -1, int pr = -1){
	if(p == -1){d[v] = 0;}
	else{
		colors[p].insert(c[v]);
	}
	for(int i = 0; i < gr[v].size(); i++){
		int to = gr[v][i];
		if(to == pr)continue;
		else{
			d[to] = d[v] + 1;
			if(p!= -1)dfs(to, p, v);
			else dfs(to, to, v);
		}
	}
}

bool check(int v){
	dfs(v);
	for(int i = 1; i <= n; i++){
		if(colors[i].size() > 1){return 0;}
	}
	return 1;
}

int main (){
	//freopen("test.txt", "r", stdin);
	cin >> n;
	for(int i = 1; i < n; i++){
		int u, v;
		cin >> u >> v;
		gr[u].push_back(v);
		gr[v].push_back(u);
	}
	for(int i = 1; i <= n; ++i)
		cin >> c[i];
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < gr[i].size(); j++){
			int to = gr[i][j];
			if(c[to] != c[i]){
				bool ans = check(to);
				if(ans){
					cout << "YES \n";
					cout << to;
					return 0;
				}
				ans = check(i);
				if(ans){
					cout << "YES \n";
					cout << to;
					return 0;
				}
				cout << "NO";
				return 0;
			}
		}
	}
	return 0;
}


// C.cpp : Defines the entry point for the console application.
//

//#include "stdafx.h"
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<vector<int> > tree(n);
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		tree[a].push_back(b);
		tree[b].push_back(a);
	}
	vector<int> color(n);
	for (int i = 0; i < n; i++) cin >> color[i];

	vector<int> dif(n, 0);
	int indexMaxDif = -1;
	int maxDif = -1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < (int)tree[i].size(); j++) {
			if (color[i] != color[tree[i][j]]) dif[i]++;
		}
		if (dif[i] > maxDif) {
			indexMaxDif = i;
			maxDif = dif[i];
		}
	}
	bool fl = true;
	for (int i = 0; i < n; i++) {
		if (dif[i] == 0 || i == indexMaxDif) continue;
		if (dif[i] > 1) {
			fl = false;
			break;
		}
		bool wasMaxDif = false;
		for (int j = 0; j < (int)tree[i].size(); j++) {
			if (tree[i][j] == indexMaxDif) {
				wasMaxDif = true;
				break;
			}
		}
		if (!wasMaxDif) {
			fl = false;
			break;
		}
	}
	if (!fl) cout << "NO";
	else {
		cout << "YES" << endl << indexMaxDif + 1;
	}
    return 0;
}


// C.cpp : Defines the entry point for the console application.
//

//#include "stdafx.h"
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<vector<int> > tree(n);
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		tree[a].push_back(b);
		tree[b].push_back(a);
	}
	vector<int> color(n);
	for (int i = 0; i < n; i++) cin >> color[i];

	vector<int> dif(n, 0);
	int indexMaxDif = -1;
	int maxDif = -1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < (int)tree[i].size(); j++) {
			if (color[i] != color[j]) dif[i]++;
		}
		if (dif[i] > maxDif) {
			indexMaxDif = i;
			maxDif = dif[i];
		}
	}
	bool fl = true;
	for (int i = 0; i < n; i++) {
		if (dif[i] == 0 || i == indexMaxDif) continue;
		if (dif[i] > 1) {
			fl = false;
			break;
		}
		bool wasMaxDif = false;
		for (int j = 0; j < (int)tree[i].size(); j++) {
			if (tree[i][j] == indexMaxDif) {
				wasMaxDif = true;
				break;
			}
		}
		if (!wasMaxDif) {
			fl = false;
			break;
		}
	}
	if (!fl) cout << "NO";
	else {
		cout << "YES" << endl << indexMaxDif + 1;
	}
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
int n;
int a[100005], b[100005];
int c[100005];
int cnt[100005];
int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n - 1; i++)
	{
		scanf("%d%d", &a[i], &b[i]);
	}
	for (int i = 1; i <= n; i++)
		scanf("%d", &c[i]);
	for (int i = 0; i < n - 1; i++)
	{
		if (c[a[i]] != c[b[i]])
		{
			cnt[a[i]]++;
			cnt[b[i]]++;
		}
	}
	int cnt1 = 0;
	int cntn = 0;
	int id1 = 0;
	int idn = 0;
	for (int i = 1; i <= n; i++)
	{
		if (cnt[i] == 0)continue;
		if (cnt[i] == 1)
		{
			cnt1++;
			id1 = i;
		}
		else
		{
			cntn++;
			idn = i;
		}
	}

	if (cntn == 1)
	{
		printf("YES\n");
		printf("%d\n", idn);
	}
	else if (cnt1 == 2 && cntn == 0)
	{
		printf("YES\n");
		printf("%d\n", id1);
	}
	else if(cnt1==0&&cntn==0){
		printf("YES\n");
		printf("0\n");
	}
	else {
		printf("NO\n");
	}
}


#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
int n;
int a[100005], b[100005];
int c[100005];
int cnt[100005];
int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n - 1; i++)
	{
		scanf("%d%d", &a[i], &b[i]);
	}
	for (int i = 1; i <= n; i++)
		scanf("%d", &c[i]);
	for (int i = 0; i < n - 1; i++)
	{
		if (c[a[i]] != c[b[i]])
		{
			cnt[a[i]]++;
			cnt[b[i]]++;
		}
	}
	int cnt1 = 0;
	int cntn = 0;
	int id1 = 0;
	int idn = 0;
	for (int i = 1; i <= n; i++)
	{
		if (cnt[i] == 0)continue;
		if (cnt[i] == 1)
		{
			cnt1++;
			id1 = i;
		}
		else
		{
			cntn++;
			idn = i;
		}
	}

	if (cntn == 1)
	{
		printf("YES\n");
		printf("%d\n", idn);
	}
	else if (cnt1 == 2 && cntn == 0)
	{
		printf("YES\n");
		printf("%d\n", id1);
	}
	else if(cnt1==0&&cntn==0){
		printf("YES\n");
		printf("1\n");
	}
	else {
		printf("NO\n");
	}
}


#include<iostream>
#include<cmath>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<map>
using namespace std;
int u[100005], v[100005];
	int c[100005];
	int p[100005], d[100005];
	int vis[100005];
int main()
{
	int n;

	memset(vis, 0, sizeof(vis));
	memset(d, 0, sizeof(d));
	cin >> n;
	for (int i = 1; i < n; i++)
	{
		cin >> u[i] >> v[i];
	}
	for (int i = 1; i <= n; i++)
	{
		cin >> c[i];
		p[i] = i;
	}
	for (int i = 1; i < n; i++)
	{
		if (c[u[i]] == c[v[i]])
		{
			p[v[i]] = p[u[i]];
			d[p[u[i]]]+= d[p[v[i]]];
		}
		else
		{
			d[p[v[i]]]++;
			d[p[u[i]]]++;
		}
	}
	for (int i = 1; i <= n; i++)
		vis[p[i]]++;
	int ret = 0;
	for (int i = 1; i <= n; i++)
		if (vis[i])
			ret++;
	int k=-1;
	for (int i = 1; i <= n; i++)
		if (vis[i])
			if (d[i] == ret - 1)
			{
				k = i;
				break;
			}
	if (k == -1)
		cout << "NO" << endl;
	else
	{
		cout << "YES" << endl;
		cout << k;cout << endl;
	}
	return 0;
}


#include<iostream>
#include<cmath>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<map>
using namespace std;
int u[100005], v[100005];
	int c[100005];
	int p[100005], d[100005];
	int vis[100005];
int main()
{
	int n;

	memset(vis, 0, sizeof(vis));
	memset(d, 0, sizeof(d));
	cin >> n;
	for (int i = 1; i < n; i++)
	{
		cin >> u[i] >> v[i];
	}
	for (int i = 1; i <= n; i++)
	{
		cin >> c[i];
		p[i] = i;
	}
	for (int i = 1; i < n; i++)
	{
		if (c[u[i]] == c[v[i]])
		{
			p[v[i]] = p[u[i]];
			d[p[u[i]]]+= d[p[v[i]]];
		}
		else
		{
			d[p[v[i]]]++;
			d[p[u[i]]]++;
		}
	}
	for (int i = 1; i <= n; i++)
		vis[p[i]]++;
	int ret = 0;
	for (int i = 1; i <= n; i++)
		if (vis[i])
			ret++;
	int k=-1;
	for (int i = 1; i <= n; i++)
		if (vis[i])
			if (d[i] == ret - 1)
			{
				k = i;
				break;
			}
	if (k == -1)
		cout << "NO" << endl;
	else
	{
		cout << "YES" << endl;
		if (vis[k] == 1)
		{
			for (int i = 1; i <= n; i++)
				if (p[i] == k)
					cout << i << endl;
		}
		else
		{
			cout << k;
			for (int i = 1; i <= n; i++)
				if (p[i] == k)
					cout <<" "<< i ;
			cout << endl;
		}
	}
	return 0;
}


#include<iostream>
#include<cmath>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<map>
using namespace std;
int u[100005], v[100005];
	int c[100005];
	int p[100005], d[100005];
	int vis[100005];
int main()
{
	int n;

	memset(vis, 0, sizeof(vis));
	memset(d, 0, sizeof(d));
	int cnt = 0;
	cin >> n;
	for (int i = 0; i < n-1; i++)
	{
		int a, b;
		cin >> a >> b;
		u[i] = a - 1; v[i] = b - 1;
	}
	for (int i = 0; i < n; i++)
	{
		cin >> c[i];
	}
	for (int i = 0; i < n-1; i++)
	{
		if (c[u[i]] != c[v[i]])
		{
			cnt++;
			d[u[i]]++;
			d[v[i]]++;
		}
	}
	for (int i = 0; i<n; i++)
	{
		if (d[i] == cnt)
		{
			cout << "YES" << endl << i+1 << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int n;
vector<vector<int>> w;
vector<int> c;
vector<int> notMatching;

vector <bool> visited;

bool sameColor(int v, int color) {
	visited[v] = true;
	if (c[v] != color) return false;
	for (int j = 0; j < w[v].size(); j++)
		if (!visited[w[v][j]])
			if (!sameColor(w[v][j], color)) return false;
	return true;
}

bool root(int v) {
	visited[v] = true;
	for (int i = 0; i < w[v].size(); i++)
		if (!sameColor(w[v][i], c[w[v][i]])) return false;
	return true;
}

void main() {

	//freopen("input.txt", "r", stdin);

	cin >> n;

	w.resize(n);
	c.resize(n);
	notMatching.resize(n, 0);

	for (int i = 0; i < n - 1; i++) {
		int x, y;

		cin >> x >> y;
		x--;
		y--;

		w[x].push_back(y);
		w[y].push_back(x);
	}

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

	for (int i = 0; i < n; i++)
		for (int j = 0; j < w[i].size(); j++)
			if (c[i] != c[w[i][j]]) {

				visited.resize(n, false);
				if (root(i)) {
					cout << "YES" << endl << i+1;
					return;
				}

				fill(visited.begin(), visited.end(), false);
				if (root(w[i][j])) {
					cout << "YES" << endl << w[i][j]+1;
					return;
				}

				cout << "NO";
			}
	cout << "YES" << endl << 1;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

void main() {

	//freopen("input.txt", "r", stdin);

	int n;
	cin >> n;

	vector<vector<int>> w;
	vector<int> c;
	vector<int> notMatching;

	w.resize(n);
	c.resize(n);
	notMatching.resize(n, 0);

	for (int i = 0; i < n - 1; i++) {
		int x, y;

		cin >> x >> y;
		x--;
		y--;

		w[x].push_back(y);
		w[y].push_back(x);
	}

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

	int notMatchingCurrentMoreThen1 = 0;
	int root = -1;

	for (int i = 0; i < n; i++) {
		int thisColor = c[i];
		int notMachingWithCurrent = 0;
		int whichNotMatch;

		for (int j = 0; j < w[i].size(); j++)
			if (thisColor != c[w[i][j]]) notMachingWithCurrent++, whichNotMatch = w[i][j];

		if (notMachingWithCurrent == 0) continue;

		if (notMachingWithCurrent == 1) {
			notMatching[i]++;
			notMatching[whichNotMatch]++;
		}

		if (notMachingWithCurrent > 1) {
			notMatchingCurrentMoreThen1++;
			root = i;
		}

		if (notMatchingCurrentMoreThen1 > 1) {
			cout << "NO";
			return;
		}
	}

	cout << "YES" << endl;
	for (int i = 0; i < n; i++) if (notMatching[i]>1) root = i;
	if (root == -1) for (int i = 0; i < n; i++) if (notMatching[i]==1) root = i;

	if (root != -1) {
		cout << root + 1;
		return;
	}
	cout << 1;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

void main() {

	//freopen("input.txt", "r", stdin);

	int n;
	cin >> n;

	vector<vector<int>> w;
	vector<int> c;
	vector<int> notMatching;

	w.resize(n);
	c.resize(n);
	notMatching.resize(n, 0);

	for (int i = 0; i < n - 1; i++) {
		int x, y;

		cin >> x >> y;
		x--;
		y--;

		w[x].push_back(y);
		w[y].push_back(x);
	}

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

	int notMatchingCurrentMoreThen1 = 0;
	int root = -1;

	for (int i = 0; i < n; i++) {
		int thisColor = c[i];
		int notMachingWithCurrent = 0;
		int whichNotMatch;

		for (int j = 0; j < w[i].size(); j++)
			if (thisColor != c[w[i][j]]) notMachingWithCurrent++, whichNotMatch = w[i][j];

		if (notMachingWithCurrent == 0) continue;

		if (notMachingWithCurrent == 1 && root != -1) {
			if (root != whichNotMatch && root != i) {
				cout << "NO";
				return;
			}
		}

		notMatching[i]++;
		notMatching[whichNotMatch]++;

		if (notMachingWithCurrent > 1) {
			notMatchingCurrentMoreThen1++;
			root = i;
		}

		if (notMatchingCurrentMoreThen1 > 1) {
			cout << "NO";
			return;
		}

	}
	cout << "YES" << endl;

	if (root != -1) {
		cout << root + 1;
		return;
	}

	int maxx = -1;
	for (int i = 0; i < n; i++) {
		if (notMatching[i] != 1) maxx = i;
	}

	cout << maxx + 1;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int n;
vector<vector<int>> w;
vector<int> c;
vector<int> notMatching;

vector <bool> visited;

bool sameColor(int v, int color) {
	visited[v] = true;
	if (c[v] != color) return false;
	for (int j = 0; j < w[v].size(); j++)
		if (!visited[w[v][j]])
			if (!sameColor(w[v][j], color)) return false;
	return true;
}

bool root(int v) {
	visited[v] = true;
	for (int i = 0; i < w[v].size(); i++)
		if (!sameColor(w[v][i], c[w[v][i]])) return false;
	return true;
}

void main() {

	//freopen("input.txt", "r", stdin);

	cin >> n;

	w.resize(n);
	c.resize(n);
	notMatching.resize(n, 0);

	for (int i = 0; i < n - 1; i++) {
		int x, y;

		cin >> x >> y;
		x--;
		y--;

		w[x].push_back(y);
		w[y].push_back(x);
	}

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

	for (int i = 0; i < n; i++)
		for (int j = 0; j < w[i].size(); j++)
			if (c[i] != c[w[i][j]]) {

				visited.resize(n, false);
				if (root(i)) {
					cout << "YES" << endl << i+1;
					return;
				}

				fill(visited.begin(), visited.end(), false);
				if (root(w[i][j])) {
					cout << "YES" << endl << w[i][j]+1;
					return;
				}

				cout << "NO";
				return;
			}
	cout << "YES" << endl << 1;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

void main() {

	//freopen("input.txt", "r", stdin);

	int n;
	cin >> n;

	vector<vector<int>> w;
	vector<int> c;
	vector<int> notMatching;

	w.resize(n);
	c.resize(n);
	notMatching.resize(n, 0);

	for (int i = 0; i < n - 1; i++) {
		int x, y;

		cin >> x >> y;
		x--;
		y--;

		w[x].push_back(y);
		w[y].push_back(x);
	}

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

	int notMatchingCurrentMoreThen1 = 0;
	int root = -1;

	for (int i = 0; i < n; i++) {
		int thisColor = c[i];
		int notMachingWithCurrent = 0;
		int whichNotMatch;

		for (int j = 0; j < w[i].size(); j++)
			if (thisColor != c[w[i][j]]) notMachingWithCurrent++, whichNotMatch = w[i][j];

		if (notMachingWithCurrent == 0) continue;

		if (notMachingWithCurrent == 1) {
			notMatching[i]++;
			notMatching[whichNotMatch]++;
		}

		if (notMachingWithCurrent > 1) {
			notMatchingCurrentMoreThen1++;
			root = i;
		}

		if (notMatchingCurrentMoreThen1 > 1) {
			cout << "NO";
			return;
		}
	}

	cout << "YES" << endl;
	for (int i = 0; i < n; i++) if (notMatching[i]>2) root = i;
	if (root == -1) for (int i = 0; i < n; i++) if (notMatching[i] == 2) root = i;

	if (root != -1) {
		cout << root + 1;
		return;
	}
	cout << 1;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <limits>
#include <cmath>
#include <cstdlib>
#include <string.h>
#include <ctime>
#include <assert.h>

using namespace std;

#define VI vector<int>
#define VVI vector<VI >
#define VB vector<bool>
#define VVB vector<VB >
#define VS vector<string>
#define PII pair<int, int>
#define VPII vector<pair<int, int> >
#define REP(var, startFrom, endTo) for(int var = startFrom; var < (int)endTo; ++var)

template <typename T>
inline const T MAX(T a, T b) { return ((a) > (b) ? (a) : (b)); }
template <typename T>
inline const T MIN(T a, T b) { return ((a) > (b) ? (b) : (a)); }
template <typename T>
inline const T ABS(T a) { return (((a) > 0) ? (a) : (-(a))); }

VVI adj;
VI colors;
VB visited;

bool dfs(int here, int color)
{
	visited[here] = true;
	for (int i = 0; i < adj[here].size(); ++i)
	{
		int there = adj[here][i];
		if (!visited[there])
		{
			if (colors[there] == color)
				return dfs(there, color);
			else
				return false;
		}
	}
	return true;
}

bool process(int root)
{
	visited = VB(adj.size(), false);
	visited[root] = true;
	for (int i = 0; i < adj[root].size(); ++i)
	{
		int there = adj[root][i];

		if (!visited[there])
		{
			if (!dfs(there, colors[adj[root][0]]))
				return false;
		}
	}
	return true;
}

int solve()
{
	set<int> check;
	for (int here = 0; here < adj.size(); ++here)
		for (int j = 0; j < adj[here].size(); ++j)
		{
			int there = adj[here][j];
			if (colors[here] != colors[there])
			{
				check.insert(here);
				check.insert(there);
			}
		}

	if (check.empty())
		return 1;
	for each (auto it in check)
		if (process(it))
			return it + 1;
	return -1;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	int n;
	cin >> n;

	adj = VVI(n); colors = VI(n);
	REP(i, 0, n - 1)
	{
		int u, v;
		cin >> u >> v;
		--u; --v;

		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	REP(i, 0, n)
		cin >> colors[i];

	int ans = solve();
	if (ans < 0)
		cout << "NO\n";
	else
		cout << "YES\n" << ans << endl;

	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <limits>
#include <cmath>
#include <cstdlib>
#include <string.h>
#include <ctime>
#include <assert.h>

using namespace std;

#define VI vector<int>
#define VVI vector<VI >
#define VB vector<bool>
#define VVB vector<VB >
#define VS vector<string>
#define PII pair<int, int>
#define VPII vector<pair<int, int> >
#define REP(var, startFrom, endTo) for(int var = startFrom; var < (int)endTo; ++var)

template <typename T>
inline const T MAX(T a, T b) { return ((a) > (b) ? (a) : (b)); }
template <typename T>
inline const T MIN(T a, T b) { return ((a) > (b) ? (b) : (a)); }
template <typename T>
inline const T ABS(T a) { return (((a) > 0) ? (a) : (-(a))); }

VVI adj;
VI colors;
VB visited;

bool dfs(int here, int color)
{
	visited[here] = true;
	for (int i = 0; i < adj[here].size(); ++i)
	{
		int there = adj[here][i];
		if (!visited[there])
		{
			if (colors[there] == color)
				return dfs(there, color);
			else
				return false;
		}
	}
	return true;
}

bool process(int root)
{
	visited = VB(adj.size(), false);
	visited[root] = true;
	for (int i = 0; i < adj[root].size(); ++i)
	{
		int there = adj[root][i];

		if (!visited[there])
		{
			if (!dfs(there, colors[adj[root][0]]))
				return false;
		}
	}
	return true;
}

int solve()
{
	int root1 = -1, root2 = -1;
	for (int here = 0; here < adj.size(); ++here)
		for (int j = 0; j < adj[here].size(); ++j)
		{
			int there = adj[here][j];
			if (colors[here] != colors[there])
			{
				root1 = here;
				root2 = there;
			}
		}

	if (root1 < 0)
		return 1;

	bool res1 = process(root1), res2 = process(root2);
	if (res1)
		return root1 + 1;
	if (res2)
		return root2 + 1;
	return -1;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	int n;
	cin >> n;

	adj = VVI(n); colors = VI(n);
	REP(i, 0, n - 1)
	{
		int u, v;
		cin >> u >> v;
		--u; --v;

		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	REP(i, 0, n)
		cin >> colors[i];

	int ans = solve();
	if (ans < 0)
		cout << "NO\n";
	else
		cout << "YES\n" << ans << endl;

	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <limits>
#include <cmath>
#include <cstdlib>
#include <string.h>
#include <ctime>
#include <assert.h>

using namespace std;

#define VI vector<int>
#define VVI vector<VI >
#define VB vector<bool>
#define VVB vector<VB >
#define VS vector<string>
#define PII pair<int, int>
#define VPII vector<pair<int, int> >
#define REP(var, startFrom, endTo) for(int var = startFrom; var < (int)endTo; ++var)

template <typename T>
inline const T MAX(T a, T b) { return ((a) > (b) ? (a) : (b)); }
template <typename T>
inline const T MIN(T a, T b) { return ((a) > (b) ? (b) : (a)); }
template <typename T>
inline const T ABS(T a) { return (((a) > 0) ? (a) : (-(a))); }

VVI adj;
VI colors;
VB visited;

bool dfs(int here, int color)
{
	visited[here] = true;
	for (int i = 0; i < adj[here].size(); ++i)
	{
		int there = adj[here][i];
		if (!visited[there])
		{
			if (colors[there] == color)
				return dfs(there, color);
			else
				return false;
		}
	}
	return true;
}

bool process(int root)
{
	visited = VB(adj.size(), false);
	visited[root] = true;
	for (int i = 0; i < adj[root].size(); ++i)
	{
		int there = adj[root][i];
		if (!visited[there])
		{
			if (!dfs(there, colors[adj[root][i]]))
				return false;
		}
	}
	return true;
}

int solve()
{
	set<int> check;
	for (int here = 0; here < adj.size(); ++here)
		for (int j = 0; j < adj[here].size(); ++j)
		{
			int there = adj[here][j];
			if (colors[here] != colors[there])
			{
				check.insert(here);
				check.insert(there);
			}
		}

	if (check.empty())
		return 1;
	for each (auto it in check)
		if (process(it))
			return it + 1;
	return -1;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	int n;
	cin >> n;

	VI src, dst;
	src = dst = VI(n - 1);
	REP(i, 0, n - 1)
	{
		int u, v;
		cin >> src[i] >> dst[i];
		src[i]--; dst[i]--;
	}

	colors = VI(n);
	REP(i, 0, n)
		cin >> colors[i];

	VI d = VI(n); int cnt = 0;
	for (int i = 0; i < n - 1; ++i)
	{
		if (colors[src[i]] != colors[dst[i]])
		{
			++cnt;
			++d[src[i]];
			++d[dst[i]];
		}
	}

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

	cout << "NO\n";
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <limits>
#include <cmath>
#include <cstdlib>
#include <string.h>
#include <ctime>
#include <assert.h>

using namespace std;

#define VI vector<int>
#define VVI vector<VI >
#define VB vector<bool>
#define VVB vector<VB >
#define VS vector<string>
#define PII pair<int, int>
#define VPII vector<pair<int, int> >
#define REP(var, startFrom, endTo) for(int var = startFrom; var < (int)endTo; ++var)

template <typename T>
inline const T MAX(T a, T b) { return ((a) > (b) ? (a) : (b)); }
template <typename T>
inline const T MIN(T a, T b) { return ((a) > (b) ? (b) : (a)); }
template <typename T>
inline const T ABS(T a) { return (((a) > 0) ? (a) : (-(a))); }

VVI adj;
VI colors;
VB visited;

bool dfs(int here, int color)
{
	visited[here] = true;
	for (int i = 0; i < adj[here].size(); ++i)
	{
		int there = adj[here][i];
		if (!visited[there])
		{
			if (colors[there] == color)
				return dfs(there, color);
			else
				return false;
		}
	}
}

bool process(int root)
{
	visited = VB(adj.size(), false);
	visited[root] = true;
	for (int i = 0; i < adj[root].size(); ++i)
	{
		int there = adj[root][i];

		if (!visited[there])
		{
			if (!dfs(there, colors[adj[root][i]]))
				return false;
		}
	}
	return true;
}

int solve()
{
	set<int> check;
	for (int here = 0; here < adj.size(); ++here)
		for (int j = 0; j < adj[here].size(); ++j)
		{
			int there = adj[here][j];
			if (colors[here] != colors[there])
			{
				check.insert(here);
				check.insert(there);
			}
		}

	if (check.empty())
		return 1;
	for each (auto it in check)
		if (process(it))
			return it + 1;
	return -1;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	int n;
	cin >> n;

	adj = VVI(n); colors = VI(n);
	REP(i, 0, n - 1)
	{
		int u, v;
		cin >> u >> v;
		--u; --v;

		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	REP(i, 0, n)
		cin >> colors[i];

	int ans = solve();
	if (ans < 0)
		cout << "NO\n";
	else
		cout << "YES\n" << ans << endl;

	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <limits>
#include <cmath>
#include <cstdlib>
#include <string.h>
#include <ctime>
#include <assert.h>

using namespace std;

#define VI vector<int>
#define VVI vector<VI >
#define VB vector<bool>
#define VVB vector<VB >
#define VS vector<string>
#define PII pair<int, int>
#define VPII vector<pair<int, int> >
#define REP(var, startFrom, endTo) for(int var = startFrom; var < (int)endTo; ++var)

template <typename T>
inline const T MAX(T a, T b) { return ((a) > (b) ? (a) : (b)); }
template <typename T>
inline const T MIN(T a, T b) { return ((a) > (b) ? (b) : (a)); }
template <typename T>
inline const T ABS(T a) { return (((a) > 0) ? (a) : (-(a))); }

VVI adj;
VI colors;
VB visited;

int visit = 0;
bool dfs(int here, int color)
{
	visited[here] = true;
	++visit;
	for (int i = 0; i < adj[here].size(); ++i)
	{
		int there = adj[here][i];
		if (!visited[there])
		{
			if (colors[there] == color)
				return dfs(there, color);
			else
				return false;
		}
	}
	return visit == visited.size();
}

bool process(int root)
{
	visited = VB(adj.size(), false);
	visited[root] = true;
	visit = 0;
	++visit;
	for (int i = 0; i < adj[root].size(); ++i)
	{
		int there = adj[root][i];
		if (!visited[there])
		{
			if (dfs(there, colors[adj[root][0]]))
				return true;
		}
	}
	return false;
}

int solve()
{
	int root1 = -1, root2 = -1;
	for (int here = 0; here < adj.size(); ++here)
		for (int j = 0; j < adj[here].size(); ++j)
		{
			int there = adj[here][j];
			if (colors[here] != colors[there])
			{
				root1 = here;
				root2 = there;
			}
		}

	if (root1 < 0)
		return 1;

	bool res1 = process(root1), res2 = process(root2);
	if (res1)
		return root1 + 1;
	if (res2)
		return root2 + 1;
	return -1;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	int n;
	cin >> n;

	adj = VVI(n); colors = VI(n);
	REP(i, 0, n - 1)
	{
		int u, v;
		cin >> u >> v;
		--u; --v;

		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	REP(i, 0, n)
		cin >> colors[i];

	int ans = solve();
	if (ans < 0)
		cout << "NO\n";
	else
		cout << "YES\n" << ans << endl;

	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <limits>
#include <cmath>
#include <cstdlib>
#include <string.h>
#include <ctime>
#include <assert.h>

using namespace std;

#define VI vector<int>
#define VVI vector<VI >
#define VB vector<bool>
#define VVB vector<VB >
#define VS vector<string>
#define PII pair<int, int>
#define VPII vector<pair<int, int> >
#define REP(var, startFrom, endTo) for(int var = startFrom; var < (int)endTo; ++var)

template <typename T>
inline const T MAX(T a, T b) { return ((a) > (b) ? (a) : (b)); }
template <typename T>
inline const T MIN(T a, T b) { return ((a) > (b) ? (b) : (a)); }
template <typename T>
inline const T ABS(T a) { return (((a) > 0) ? (a) : (-(a))); }

VVI adj;
VI colors;
VB visited;

bool dfs(int here, int color)
{
	visited[here] = true;
	for (int i = 0; i < adj[here].size(); ++i)
	{
		int there = adj[here][i];
		if (!visited[there])
		{
			if (colors[there] == color)
				return dfs(there, color);
			else
				return false;
		}
	}
	return true;
}

bool process(int root)
{
	visited = VB(adj.size(), false);
	visited[root] = true;
	for (int i = 0; i < adj[root].size(); ++i)
	{
		int there = adj[root][i];

		if (!visited[there])
		{
			if (!dfs(there, colors[adj[root][0]]))
				return false;
		}
	}
	return true;
}

int solve()
{
	set<int> check;
	for (int here = 0; here < adj.size(); ++here)
		for (int j = 0; j < adj[here].size(); ++j)
		{
			int there = adj[here][j];
			if (colors[here] != colors[there])
			{
				check.insert(here);
				check.insert(there);
			}
		}

	if (check.empty())
		return 1;
	for (auto it : check)
		if (process(it))
			return it + 1;
	return -1;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	int n;
	cin >> n;

	adj = VVI(n); colors = VI(n);
	REP(i, 0, n - 1)
	{
		int u, v;
		cin >> u >> v;
		--u; --v;

		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	REP(i, 0, n)
		cin >> colors[i];

	int ans = solve();
	if (ans < 0)
		cout << "NO\n";
	else
		cout << "YES\n" << ans << endl;

	return 0;
}