#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};

const int N=202020;
vector<int> g[N];
int c[N];
int cc[N];
int d[N];
int h[N];
void dfs1(int v,int p=0,int dd=0){
    d[v]=dd;
    for(int to:g[v])
        if(to^p)
            dfs1(to,v,dd+1);
}
void dfs2(int v,int p=0){
    h[v]=0;
    for(int to:g[v])
        if(to^p){
            dfs2(to,v);
            upx(h[v],h[to]+1);
        }
}
int q;
void dfs3(int v,int p=0){
    c[v]=q;
    sort(g[v].begin(),g[v].end(),[&](int x,int y){
        return h[x]<h[y];
    });
    for(int to:g[v]){
        if(to^p){
            q++;
            dfs3(to,v);
            q++;
        }
    }
}
int32_t main(){
    int n;
    cin>>n;
    forn(i,n-1){
        int x,y;
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }
    dfs1(1);
    int s1=max_element(d+1,d+n+1)-d;
    dfs1(s1);
    int s2=max_element(d+1,d+n+1)-d;
    dfs2(s1);
    q=1;
    dfs3(s1);
    for(int i=1;i<=n;++i){
        cc[i]=c[i];
    }
    dfs2(s2);
    q=1;
    dfs3(s2);
    int o1=*max_element(c+1,c+n+1);
    int o2=*max_element(cc+1,cc+n+1);
    if(o1<o2){
        for(int i=1;i<=n;++i)cout<<c[i]<<' ';
    }else{
        for(int i=1;i<=n;++i)cout<<cc[i]<<' ';
    }
    cout<<'\n';
    return 0;
}

#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")
#define io_init cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(20)
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//Dijkstra法
typedef pair<ll, ll> P;

void Dijkstra(int s, vector<vector<pair<ll,ll>>>& g, vector<ll>& d) {
	priority_queue<P, vector<P>, greater<P>> q;
	d = vector<ll>(g.size(), INF_LL);
	d[s] = 0;
	q.push(P{ 0,s });

	while (!q.empty()) {
		P p = q.top(); q.pop();
		ll v = p.second;
		if (d[v] < p.first)continue;
		for (int i = 0; i < g[v].size(); i++) {
			auto e = g[v][i];
			if (d[e.first] > d[v] + e.second) {
				d[e.first] = d[v] + e.second;
				q.push(P{ d[e.first] , e.first });
			}
		}
	}
}

int main() {
	int a, b, x, y;
	cin >> a >> b >> x >> y;
	a--; b--;
	vector < vector<pair<ll, ll>>> G(200);
	for (int i = 0; i < 100; i++) {
		G[i].push_back({ i+100,x });
		G[i+100].push_back({ i,x });
	}
	for (int i = 0; i < 99; i++) {
		G[i + 1].push_back({ i + 100,x });
		G[i + 100].push_back({ i + 1 ,x });
		G[i + 1].push_back({ i,y });
		G[i].push_back({ i + 1,y });
	}
	vector<ll> d;
	Dijkstra(a, G, d);
	cout << d[b + 100] << endl;
}
	