//============================================================================
// Name        : Brahmi Zied
// Author      : brahZied
// Version     : 2022
// Description : Road to specialist
//============================================================================
/*
    STAY ORGANIZED
    CHANGE YOUR APPROACH
    BE CONFIDENT
*/
// when you train write the algos from 0
//Think different approaches (trace TestCase,think with symbols,think with PICS,numberTheory,bs,dp,greedy,graphs,shortest paths,mst,dsu,LCA(binary lifting?))
//Stay Calm
// IN TRAINING DO NOT SEE WRONG TEST CASES AFTER SUBMITTING!
//Look for special cases
//Beware of overflow and array bounds
//Think the problem backwards
#include <bits/stdc++.h>
using namespace std;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

typedef long long ll;
typedef long double ld;
ll n,m,k,g,a,b,d,c;
const ll prime=1e9+7;
const int nax=2e5+5;
vector<int> adj[nax];
int nodeFurthest=-1;
int furthest=-1;
void dfs(int node,int parent,int level){
	
	if(level>=furthest){
		nodeFurthest=node;
		furthest=level;
	}
	
	for(int i=0;i<(int)adj[node].size();i++){
		if(adj[node][i]!=parent){
			dfs(adj[node][i],node,level+1);
		}
	}
}
void dfs1(int node,int parent){
	cout << node+1 << " ";
	
	for(int i=0;i<(int)adj[node].size();i++){
		if(adj[node][i]!=parent){
			dfs1(adj[node][i],node);
		}
	}
	
}
void solve(){
	cin >> n ;
	int from,to;
	for(int i=0;i<n-1;i++){
		cin >> from >> to;
		from--;
		to--;
		adj[from].push_back(to);
		adj[to].push_back(from);
	}
	
	dfs(from,-1,0);
	
	dfs(nodeFurthest,-1,0);
	if(furthest<=3){
		cout << "NO"<<"\n";
		return;
	}
	int curr ,next;
	for(int i=0;i<n;i++){
		if((int)adj[i].size()<=1) continue;
		for(int j=0;j<(int)adj[i].size();j++){
			if(adj[adj[i][j]].size()>=2){
				next=adj[i][j];
				curr=i;
				break;
			}
		}
	}
	debug() << imie(curr) << imie(next);
	cout <<"YES"<<"\n";
	dfs1(curr,next);
	dfs1(next,curr);
	cout <<"\n";
}
 
int main() {
	fastInp;
	//freopen("mootube.in","r",stdin);
	//freopen("t.out","w",stdout);
	int tc=1;
	//cout << res[9] << "\n";
	//reverse(res.begin(),res.end());
	
	//cin >> tc;
	//cout << setprecision(10)<<fixed;
	//int i=1;
	//tempTC=tc;
	while(tc--){
		//cout <<"HELLO"<<endl;
		//cout << "Case #"<<i<<": " ;
		//cout << setprecision(10) << "\n";
		solve();
		//i++;
	}
	/*Slong long number;
	while(cin >> number){
		if(number==0) break;
		long long i=(long long)sqrt(number);
		if(i*i==number){
			cout <<"yes"<<"\n";
		}else{
			cout <<"no"<<"\n";
		}
		
	}*/
	
	/*while(true){
		cin >> n >> m >>coin;
 
		if(n==0 && m==0&&coin==0){
			break;
		}
		solveUVA();
	}
	*/
	return 0;
}
