#include <bits/stdc++.h>
using namespace std;

const int MAXN=2e5+10;
const int MAXMASK=(1<<20);

bool ok[MAXN];
int sz[MAXN];
long long pat[MAXN];
int cnt[MAXMASK];
int msk[MAXN];
int val[MAXN];
long long bad[MAXN];
long long ans[MAXN];
vector<int> g[MAXN];
string s;

void prep(int u,int p)
{
    sz[u]=1;
    for(auto v:g[u])
        if(ok[v]&&v!=p)
            prep(v,u),sz[u]+=sz[v];
}

int centroid(int u,int r)
{
    for(auto v:g[u])
        if(ok[v]&&sz[v]<sz[u]&&sz[v]>=sz[r]/2)
            return centroid(v,r);
    return u;
}

void add(int u,int p)
{
    msk[u]^=(1<<val[u]);
    cnt[msk[u]]++;
    for(auto v:g[u])
        if(ok[v]&&v!=p)
            msk[v]=msk[u],add(v,u);
}

void rem(int u,int p)
{
    cnt[msk[u]]--;
    pat[u]=0;
    bad[u]=0;
    msk[u]=0;
    for(auto v:g[u])
        if(ok[v]&&v!=p)
            rem(v,u);
}

void clr(int u,int p)
{
    pat[u]=0;
    bad[u]=0;
    msk[u]=0;
    for(auto v:g[u])
        if(ok[v]&&v!=p)
            clr(v,u);
}

void calc(int u,int p,int mask)
{
    mask^=(1<<val[u]);
    pat[u]+=cnt[mask];
    bad[u]+=cnt[mask];
    if(mask==0||__builtin_popcount(mask)==1)
        pat[u]++;
    for(int i=0;i<20;i++)
        pat[u]+=cnt[mask^(1<<i)],bad[u]+=cnt[mask^(1<<i)];
    for(auto v:g[u])
        if(ok[v]&&v!=p)
            calc(v,u,mask),pat[u]+=pat[v],bad[u]+=bad[v];
    ans[u]+=pat[u];
}

void solve(int u)
{
    prep(u,0);
    u=centroid(u,u);
    for(auto v:g[u])
        if(ok[v])
            add(v,u);
    for(auto v:g[u])
    {
        if(ok[v])
        {
            rem(v,u);
            calc(v,u,(1<<val[u]));
            pat[u]+=pat[v];
            bad[u]+=bad[v];
            clr(v,u);
            add(v,u);
        }
    }
    for(auto v:g[u])
        if(ok[v])
            rem(v,u);
    ans[u]+=pat[u]-bad[u]/2+1;
    pat[u]=0;
    bad[u]=0;
    ok[u]=false;
    for(auto v:g[u])
        if(ok[v])
            solve(v);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,u,v;
    cin>>n;
    for(int i=1;i<n;i++)
        cin>>u>>v,g[u].emplace_back(v),g[v].emplace_back(u);
    cin>>s;
    for(int i=0;i<n;i++)
        val[i+1]=s[i]-'a',ok[i+1]=true;
    solve(1);
    for(int i=1;i<=n;i++)
        cout<<ans[i]<<" ";
}


#include <bits/stdc++.h>
using namespace std;

const int MAXN=2e5+10;

bool ok[MAXN];
int sz[MAXN];
long long pat[MAXN];
int cnt[MAXN*5];
int msk[MAXN];
int val[MAXN];
long long bad[MAXN];
long long ans[MAXN];
vector<int> g[MAXN];
string s;

void prep(int u,int p)
{
    sz[u]=1;
    for(auto v:g[u])
        if(ok[v]&&v!=p)
            prep(v,u),sz[u]+=sz[v];
}

int centroid(int u,int r)
{
    for(auto v:g[u])
        if(ok[v]&&sz[v]<sz[u]&&sz[v]>=sz[r]/2)
            return centroid(v,r);
    return u;
}

void add(int u,int p)
{
    msk[u]^=(1<<val[u]);
    cnt[msk[u]]++;
    for(auto v:g[u])
        if(ok[v]&&v!=p)
            msk[v]=msk[u],add(v,u);
}

void rem(int u,int p)
{
    cnt[msk[u]]--;
    pat[u]=0;
    bad[u]=0;
    msk[u]=0;
    for(auto v:g[u])
        if(ok[v]&&v!=p)
            rem(v,u);
}

void calc(int u,int p,int mask)
{
    mask^=(1<<val[u]);
    pat[u]+=cnt[mask];
    bad[u]+=cnt[mask];
    if(mask==0)
        pat[u]++;
    for(int i=0;i<20;i++)
        pat[u]+=cnt[mask^(1<<i)],bad[u]+=cnt[mask^(1<<i)];
    for(auto v:g[u])
        if(ok[v]&&v!=p)
            calc(v,u,mask),pat[u]+=pat[v];
    ans[u]+=pat[u];
}

void solve(int u)
{
    prep(u,0);
    u=centroid(u,u);
    for(auto v:g[u])
        if(ok[v])
            add(v,u);
    for(auto v:g[u])
    {
        if(ok[v])
        {
            rem(v,u);
            calc(v,u,(1<<val[u]));
            add(v,u);
            pat[u]+=pat[v];
            bad[u]+=bad[v];
        }
    }
    for(auto v:g[u])
        if(ok[v])
            rem(v,u);
    ans[u]+=pat[u]-bad[u]/2+1;
    //cout<<u<<"\n";
    //for(int i=1;i<=5;i++)
    //    cout<<ans[i]<<" ";
    //cout<<"\n";
    ok[u]=false;
    for(auto v:g[u])
        if(ok[v])
            solve(v);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,u,v;
    cin>>n;
    for(int i=1;i<n;i++)
        cin>>u>>v,g[u].emplace_back(v),g[v].emplace_back(u);
    cin>>s;
    for(int i=0;i<n;i++)
        val[i+1]=s[i]-'a',ok[i+1]=true;
    solve(1);
    for(int i=1;i<=n;i++)
        cout<<ans[i]<<" ";
}


#include <bits/stdc++.h>
using namespace std;

const long long MAXN=1e6+10;

bool ok[MAXN];
long long sz[MAXN];
long long pat[MAXN];
long long cnt[MAXN];
long long msk[MAXN];
long long val[MAXN];
long long bad[MAXN];
long long ans[MAXN];
vector<long long> g[MAXN];
string s;

void prep(long long u,long long p)
{
    sz[u]=1;
    for(auto v:g[u])
        if(ok[v]&&v!=p)
            prep(v,u),sz[u]+=sz[v];
}

long long centroid(long long u,long long r)
{
    for(auto v:g[u])
        if(ok[v]&&sz[v]<sz[u]&&sz[v]>=sz[r]/2)
            return centroid(v,r);
    return u;
}

void add(long long u,long long p)
{
    msk[u]^=(1<<val[u]);
    cnt[msk[u]]++;
    for(auto v:g[u])
        if(ok[v]&&v!=p)
            msk[v]=msk[u],add(v,u);
}

void rem(long long u,long long p)
{
    cnt[msk[u]]--;
    pat[u]=0;
    bad[u]=0;
    msk[u]=0;
    for(auto v:g[u])
        if(ok[v]&&v!=p)
            rem(v,u);
}

void calc(long long u,long long p,long long mask)
{
    mask^=(1<<val[u]);
    pat[u]+=cnt[mask];
    bad[u]+=cnt[mask];
    if(mask==0)
        pat[u]++;
    for(long long i=0;i<20;i++)
        pat[u]+=cnt[mask^(1<<i)],bad[u]+=cnt[mask^(1<<i)];
    for(auto v:g[u])
        if(ok[v]&&v!=p)
            calc(v,u,mask),pat[u]+=pat[v];
    ans[u]+=pat[u];
}

void solve(long long u)
{
    prep(u,0);
    u=centroid(u,u);
    for(auto v:g[u])
        if(ok[v])
            add(v,u);
    for(auto v:g[u])
    {
        if(ok[v])
        {
            rem(v,u);
            calc(v,u,(1<<val[u]));
            pat[u]+=pat[v];
            bad[u]+=bad[v];
            rem(v,u);
            add(v,u);
        }
    }
    for(auto v:g[u])
        if(ok[v])
            rem(v,u);
    ans[u]+=pat[u]-bad[u]/2+1;
    ok[u]=false;
    for(auto v:g[u])
        if(ok[v])
            solve(v);
}

long long main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long n,u,v;
    cin>>n;
    for(long long i=1;i<n;i++)
        cin>>u>>v,g[u].emplace_back(v),g[v].emplace_back(u);
    cin>>s;
    for(long long i=0;i<n;i++)
        val[i+1]=s[i]-'a',ok[i+1]=true;
    solve(1);
    for(long long i=1;i<=n;i++)
        cout<<ans[i]<<" ";
}


#include <bits/stdc++.h>
using namespace std;

const long long MAXN=1e6+10;

bool ok[MAXN];
long long sz[MAXN];
long long pat[MAXN];
long long cnt[MAXN];
long long msk[MAXN];
long long val[MAXN];
long long bad[MAXN];
long long ans[MAXN];
vector<long long> g[MAXN];
string s;

void prep(long long u,long long p)
{
    sz[u]=1;
    for(auto v:g[u])
        if(ok[v]&&v!=p)
            prep(v,u),sz[u]+=sz[v];
}

long long centroid(long long u,long long r)
{
    for(auto v:g[u])
        if(ok[v]&&sz[v]<sz[u]&&sz[v]>=sz[r]/2)
            return centroid(v,r);
    return u;
}

void add(long long u,long long p)
{
    msk[u]^=(1<<val[u]);
    cnt[msk[u]]++;
    for(auto v:g[u])
        if(ok[v]&&v!=p)
            msk[v]=msk[u],add(v,u);
}

void rem(long long u,long long p)
{
    cnt[msk[u]]--;
    pat[u]=0;
    bad[u]=0;
    msk[u]=0;
    for(auto v:g[u])
        if(ok[v]&&v!=p)
            rem(v,u);
}

void clr(long long u,long long p)
{
    pat[u]=0;
    bad[u]=0;
    msk[u]=0;
    for(auto v:g[u])
        if(ok[v]&&v!=p)
            clr(v,u);
}

void calc(long long u,long long p,long long mask)
{
    mask^=(1<<val[u]);
    pat[u]+=cnt[mask];
    bad[u]+=cnt[mask];
    if(mask==0)
        pat[u]++;
    for(long long i=0;i<20;i++)
        pat[u]+=cnt[mask^(1<<i)],bad[u]+=cnt[mask^(1<<i)];
    for(auto v:g[u])
        if(ok[v]&&v!=p)
            calc(v,u,mask),pat[u]+=pat[v];
    ans[u]+=pat[u];
}

void solve(long long u)
{
    prep(u,0);
    u=centroid(u,u);
    for(auto v:g[u])
        if(ok[v])
            add(v,u);
    for(auto v:g[u])
    {
        if(ok[v])
        {
            rem(v,u);
            calc(v,u,(1<<val[u]));
            pat[u]+=pat[v];
            bad[u]+=bad[v];
            clr(v,u);
            add(v,u);
        }
    }
    for(auto v:g[u])
        if(ok[v])
            rem(v,u);
    ans[u]+=pat[u]-bad[u]/2+1;
    pat[u]=0;
    bad[u]=0;
    ok[u]=false;
    for(auto v:g[u])
        if(ok[v])
            solve(v);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long n,u,v;
    cin>>n;
    for(long long i=1;i<n;i++)
        cin>>u>>v,g[u].emplace_back(v),g[v].emplace_back(u);
    cin>>s;
    for(long long i=0;i<n;i++)
        val[i+1]=s[i]-'a',ok[i+1]=true;
    solve(1);
    for(long long i=1;i<=n;i++)
        cout<<ans[i]<<" ";
}


#include <bits/stdc++.h>
using namespace std;

const long long MAXN=1e6+10;

bool ok[MAXN];
long long sz[MAXN];
long long pat[MAXN];
long long cnt[MAXN];
long long msk[MAXN];
long long val[MAXN];
long long bad[MAXN];
long long ans[MAXN];
vector<long long> g[MAXN];
string s;

void prep(long long u,long long p)
{
    sz[u]=1;
    for(auto v:g[u])
        if(ok[v]&&v!=p)
            prep(v,u),sz[u]+=sz[v];
}

long long centroid(long long u,long long r)
{
    for(auto v:g[u])
        if(ok[v]&&sz[v]<sz[u]&&sz[v]>=sz[r]/2)
            return centroid(v,r);
    return u;
}

void add(long long u,long long p)
{
    msk[u]^=(1<<val[u]);
    cnt[msk[u]]++;
    for(auto v:g[u])
        if(ok[v]&&v!=p)
            msk[v]=msk[u],add(v,u);
}

void rem(long long u,long long p)
{
    cnt[msk[u]]--;
    pat[u]=0;
    bad[u]=0;
    msk[u]=0;
    for(auto v:g[u])
        if(ok[v]&&v!=p)
            rem(v,u);
}

void calc(long long u,long long p,long long mask)
{
    mask^=(1<<val[u]);
    pat[u]+=cnt[mask];
    bad[u]+=cnt[mask];
    if(mask==0)
        pat[u]++;
    for(long long i=0;i<20;i++)
        pat[u]+=cnt[mask^(1<<i)],bad[u]+=cnt[mask^(1<<i)];
    for(auto v:g[u])
        if(ok[v]&&v!=p)
            calc(v,u,mask),pat[u]+=pat[v];
    ans[u]+=pat[u];
}

void solve(long long u)
{
    prep(u,0);
    u=centroid(u,u);
    for(auto v:g[u])
        if(ok[v])
            add(v,u);
    for(auto v:g[u])
    {
        if(ok[v])
        {
            rem(v,u);
            calc(v,u,(1<<val[u]));
            pat[u]+=pat[v];
            bad[u]+=bad[v];
            rem(v,u);
            add(v,u);
        }
    }
    for(auto v:g[u])
        if(ok[v])
            rem(v,u);
    ans[u]+=pat[u]-bad[u]/2+1;
    pat[u]=0;
    bad[u]=0;
    ok[u]=false;
    for(auto v:g[u])
        if(ok[v])
            solve(v);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long n,u,v;
    cin>>n;
    for(long long i=1;i<n;i++)
        cin>>u>>v,g[u].emplace_back(v),g[v].emplace_back(u);
    cin>>s;
    for(long long i=0;i<n;i++)
        val[i+1]=s[i]-'a',ok[i+1]=true;
    solve(1);
    for(long long i=1;i<=n;i++)
        cout<<ans[i]<<" ";
}


#include <bits/stdc++.h>
using namespace std;

const long long MAXN=2e6+10;

bool ok[MAXN];
long long sz[MAXN];
long long pat[MAXN];
long long cnt[MAXN];
long long msk[MAXN];
long long val[MAXN];
long long bad[MAXN];
long long ans[MAXN];
vector<long long> g[MAXN];
string s;

void prep(long long u,long long p)
{
    sz[u]=1;
    for(auto v:g[u])
        if(ok[v]&&v!=p)
            prep(v,u),sz[u]+=sz[v];
}

long long centroid(long long u,long long r)
{
    for(auto v:g[u])
        if(ok[v]&&sz[v]<sz[u]&&sz[v]>=sz[r]/2)
            return centroid(v,r);
    return u;
}

void add(long long u,long long p)
{
    msk[u]^=(1<<val[u]);
    cnt[msk[u]]++;
    for(auto v:g[u])
        if(ok[v]&&v!=p)
            msk[v]=msk[u],add(v,u);
}

void rem(long long u,long long p)
{
    cnt[msk[u]]--;
    pat[u]=0;
    bad[u]=0;
    msk[u]=0;
    for(auto v:g[u])
        if(ok[v]&&v!=p)
            rem(v,u);
}

void clr(long long u,long long p)
{
    pat[u]=0;
    bad[u]=0;
    msk[u]=0;
    for(auto v:g[u])
        if(ok[v]&&v!=p)
            clr(v,u);
}

void calc(long long u,long long p,long long mask)
{
    mask^=(1<<val[u]);
    pat[u]+=cnt[mask];
    bad[u]+=cnt[mask];
    if(mask==0||__builtin_popcount(mask)==1)
        pat[u]++;
    for(long long i=0;i<20;i++)
        pat[u]+=cnt[mask^(1<<i)],bad[u]+=cnt[mask^(1<<i)];
    for(auto v:g[u])
        if(ok[v]&&v!=p)
            calc(v,u,mask),pat[u]+=pat[v],bad[u]+=bad[v];
    ans[u]+=pat[u];
}

void solve(long long u)
{
    prep(u,0);
    u=centroid(u,u);
    for(auto v:g[u])
        if(ok[v])
            add(v,u);
    for(auto v:g[u])
    {
        if(ok[v])
        {
            rem(v,u);
            calc(v,u,(1<<val[u]));
            pat[u]+=pat[v];
            bad[u]+=bad[v];
            clr(v,u);
            add(v,u);
        }
    }
    for(auto v:g[u])
        if(ok[v])
            rem(v,u);
    ans[u]+=pat[u]-bad[u]/2+1;
    pat[u]=0;
    bad[u]=0;
    ok[u]=false;
    for(auto v:g[u])
        if(ok[v])
            solve(v);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long n,u,v;
    cin>>n;
    for(long long i=1;i<n;i++)
        cin>>u>>v,g[u].emplace_back(v),g[v].emplace_back(u);
    cin>>s;
    for(long long i=0;i<n;i++)
        val[i+1]=s[i]-'a',ok[i+1]=true;
    solve(1);
    for(long long i=1;i<=n;i++)
        cout<<ans[i]<<" ";
}


#include <bits/stdc++.h>
using namespace std;

const int MAXN=1e6+10;

bool ok[MAXN];
int sz[MAXN];
long long pat[MAXN];
int cnt[MAXN];
int msk[MAXN];
int val[MAXN];
long long bad[MAXN];
long long ans[MAXN];
vector<int> g[MAXN];
string s;

void prep(int u,int p)
{
    sz[u]=1;
    for(auto v:g[u])
        if(ok[v]&&v!=p)
            prep(v,u),sz[u]+=sz[v];
}

int centroid(int u,int r)
{
    for(auto v:g[u])
        if(ok[v]&&sz[v]<sz[u]&&sz[v]>=sz[r]/2)
            return centroid(v,r);
    return u;
}

void add(int u,int p)
{
    msk[u]^=(1<<val[u]);
    cnt[msk[u]]++;
    for(auto v:g[u])
        if(ok[v]&&v!=p)
            msk[v]=msk[u],add(v,u);
}

void rem(int u,int p)
{
    cnt[msk[u]]--;
    pat[u]=0;
    bad[u]=0;
    msk[u]=0;
    for(auto v:g[u])
        if(ok[v]&&v!=p)
            rem(v,u);
}

void calc(int u,int p,int mask)
{
    mask^=(1<<val[u]);
    pat[u]+=cnt[mask];
    bad[u]+=cnt[mask];
    if(mask==0)
        pat[u]++;
    for(int i=0;i<20;i++)
        pat[u]+=cnt[mask^(1<<i)],bad[u]+=cnt[mask^(1<<i)];
    for(auto v:g[u])
        if(ok[v]&&v!=p)
            calc(v,u,mask),pat[u]+=pat[v];
    ans[u]+=pat[u];
}

void solve(int u)
{
    prep(u,0);
    u=centroid(u,u);
    for(auto v:g[u])
        if(ok[v])
            add(v,u);
    for(auto v:g[u])
    {
        if(ok[v])
        {
            rem(v,u);
            calc(v,u,(1<<val[u]));
            pat[u]+=pat[v];
            bad[u]+=bad[v];
            rem(v,u);
            add(v,u);
        }
    }
    for(auto v:g[u])
        if(ok[v])
            rem(v,u);
    ans[u]+=pat[u]-bad[u]/2+1;
    ok[u]=false;
    for(auto v:g[u])
        if(ok[v])
            solve(v);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,u,v;
    cin>>n;
    for(int i=1;i<n;i++)
        cin>>u>>v,g[u].emplace_back(v),g[v].emplace_back(u);
    cin>>s;
    for(int i=0;i<n;i++)
        val[i+1]=s[i]-'a',ok[i+1]=true;
    solve(1);
    for(int i=1;i<=n;i++)
        cout<<ans[i]<<" ";
}


//                             In The Name Of Allah
//                             	Mohammad Hosseini
//                                     190
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

const int N = 2e5 + 100, OO = 724249387, T = (1 << 20) + 10, M = 1e9 + 7, P = 6151, SQ = 280, lg = 24;
typedef pair <int, int> pii;
bool mark[N];
int sz[N], ans[N], mp[T], a[N];
vector <int> v[N];

void dsz(int x, int y) {
	sz[x] = 1;
	for(auto u : v[x])
		if(!mark[u] && u != y)
			dsz(u, x), sz[x] += sz[u];
}

int centroid(int x, int y, int z) {
	for(auto u : v[x])
		if(!mark[u] && u != y && sz[u] * 2 >= z)
			return centroid(u, x, z);
	return x;
}

void get(int x, int y, int cnt, int t) {
	cnt ^= (1 << a[x]);
	mp[cnt] += t;
	for(auto u : v[x])
		if(!mark[u] && u != y)
			get(u, x, cnt, t);
}

int cal(int x, int y, int cnt) {
	cnt ^= (1 << a[x]);
	int t = mp[cnt];
	for(int i = 0; i < 20; i++) {
		int cmp = cnt ^ (1 << i);
		t += mp[cmp];
	}
	for(auto u : v[x])
		if(u != y && !mark[u])
			t += cal(u, x, cnt);
	ans[x] += t;
	return t;
}

void solve(int x) {
	dsz(x, 0);
	x = centroid(x, 0, sz[x]);
	get(x, 0, 0, +1);
	int h = 0;
	for(auto u : v[x]) {
		if(mark[u])
			continue;
		get(u, x, (1 << a[x]), -1);
		h += cal(u, x, 0);
		get(u, x, (1 << a[x]), +1);
	}
	h -= mp[0];
	ans[x] += mp[0];
	for(int i = 0; i < 20; i++) {
		h -= mp[(1 << i)], ans[x] +=mp[(1 << i)];
	}
	h++;
	ans[x] += h / 2;
	get(x, 0, 0, -1);
	mark[x] = true;
	for(auto u : v[x])
		if(!mark[u])
			solve(u);
}

int32_t main() {
	use_fast;
	int n;
	cin >> n;
	for(int i = 1; i < n; i++) {
		int x, y;
		cin >> x >> y;
		v[x].pb(y);
		v[y].pb(x);
	}
	for(int i = 1; i <= n; i++) {
		char c;
		cin >> c;
		a[i] = c - 'a';
	}
	solve(1);
	for(int i = 1; i <= n; i++)
		cout << ans[i] << " ";
	cout << endl;
	return 0;
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- uploaded by ubuntu 20.04
5- ...
*/


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define mp make_pair
#define ins insert
#define sz(x) (int)x.size()
#define whoami(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); whi(_it, args); }

void whi(istream_iterator<string> it) { cerr<<"\n"; }

template<typename T, typename... Args>
void whi(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<" "<<a<<" "; whi(++it, args...); }

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed); cerr.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed); cerr.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

const int MOD = 1000000007;
const ll INF = 4e18;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
//ordered_set = order_of_key(.)
//ordered_set = find_by_order(.)
typedef ordered_set<int> OSI;
typedef ordered_set<ll> OSL;
typedef ordered_multiset<int> MOSI;
typedef ordered_multiset<ll> MOSL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int sze[MV], when[(1<<LMV)];
ll arr[MV], bt[(1<<LMV)];
bool isCrtd[MV];
string sd;
VI G[MV];
ll gs;
int tx;

void dfs_vis2(int s, int p)
{
	sze[s] = 1;
	for(auto u : G[s])
	{
		if((u != p) && !isCrtd[u])
		{
			dfs_vis2(u, s);
			sze[s] += sze[u];
		}
	}
	return;
}

PII cent_find(int s, int p, int rt)
{
	int msz = 0;
	PII centroid = {0, MV};
	for(auto u : G[s])
	{
		if((u != p) && !isCrtd[u] && (sze[s] > sze[rt]/2))
		{
			PII px = cent_find(u, s, rt);
			if(centroid.ss > px.ss)
			centroid = px;
			msz = max(msz, sze[u]);
		}
	}
	msz = max(msz, sze[rt]-sze[s]);
	if(centroid.ss > msz)
	centroid = {s, msz};
	return centroid;
}

void dfs_sol2(int s, int p, int vl, int add)
{
	vl ^= (1<<(sd[s-1] - 'a'));
	if(when[vl] != tx)
	{
		when[vl] = tx;
		bt[vl] = 0;
	}
	bt[vl] += add;
	for(auto u : G[s])
	{
		if((u != p) && !isCrtd[u])
		dfs_sol2(u, s, vl, add);
	}
	return;
}

ll dfs_sol3(int s, int p, int vl)
{
	vl ^= (1<<(sd[s-1] - 'a'));
	ll tt = 0;
	for(int i=0;i<20;i++)
	{
		if(when[vl ^ (1<<i)] == tx)
		tt += bt[vl ^ (1<<i)];
		if(!(vl ^ (1<<i)))
		{
			gs++;
			tt++;
		}
	}
	if(when[vl] == tx)
	tt += bt[vl];
	if(!vl)
	{
		gs++;
		tt++;
	}
	for(auto u : G[s])
	{
		if((u != p) && !isCrtd[u])
		tt += dfs_sol3(u, s, vl);
	}
	arr[s] += tt;
	return tt;
}

void dfs_sol1(int s, int compsz)
{
	tx++;
	for(auto u : G[s])
	{
		if(!isCrtd[u])
		dfs_sol2(u, s, 0, 1);
	}
	gs = 0;
	for(auto u : G[s])
	{
		if(!isCrtd[u])
		{
			dfs_sol2(u, s, 0, -1);
			gs += dfs_sol3(u, s, (1<<(sd[s-1] - 'a')));
			dfs_sol2(u, s, 0, 1);
		}
	}
	gs >>= 1LL;
	arr[s] += gs;
	return;
}

void dfs_vis1(int s)
{
	dfs_vis2(s, -1);
	PII centroid = cent_find(s, -1, s);
	dfs_sol1(centroid.ff, sze[s]);
	isCrtd[centroid.ff] = 1;
	for(auto u : G[centroid.ff])
	{
		if(!isCrtd[u])
		dfs_vis1(u);
	}
	return;
}

void solve(int T)
{
	int n;
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int s,d;
		cin>>s>>d;
		G[s].pb(d);
		G[d].pb(s);
	}
	cin>>sd;
	tx = 0;
	dfs_vis1(1);
	for(int i=1;i<=n;i++)
	{
		arr[i]++;
		cout<<arr[i]<<" \n"[i == n];
	}
	return;
}

int main(void)
{
	FLASH();
	//freopen("cowjog.in", "r", stdin);
	//freopen("cowjog.out", "w", stdout);
	int T;
	T = 1;

#ifndef ONLINE_JUDGE
	time_t time_t1, time_t2;
	time_t1 = clock();
#endif

	//cin>>T;
	while(T--)
	solve(T);

#ifndef ONLINE_JUDGE
	time_t2 = clock();
	SETF();
	cerr<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
	UNSETF();
#endif

	return 0;
}


/// https://codeforces.com/contest/914/problem/E?locale=en

#include<bits/stdc++.h>
using namespace std;
const int maxn=2*1e5+5;
const int maxm=1<<21;

long long n,m;
string s;
vector<long long>v[maxn];
bool used[maxn];
long long d[maxn],ans[maxn];
long long bin[32];
long long bit[maxm];

void init_()
{
    int i=1;
    bin[0]=0;
    bin[1]=1;
    for(i=2;i<=22;i++)
        bin[i]=bin[i-1]*2;
}

void read()
{
    int i,a,b;
    cin>>n;
    m=n;
    for(i=1;i<n;i++)
    {
        cin>>a>>b;
        v[a].emplace_back(b);
        v[b].emplace_back(a);
    }
    cin>>s;
    s="#"+s;
}

long long dfs(int i,int par)
{
    int j,sz=v[i].size();
    d[i]=1;
    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            d[i]+=dfs(t,i);
    }
    return d[i];
}

long long centroid(int i,int par)
{
    int j,sz=v[i].size();
    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par&&d[t]>n/2)
            return centroid(t,i);
    }
    return i;
}

long long get_ans(long long x,int y)
{
    long long tans=0,i;

    for(i=0;i<21;i++)
        if(x==bin[i]&&y==1)
            tans++;

    tans+=bit[x];
    for(i=0;i<21;i++)
    {
        long long y=x;
        y^=1<<i;

        tans+=bit[y];
    }

    return tans;
}

long long solve(int i,int par,long long x,int y)
{
    long long j,sz=v[i].size(),tans=0;

    x^=1<<int(s[i]-'a');

    tans+=get_ans(x,y);

    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            tans+=solve(t,i,x,y);
    }
    //cout<<i<<" "<<tans<<endl;
    ans[i]+=tans;
    return tans;
}

void update(int i,int par,long long x,int y)
{
    int j,sz=v[i].size();

    x^=1<<int(s[i]-'a');
    bit[x]+=y;

    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            update(t,i,x,y);
    }
}

void c_decomposition(int i)
{
    n=dfs(i,0);
    int c=centroid(i,0);
    //cout<<c<<endl;
    used[c]=true;

    int sz=v[c].size();
    for(i=0;i<sz;i++)
    {
        int t=v[c][i];
        if(!used[t])
        {
            ans[c]+=solve(t,c,1<<int(s[c]-'a'),1);
            update(t,c,0,1);
            //cout<<" "<<c<<" "<<ans[c]<<endl;
        }
    }

    for(i=0;i<sz;i++)
    {
        int t=v[c][i];
        if(!used[t])
        {
            update(t,c,0,-1);
            solve(t,c,1<<int(s[c]-'a'),-1);
        }
    }

    for(i=0;i<sz;i++)
        if(!used[v[c][i]])
            c_decomposition(v[c][i]);
}

void print()
{
    int i;
    for(i=1;i<=m;i++)
        cout<<ans[i]+1<<" ";
    cout<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    init_();
    read();
    c_decomposition(1);
    print();
	return 0;
}


/// https://codeforces.com/contest/914/problem/E?locale=en

#include<bits/stdc++.h>
using namespace std;
const int maxn=2*1e5+5;
const int maxm=1<<21;

long long n,m;
string s;
vector<long long>v[maxn];
bool used[maxn];
long long d[maxn],ans[maxn];
long long bin[32];
long long bit[maxm];

void init_()
{
    int i=1;
    bin[0]=bin[1]=1;
    for(i=2;i<=22;i++)
        bin[i]=bin[i-1]*2;
}

void read()
{
    int i,a,b;
    cin>>n;
    m=n;
    for(i=1;i<n;i++)
    {
        cin>>a>>b;
        v[a].emplace_back(b);
        v[b].emplace_back(a);
    }
    cin>>s;
    s="#"+s;
}

long long dfs(int i,int par)
{
    int j,sz=v[i].size();
    d[i]=1;
    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            d[i]+=dfs(t,i);
    }
    return d[i];
}

long long centroid(int i,int par)
{
    int j,sz=v[i].size();
    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par&&d[t]>n/2)
            return centroid(t,i);
    }
    return i;
}

long long get_ans(long long x)
{
    long long tans=0,i;

    for(i=0;i<21;i++)
        if(x==bin[i])
            tans++;

    for(i=0;i<21;i++)
    {
        long long y=x;
        y^=1<<i;

        tans+=bit[y];
    }

    return tans;
}

long long solve(int i,int par,long long x)
{
    long long j,sz=v[i].size(),tans=0;

    x^=1<<int(s[i]-'a');

    tans+=get_ans(x);

    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            tans+=solve(t,i,x);
    }

    ans[i]+=tans;
    return tans;
}

void update(int i,int par,long long x,int y)
{
    int j,sz=v[i].size();

    x^=1<<int(s[i]-'a');
    bit[x]+=y;

    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            update(t,i,x,y);
    }
}

void c_decomposition(int i)
{
    n=dfs(i,0);
    int c=centroid(i,0);
    //cout<<i<<" "<<c<<endl;
    used[c]=true;

    int sz=v[c].size();
    for(i=0;i<sz;i++)
    {
        int t=v[c][i];
        if(!used[t])
        {
            ans[c]+=solve(t,c,1<<int(s[c]-'a'));
            update(t,c,0,1);
        }
    }

    for(i=0;i<sz;i++)
    {
        int t=v[c][i];
        if(!used[t])
        {
            update(t,c,0,-1);
            solve(t,c,1<<int(s[c]-'a'));
        }
    }

    for(i=0;i<sz;i++)
        if(!used[v[c][i]])
            c_decomposition(v[c][i]);
}

void print()
{
    int i;
    for(i=1;i<=m;i++)
        cout<<ans[i]+1<<" ";
    cout<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    init_();
    read();
    c_decomposition(1);
    print();
	return 0;
}


/// https://codeforces.com/contest/914/problem/E?locale=en

#include<bits/stdc++.h>
using namespace std;
const int maxn=2*1e5+5;
const int maxm=1<<21;

int n;
string s;
vector<int>v[maxn];
bool used[maxn];
int d[maxn],ans[maxn];
int bin[32];
int bit[maxm];

void init_()
{
    int i=1;
    bin[0]=bin[1]=1;
    for(i=2;i<=20;i++)
        bin[i]=bin[i-1]*2;
}

void read()
{
    int i,a,b;
    cin>>n;
    for(i=1;i<n;i++)
    {
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    cin>>s;
    s="#"+s;
}

int dfs(int i,int par)
{
    int j,sz=v[i].size();
    d[i]=1;
    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            d[i]+=dfs(t,i);
    }
    return d[i];
}

int centroid(int i,int par)
{
    int j,sz=v[i].size();
    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par&&d[t]>n/2)
            return centroid(t,i);
    }
    return i;
}

int get_ans(int x)
{
    int tans=0,i;

    for(i=0;i<=20;i++)
        if(x==bin[i])
            tans++;

    for(i=0;i<=20;i++)
    {
        int y=x;
        y^=1<<i;

        tans+=bit[y];
    }

    return tans;
}

int solve(int i,int par,int x)
{
    int j,sz=v[i].size(),tans=0;

    x^=1<<int(s[i]-'a');

    tans+=get_ans(x);

    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            tans+=solve(t,i,x);
    }

    ans[i]+=tans;
    return tans;
}

void update(int i,int par,int x,int y)
{
    int j,sz=v[i].size();

    x^=1<<int(s[i]-'a');
    bit[x]+=y;

    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            update(t,i,x,y);
    }
}

void c_decomposition(int i)
{
    dfs(i,0);
    int c=centroid(i,0);
    used[c]=true;

    memset(bit,0,sizeof(bit));

    int sz=v[c].size();
    for(i=0;i<sz;i++)
    {
        int t=v[c][i];
        if(!used[t])
        {
            ans[c]+=solve(t,c,1<<int(s[c]-'a'));
            update(t,c,0,1);
        }
    }

    for(i=0;i<sz;i++)
    {
        int t=v[c][i];
        if(!used[t])
        {
            update(t,c,0,-1);
            solve(t,c,1<<int(s[c]-'a'));
        }
    }

    for(i=1;i<=n;i++)
        if(!used[i])
            c_decomposition(i);
}

void print()
{
    int i;
    for(i=1;i<=n;i++)
        cout<<ans[i]+1<<" ";
    cout<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    init_();
    read();
    c_decomposition(1);
    memset(used,0,sizeof(used));
    memset(d,0,sizeof(d));
    print();
	return 0;
}


/// https://codeforces.com/contest/914/problem/E?locale=en

#include<bits/stdc++.h>
using namespace std;
const int maxn=2*1e5+5;
const int maxm=1<<21;

int n;
string s;
vector<int>v[maxn];
bool used[maxn];
int d[maxn],ans[maxn];
int bin[32];
int bit[maxm];

void init_()
{
    int i=1;
    bin[0]=bin[1]=1;
    for(i=2;i<=20;i++)
        bin[i]=bin[i-1]*2;
}

void read()
{
    int i,a,b;
    cin>>n;
    for(i=1;i<n;i++)
    {
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    cin>>s;
    s="#"+s;
}

int dfs(int i,int par)
{
    int j,sz=v[i].size();
    d[i]=1;
    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            d[i]+=dfs(t,i);
    }
    return d[i];
}

int centroid(int i,int par)
{
    int j,sz=v[i].size();
    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par&&d[t]>n/2)
            return centroid(t,i);
    }
    return i;
}

int get_ans(int x)
{
    int tans=0,i;

    for(i=0;i<=20;i++)
        if(x==bin[i])
            tans++;

    for(i=0;i<=20;i++)
    {
        int y=x;
        y^=1<<i;

        tans+=bit[y];
    }

    return tans;
}

int solve(int i,int par,int x)
{
    int j,sz=v[i].size(),tans=0;

    x^=1<<int(s[i]-'a');

    tans+=get_ans(x);

    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            tans+=solve(t,i,x);
    }

    ans[i]+=tans;
    return tans;
}

void update(int i,int par,int x,int y)
{
    int j,sz=v[i].size();

    x^=1<<int(s[i]-'a');
    bit[x]+=y;

    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            update(t,i,x,y);
    }
}

void c_decomposition(int i)
{
    dfs(i,0);
    int c=centroid(i,0);
    used[c]=true;

    memset(bit,0,sizeof(bit));

    int sz=v[c].size();
    for(i=0;i<sz;i++)
    {
        int t=v[c][i];
        if(!used[t])
        {
            ans[c]+=solve(t,c,1<<int(s[c]-'a'));
            update(t,c,0,1);
        }
    }

    for(i=0;i<sz;i++)
    {
        int t=v[c][i];
        if(!used[t])
        {
            update(t,c,0,-1);
            solve(t,c,1<<int(s[c]-'a'));
        }
    }

    for(i=1;i<=n;i++)
        if(!used[i])
            c_decomposition(i);
}

void print()
{
    int i;
    for(i=1;i<=n;i++)
        cout<<ans[i]+1<<" ";
    cout<<endl;
}

int main()
{
    init_();
    read();
    c_decomposition(1);
    memset(used,0,sizeof(used));
    memset(d,0,sizeof(d));
    print();
	return 0;
}


/// https://codeforces.com/contest/914/problem/E?locale=en

#include<bits/stdc++.h>
using namespace std;
const int maxn=2*1e5+5;
const int maxm=1<<21;

int n,m;
string s;
vector<int>v[maxn];
bool used[maxn];
int d[maxn],ans[maxn];
int bin[32];
int bit[maxm];

void init_()
{
    int i=1;
    bin[0]=bin[1]=1;
    for(i=2;i<=20;i++)
        bin[i]=bin[i-1]*2;
}

void read()
{
    int i,a,b;
    cin>>n;
    m=n;
    for(i=1;i<n;i++)
    {
        cin>>a>>b;
        v[a].emplace_back(b);
        v[b].emplace_back(a);
    }
    cin>>s;
    s="#"+s;
}

int dfs(int i,int par)
{
    int j,sz=v[i].size();
    d[i]=1;
    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            d[i]+=dfs(t,i);
    }
    return d[i];
}

int centroid(int i,int par)
{
    int j,sz=v[i].size();
    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par&&d[t]>n/2)
            return centroid(t,i);
    }
    return i;
}

int get_ans(int x)
{
    int tans=0,i;

    for(i=0;i<=20;i++)
        if(x==bin[i])
            tans++;

    for(i=0;i<=20;i++)
    {
        int y=x;
        y^=1<<i;

        tans+=bit[y];
    }

    return tans;
}

int solve(int i,int par,int x)
{
    int j,sz=v[i].size(),tans=0;

    x^=1<<int(s[i]-'a');

    tans+=get_ans(x);

    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            tans+=solve(t,i,x);
    }

    ans[i]+=tans;
    return tans;
}

void update(int i,int par,int x,int y)
{
    int j,sz=v[i].size();

    x^=1<<int(s[i]-'a');
    bit[x]+=y;

    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            update(t,i,x,y);
    }
}

void c_decomposition(int i)
{
    n=dfs(i,0);
    int c=centroid(i,0);
    //cout<<i<<" "<<c<<endl;
    used[c]=true;

    int sz=v[c].size();
    for(i=0;i<sz;i++)
    {
        int t=v[c][i];
        if(!used[t])
        {
            ans[c]+=solve(t,c,1<<int(s[c]-'a'));
            update(t,c,0,1);
        }
    }

    for(i=0;i<sz;i++)
    {
        int t=v[c][i];
        if(!used[t])
        {
            update(t,c,0,-1);
            solve(t,c,1<<int(s[c]-'a'));
        }
    }

    for(i=0;i<sz;i++)
        if(!used[v[c][i]])
            c_decomposition(v[c][i]);
}

void print()
{
    int i;
    for(i=1;i<=m;i++)
        cout<<ans[i]+1<<" ";
    cout<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    init_();
    read();
    c_decomposition(1);
    print();
	return 0;
}


/// https://codeforces.com/contest/914/problem/E?locale=en

#include<bits/stdc++.h>
using namespace std;
const int maxn=2*1e5+5;
const int maxm=1<<21;

int n,m;
string s;
vector<int>v[maxn];
bool used[maxn];
int d[maxn],ans[maxn];
int bin[32];
int bit[maxm];

void init_()
{
    int i=1;
    bin[0]=bin[1]=1;
    for(i=2;i<=20;i++)
        bin[i]=bin[i-1]*2;
}

void read()
{
    int i,a,b;
    cin>>n;
    m=n;
    for(i=1;i<n;i++)
    {
        cin>>a>>b;
        v[a].emplace_back(b);
        v[b].emplace_back(a);
    }
    cin>>s;
    s="#"+s;
}

int dfs(int i,int par)
{
    int j,sz=v[i].size();
    d[i]=1;
    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            d[i]+=dfs(t,i);
    }
    return d[i];
}

int centroid(int i,int par)
{
    int j,sz=v[i].size();
    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par&&d[t]>n/2)
            return centroid(t,i);
    }
    return i;
}

int get_ans(int x)
{
    int tans=0,i;

    for(i=0;i<=30;i++)
        if(x==bin[i])
            tans++;

    for(i=0;i<=30;i++)
    {
        int y=x;
        y^=1<<i;

        tans+=bit[y];
    }

    return tans;
}

int solve(int i,int par,int x)
{
    int j,sz=v[i].size(),tans=0;

    x^=1<<int(s[i]-'a');

    tans+=get_ans(x);

    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            tans+=solve(t,i,x);
    }

    ans[i]+=tans;
    return tans;
}

void update(int i,int par,int x,int y)
{
    int j,sz=v[i].size();

    x^=1<<int(s[i]-'a');
    bit[x]+=y;

    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            update(t,i,x,y);
    }
}

void c_decomposition(int i)
{
    n=dfs(i,0);
    int c=centroid(i,0);
    //cout<<i<<" "<<c<<endl;
    used[c]=true;

    int sz=v[c].size();
    for(i=0;i<sz;i++)
    {
        int t=v[c][i];
        if(!used[t])
        {
            ans[c]+=solve(t,c,1<<int(s[c]-'a'));
            update(t,c,0,1);
        }
    }

    for(i=0;i<sz;i++)
    {
        int t=v[c][i];
        if(!used[t])
        {
            update(t,c,0,-1);
            solve(t,c,1<<int(s[c]-'a'));
        }
    }

    for(i=0;i<sz;i++)
        if(!used[v[c][i]])
            c_decomposition(v[c][i]);
}

void print()
{
    int i;
    for(i=1;i<=m;i++)
        cout<<ans[i]+1<<" ";
    cout<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    init_();
    read();
    c_decomposition(1);
    print();
	return 0;
}


/// https://codeforces.com/contest/914/problem/E?locale=en

#include<bits/stdc++.h>
using namespace std;
const int maxn=2*1e5+5;
const int maxm=1<<21;

long long n,m;
string s;
vector<long long>v[maxn];
bool used[maxn];
long long d[maxn],ans[maxn];
long long bin[32];
long long bit[maxm];

void init_()
{
    int i=1;
    bin[0]=0;
    bin[1]=1;
    for(i=2;i<=22;i++)
        bin[i]=bin[i-1]*2;
}

void read()
{
    int i,a,b;
    cin>>n;
    m=n;
    for(i=1;i<n;i++)
    {
        cin>>a>>b;
        v[a].emplace_back(b);
        v[b].emplace_back(a);
    }
    cin>>s;
    s="#"+s;
}

long long dfs(int i,int par)
{
    int j,sz=v[i].size();
    d[i]=1;
    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            d[i]+=dfs(t,i);
    }
    return d[i];
}

long long centroid(int i,int par)
{
    int j,sz=v[i].size();
    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par&&d[t]>n/2)
            return centroid(t,i);
    }
    return i;
}

long long get_ans(long long x,int y)
{
    long long tans=0,i;

    for(i=0;i<21;i++)
        if(x==bin[i])
            tans++;

    for(i=0;i<21;i++)
    {
        long long y=x;
        y^=1<<i;

        tans+=bit[y];
    }

    return tans;
}

long long solve(int i,int par,long long x,int y)
{
    long long j,sz=v[i].size(),tans=0;

    x^=1<<int(s[i]-'a');

    tans+=get_ans(x,y);

    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            tans+=solve(t,i,x,y);
    }
    //cout<<i<<" "<<tans<<endl;
    ans[i]+=tans;
    return tans;
}

void update(int i,int par,long long x,int y)
{
    int j,sz=v[i].size();

    x^=1<<int(s[i]-'a');
    bit[x]+=y;

    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            update(t,i,x,y);
    }
}

void c_decomposition(int i)
{
    n=dfs(i,0);
    int c=centroid(i,0);
    //cout<<c<<endl;
    used[c]=true;

    int sz=v[c].size();
    for(i=0;i<sz;i++)
    {
        int t=v[c][i];
        if(!used[t])
        {
            ans[c]+=solve(t,c,1<<int(s[c]-'a'),1);
            update(t,c,0,1);
            //cout<<" "<<c<<" "<<ans[c]<<endl;
        }
    }

    for(i=0;i<sz;i++)
    {
        int t=v[c][i];
        if(!used[t])
        {
            update(t,c,0,-1);
            solve(t,c,1<<int(s[c]-'a'),-1);
        }
    }

    for(i=0;i<sz;i++)
        if(!used[v[c][i]])
            c_decomposition(v[c][i]);
}

void print()
{
    int i;
    for(i=1;i<=m;i++)
        cout<<ans[i]+1<<" ";
    cout<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    init_();
    read();
    c_decomposition(1);
    print();
	return 0;
}


/// https://codeforces.com/contest/914/problem/E?locale=en

#include<bits/stdc++.h>
using namespace std;
const int maxn=2*1e5+5;
const int maxm=1<<20;

int n,m;
string s;
vector<int>v[maxn];
bool used[maxn];
int d[maxn],ans[maxn];
int bit[maxm];

void read()
{
    int i,a,b;
    cin>>n;
    m=n;
    for(i=1;i<n;i++)
    {
        cin>>a>>b;
        v[a].emplace_back(b);
        v[b].emplace_back(a);
    }
    cin>>s;
    s="#"+s;
}

int dfs(int i,int par)
{
    int j,sz=v[i].size();
    d[i]=1;
    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            d[i]+=dfs(t,i);
    }
    return d[i];
}

int centroid(int i,int par)
{
    int j,sz=v[i].size();
    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par&&d[t]>n/2)
            return centroid(t,i);
    }
    return i;
}

int get_ans(int x)
{
    int tans=0,i;

    /*for(i=0;i<20;i++)
        if(x==bin[i])
            tans++;*/

    for(i=0;i<20;i++)
    {
        int y=x;
        y^=1<<i;

        tans+=bit[y];
    }

    return tans;
}

int solve(int i,int par,int x)
{
    int j,sz=v[i].size(),tans=0;

    x^=1<<int(s[i]-'a');

    tans+=get_ans(x);

    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            tans+=solve(t,i,x);
    }

    ans[i]+=tans;
    return tans;
}

void update(int i,int par,int x,int y)
{
    int j,sz=v[i].size();

    x^=1<<int(s[i]-'a');
    bit[x]+=y;

    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            update(t,i,x,y);
    }
}

void c_decomposition(int i)
{
    n=dfs(i,0);
    int c=centroid(i,0);
    //cout<<i<<" "<<c<<endl;
    used[c]=true;

    int sz=v[c].size();
    for(i=0;i<sz;i++)
    {
        int t=v[c][i];
        if(!used[t])
        {
            ans[c]+=solve(t,c,1<<int(s[c]-'a'));
            update(t,c,0,1);
        }
    }

    for(i=0;i<sz;i++)
    {
        int t=v[c][i];
        if(!used[t])
        {
            update(t,c,0,-1);
            solve(t,c,1<<int(s[c]-'a'));
        }
    }

    for(i=0;i<sz;i++)
        if(!used[v[c][i]])
            c_decomposition(v[c][i]);
}

void print()
{
    int i;
    for(i=1;i<=m;i++)
        cout<<ans[i]+1<<" ";
    cout<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    read();
    c_decomposition(1);
    print();
	return 0;
}


/// https://codeforces.com/contest/914/problem/E?locale=en

#include<bits/stdc++.h>
using namespace std;
const int maxn=2*1e5+5;
const int maxm=1<<20;

int n,m;
string s;
vector<int>v[maxn];
bool used[maxn];
int d[maxn],ans[maxn];
int bin[32];
int bit[maxm];

void init_()
{
    int i=1;
    bin[0]=bin[1]=1;
    for(i=2;i<=20;i++)
        bin[i]=bin[i-1]*2;
}

void read()
{
    int i,a,b;
    cin>>n;
    m=n;
    for(i=1;i<n;i++)
    {
        cin>>a>>b;
        v[a].emplace_back(b);
        v[b].emplace_back(a);
    }
    cin>>s;
    s="#"+s;
}

int dfs(int i,int par)
{
    int j,sz=v[i].size();
    d[i]=1;
    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            d[i]+=dfs(t,i);
    }
    return d[i];
}

int centroid(int i,int par)
{
    int j,sz=v[i].size();
    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par&&d[t]>n/2)
            return centroid(t,i);
    }
    return i;
}

int get_ans(int x)
{
    int tans=0,i;

    for(i=0;i<20;i++)
        if(x==bin[i])
            tans++;

    for(i=0;i<20;i++)
    {
        int y=x;
        y^=1<<i;

        tans+=bit[y];
    }

    return tans;
}

int solve(int i,int par,int x)
{
    int j,sz=v[i].size(),tans=0;

    x^=1<<int(s[i]-'a');

    tans+=get_ans(x);

    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            tans+=solve(t,i,x);
    }

    ans[i]+=tans;
    return tans;
}

void update(int i,int par,int x,int y)
{
    int j,sz=v[i].size();

    x^=1<<int(s[i]-'a');
    bit[x]+=y;

    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            update(t,i,x,y);
    }
}

void c_decomposition(int i)
{
    n=dfs(i,0);
    int c=centroid(i,0);
    //cout<<i<<" "<<c<<endl;
    used[c]=true;

    int sz=v[c].size();
    for(i=0;i<sz;i++)
    {
        int t=v[c][i];
        if(!used[t])
        {
            ans[c]+=solve(t,c,1<<int(s[c]-'a'));
            update(t,c,0,1);
        }
    }

    for(i=0;i<sz;i++)
    {
        int t=v[c][i];
        if(!used[t])
        {
            update(t,c,0,-1);
            solve(t,c,1<<int(s[c]-'a'));
        }
    }

    for(i=0;i<sz;i++)
        if(!used[v[c][i]])
            c_decomposition(v[c][i]);
}

void print()
{
    int i;
    for(i=1;i<=m;i++)
        cout<<ans[i]+1<<" ";
    cout<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    init_();
    read();
    c_decomposition(1);
    print();
	return 0;
}


/// https://codeforces.com/contest/914/problem/E?locale=en

#include<bits/stdc++.h>
using namespace std;
const int maxn=2*1e5+5;
const int maxm=1<<26;

int n,m;
string s;
vector<int>v[maxn];
bool used[maxn];
int d[maxn],ans[maxn];
int bin[32];
int bit[maxm];

void init_()
{
    int i=1;
    bin[0]=bin[1]=1;
    for(i=2;i<=26;i++)
        bin[i]=bin[i-1]*2;
}

void read()
{
    int i,a,b;
    cin>>n;
    m=n;
    for(i=1;i<n;i++)
    {
        cin>>a>>b;
        v[a].emplace_back(b);
        v[b].emplace_back(a);
    }
    cin>>s;
    s="#"+s;
}

int dfs(int i,int par)
{
    int j,sz=v[i].size();
    d[i]=1;
    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            d[i]+=dfs(t,i);
    }
    return d[i];
}

int centroid(int i,int par)
{
    int j,sz=v[i].size();
    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par&&d[t]>n/2)
            return centroid(t,i);
    }
    return i;
}

int get_ans(int x)
{
    int tans=0,i;

    for(i=0;i<26;i++)
        if(x==bin[i])
            tans++;

    for(i=0;i<26;i++)
    {
        int y=x;
        y^=1<<i;

        tans+=bit[y];
    }

    return tans;
}

int solve(int i,int par,int x)
{
    int j,sz=v[i].size(),tans=0;

    x^=1<<int(s[i]-'a');

    tans+=get_ans(x);

    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            tans+=solve(t,i,x);
    }

    ans[i]+=tans;
    return tans;
}

void update(int i,int par,int x,int y)
{
    int j,sz=v[i].size();

    x^=1<<int(s[i]-'a');
    bit[x]+=y;

    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            update(t,i,x,y);
    }
}

void c_decomposition(int i)
{
    n=dfs(i,0);
    int c=centroid(i,0);
    //cout<<i<<" "<<c<<endl;
    used[c]=true;

    int sz=v[c].size();
    for(i=0;i<sz;i++)
    {
        int t=v[c][i];
        if(!used[t])
        {
            ans[c]+=solve(t,c,1<<int(s[c]-'a'));
            update(t,c,0,1);
        }
    }

    for(i=0;i<sz;i++)
    {
        int t=v[c][i];
        if(!used[t])
        {
            update(t,c,0,-1);
            solve(t,c,1<<int(s[c]-'a'));
        }
    }

    for(i=0;i<sz;i++)
        if(!used[v[c][i]])
            c_decomposition(v[c][i]);
}

void print()
{
    int i;
    for(i=1;i<=m;i++)
        cout<<ans[i]+1<<" ";
    cout<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    init_();
    read();
    c_decomposition(1);
    print();
	return 0;
}


/// https://codeforces.com/contest/914/problem/E?locale=en

#include<bits/stdc++.h>
using namespace std;
const int maxn=2*1e5+5;
const int maxm=1<<21;

int n,m;
string s;
vector<int>v[maxn];
bool used[maxn];
int d[maxn],ans[maxn];
int bin[32];
int bit[maxm];

void init_()
{
    int i=1;
    bin[0]=bin[1]=1;
    for(i=2;i<=20;i++)
        bin[i]=bin[i-1]*2;
}

void read()
{
    int i,a,b;
    cin>>n;
    m=n;
    for(i=1;i<n;i++)
    {
        cin>>a>>b;
        v[a].emplace_back(b);
        v[b].emplace_back(a);
    }
    cin>>s;
    s="#"+s;
}

int dfs(int i,int par)
{
    int j,sz=v[i].size();
    d[i]=1;
    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            d[i]+=dfs(t,i);
    }
    return d[i];
}

int centroid(int i,int par)
{
    int j,sz=v[i].size();
    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par&&d[t]>n/2)
            return centroid(t,i);
    }
    return i;
}

int get_ans(int x)
{
    int tans=0,i;

    for(i=0;i<=18;i++)
        if(x==bin[i])
            tans++;

    for(i=0;i<=18;i++)
    {
        int y=x;
        y^=1<<i;

        tans+=bit[y];
    }

    return tans;
}

int solve(int i,int par,int x)
{
    int j,sz=v[i].size(),tans=0;

    x^=1<<int(s[i]-'a');

    tans+=get_ans(x);

    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            tans+=solve(t,i,x);
    }

    ans[i]+=tans;
    return tans;
}

void update(int i,int par,int x,int y)
{
    int j,sz=v[i].size();

    x^=1<<int(s[i]-'a');
    bit[x]+=y;

    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            update(t,i,x,y);
    }
}

void c_decomposition(int i)
{
    n=dfs(i,0);
    int c=centroid(i,0);
    //cout<<i<<" "<<c<<endl;
    used[c]=true;

    int sz=v[c].size();
    for(i=0;i<sz;i++)
    {
        int t=v[c][i];
        if(!used[t])
        {
            ans[c]+=solve(t,c,1<<int(s[c]-'a'));
            update(t,c,0,1);
        }
    }

    for(i=0;i<sz;i++)
    {
        int t=v[c][i];
        if(!used[t])
        {
            update(t,c,0,-1);
            solve(t,c,1<<int(s[c]-'a'));
        }
    }

    for(i=0;i<sz;i++)
        if(!used[v[c][i]])
            c_decomposition(v[c][i]);
}

void print()
{
    int i;
    for(i=1;i<=m;i++)
        cout<<ans[i]+1<<" ";
    cout<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    init_();
    read();
    c_decomposition(1);
    print();
	return 0;
}


/// https://codeforces.com/contest/914/problem/E?locale=en

#include<bits/stdc++.h>
using namespace std;
const int maxn=2*1e5+5;
const int maxm=1<<20;

long long n,m;
string s;
vector<long long>v[maxn];
bool used[maxn];
long long d[maxn],ans[maxn];
long long bin[32];
long long bit[maxm];

void init_()
{
    int i=1;
    bin[0]=bin[1]=1;
    for(i=2;i<=20;i++)
        bin[i]=bin[i-1]*2;
}

void read()
{
    int i,a,b;
    cin>>n;
    m=n;
    for(i=1;i<n;i++)
    {
        cin>>a>>b;
        v[a].emplace_back(b);
        v[b].emplace_back(a);
    }
    cin>>s;
    s="#"+s;
}

long long dfs(int i,int par)
{
    int j,sz=v[i].size();
    d[i]=1;
    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            d[i]+=dfs(t,i);
    }
    return d[i];
}

long long centroid(int i,int par)
{
    int j,sz=v[i].size();
    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par&&d[t]>n/2)
            return centroid(t,i);
    }
    return i;
}

long long get_ans(long long x)
{
    long long tans=0,i;

    for(i=0;i<20;i++)
        if(x==bin[i])
            tans++;

    for(i=0;i<20;i++)
    {
        long long y=x;
        y^=1<<i;

        tans+=bit[y];
    }

    return tans;
}

long long solve(int i,int par,long long x)
{
    long long j,sz=v[i].size(),tans=0;

    x^=1<<int(s[i]-'a');

    tans+=get_ans(x);

    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            tans+=solve(t,i,x);
    }

    ans[i]+=tans;
    return tans;
}

void update(int i,int par,long long x,int y)
{
    int j,sz=v[i].size();

    x^=1<<int(s[i]-'a');
    bit[x]+=y;

    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            update(t,i,x,y);
    }
}

void c_decomposition(int i)
{
    n=dfs(i,0);
    int c=centroid(i,0);
    //cout<<i<<" "<<c<<endl;
    used[c]=true;

    int sz=v[c].size();
    for(i=0;i<sz;i++)
    {
        int t=v[c][i];
        if(!used[t])
        {
            ans[c]+=solve(t,c,1<<int(s[c]-'a'));
            update(t,c,0,1);
        }
    }

    for(i=0;i<sz;i++)
    {
        int t=v[c][i];
        if(!used[t])
        {
            update(t,c,0,-1);
            solve(t,c,1<<int(s[c]-'a'));
        }
    }

    for(i=0;i<sz;i++)
        if(!used[v[c][i]])
            c_decomposition(v[c][i]);
}

void print()
{
    int i;
    for(i=1;i<=m;i++)
        cout<<ans[i]+1<<" ";
    cout<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    init_();
    read();
    c_decomposition(1);
    print();
	return 0;
}


/// https://codeforces.com/contest/914/problem/E?locale=en

#include<bits/stdc++.h>
using namespace std;
const int maxn=2*1e5+5;
const int maxm=1<<21;

int n;
string s;
vector<int>v[maxn];
bool used[maxn];
int d[maxn],ans[maxn];
int bin[32];
int bit[maxm];

void init_()
{
    int i=1;
    bin[0]=bin[1]=1;
    for(i=2;i<=20;i++)
        bin[i]=bin[i-1]*2;
}

void read()
{
    int i,a,b;
    cin>>n;
    for(i=1;i<n;i++)
    {
        cin>>a>>b;
        v[a].emplace_back(b);
        v[b].emplace_back(a);
    }
    cin>>s;
    s="#"+s;
}

int dfs(int i,int par)
{
    int j,sz=v[i].size();
    d[i]=1;
    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            d[i]+=dfs(t,i);
    }
    return d[i];
}

int centroid(int i,int par)
{
    int j,sz=v[i].size();
    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par&&d[t]>n/2)
            return centroid(t,i);
    }
    return i;
}

int get_ans(int x)
{
    int tans=0,i;

    for(i=0;i<=20;i++)
        if(x==bin[i])
            tans++;

    for(i=0;i<=20;i++)
    {
        int y=x;
        y^=1<<i;

        tans+=bit[y];
    }

    return tans;
}

int solve(int i,int par,int x)
{
    int j,sz=v[i].size(),tans=0;

    x^=1<<int(s[i]-'a');

    tans+=get_ans(x);

    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            tans+=solve(t,i,x);
    }

    ans[i]+=tans;
    return tans;
}

void update(int i,int par,int x,int y)
{
    int j,sz=v[i].size();

    x^=1<<int(s[i]-'a');
    bit[x]+=y;

    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            update(t,i,x,y);
    }
}

void c_decomposition(int i)
{
    dfs(i,0);
    int c=centroid(i,0);
    used[c]=true;

    int sz=v[c].size();
    for(i=0;i<sz;i++)
    {
        int t=v[c][i];
        if(!used[t])
        {
            ans[c]+=solve(t,c,1<<int(s[c]-'a'));
            update(t,c,0,1);
        }
    }

    for(i=0;i<sz;i++)
    {
        int t=v[c][i];
        if(!used[t])
        {
            update(t,c,0,-1);
            solve(t,c,1<<int(s[c]-'a'));
        }
    }

    for(i=1;i<=n;i++)
        if(!used[i])
            c_decomposition(i);
}

void print()
{
    int i;
    for(i=1;i<=n;i++)
        cout<<ans[i]+1<<" ";
    cout<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    init_();
    read();
    c_decomposition(1);
    print();
	return 0;
}


/// https://codeforces.com/contest/914/problem/E?locale=en

#include<bits/stdc++.h>
using namespace std;
const int maxn=2*1e5+5;
const int maxm=1<<21;

long long n,m;
string s;
vector<long long>v[maxn];
bool used[maxn];
long long d[maxn],ans[maxn];
long long bin[32];
long long bit[maxm];

void init_()
{
    int i=1;
    bin[0]=0;
    bin[1]=1;
    for(i=2;i<=22;i++)
        bin[i]=bin[i-1]*2;
}

void read()
{
    int i,a,b;
    cin>>n;
    m=n;
    for(i=1;i<n;i++)
    {
        cin>>a>>b;
        v[a].emplace_back(b);
        v[b].emplace_back(a);
    }
    cin>>s;
    s="#"+s;
}

long long dfs(int i,int par)
{
    int j,sz=v[i].size();
    d[i]=1;
    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            d[i]+=dfs(t,i);
    }
    return d[i];
}

long long centroid(int i,int par)
{
    int j,sz=v[i].size();
    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par&&d[t]>n/2)
            return centroid(t,i);
    }
    return i;
}

long long get_ans(long long x,int y)
{
    long long tans=0,i;

    for(i=0;i<21;i++)
        if(x==bin[i]&&y==1)
            tans++;

    for(i=0;i<21;i++)
    {
        long long y=x;
        y^=1<<i;

        tans+=bit[y];
    }

    return tans;
}

long long solve(int i,int par,long long x,int y)
{
    long long j,sz=v[i].size(),tans=0;

    x^=1<<int(s[i]-'a');

    tans+=get_ans(x,y);

    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            tans+=solve(t,i,x,y);
    }
    //cout<<i<<" "<<tans<<endl;
    ans[i]+=tans;
    return tans;
}

void update(int i,int par,long long x,int y)
{
    int j,sz=v[i].size();

    x^=1<<int(s[i]-'a');
    bit[x]+=y;

    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            update(t,i,x,y);
    }
}

void c_decomposition(int i)
{
    n=dfs(i,0);
    int c=centroid(i,0);
    //cout<<c<<endl;
    used[c]=true;

    int sz=v[c].size();
    for(i=0;i<sz;i++)
    {
        int t=v[c][i];
        if(!used[t])
        {
            ans[c]+=solve(t,c,1<<int(s[c]-'a'),1);
            update(t,c,0,1);
            //cout<<" "<<c<<" "<<ans[c]<<endl;
        }
    }

    for(i=0;i<sz;i++)
    {
        int t=v[c][i];
        if(!used[t])
        {
            update(t,c,0,-1);
            solve(t,c,1<<int(s[c]-'a'),-1);
        }
    }

    for(i=0;i<sz;i++)
        if(!used[v[c][i]])
            c_decomposition(v[c][i]);
}

void print()
{
    int i;
    for(i=1;i<=m;i++)
        cout<<ans[i]+1<<" ";
    cout<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    init_();
    read();
    c_decomposition(1);
    print();
	return 0;
}


/// https://codeforces.com/contest/914/problem/E?locale=en

#include<bits/stdc++.h>
using namespace std;
const int maxn=2*1e5+5;
const int maxm=1<<21;

int n;
string s;
vector<int>v[maxn];
bool used[maxn];
int d[maxn],ans[maxn];
int bin[32];
int bit[maxm];

void init_()
{
    int i=1;
    bin[0]=bin[1]=1;
    for(i=2;i<=20;i++)
        bin[i]=bin[i-1]*2;
}

void read()
{
    int i,a,b;
    cin>>n;
    for(i=1;i<n;i++)
    {
        cin>>a>>b;
        v[a].emplace_back(b);
        v[b].emplace_back(a);
    }
    cin>>s;
    s="#"+s;
}

int dfs(int i,int par)
{
    int j,sz=v[i].size();
    d[i]=1;
    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            d[i]+=dfs(t,i);
    }
    return d[i];
}

int centroid(int i,int par)
{
    int j,sz=v[i].size();
    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par&&d[t]>=n/2)
            return centroid(t,i);
    }
    return i;
}

int get_ans(int x)
{
    int tans=0,i;

    for(i=0;i<=20;i++)
        if(x==bin[i])
            tans++;

    for(i=0;i<=20;i++)
    {
        int y=x;
        y^=1<<i;

        tans+=bit[y];
    }

    return tans;
}

int solve(int i,int par,int x)
{
    int j,sz=v[i].size(),tans=0;

    x^=1<<int(s[i]-'a');

    tans+=get_ans(x);

    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            tans+=solve(t,i,x);
    }

    ans[i]+=tans;
    return tans;
}

void update(int i,int par,int x,int y)
{
    int j,sz=v[i].size();

    x^=1<<int(s[i]-'a');
    bit[x]+=y;

    for(j=0;j<sz;j++)
    {
        int t=v[i][j];
        if(!used[t]&&t!=par)
            update(t,i,x,y);
    }
}

void c_decomposition(int i)
{
    dfs(i,0);
    int c=centroid(i,0);
    used[c]=true;

    int sz=v[c].size();
    for(i=0;i<sz;i++)
    {
        int t=v[c][i];
        if(!used[t])
        {
            ans[c]+=solve(t,c,1<<int(s[c]-'a'));
            update(t,c,0,1);
        }
    }

    for(i=0;i<sz;i++)
    {
        int t=v[c][i];
        if(!used[t])
        {
            update(t,c,0,-1);
            solve(t,c,1<<int(s[c]-'a'));
        }
    }

    for(i=1;i<=n;i++)
        if(!used[i])
            c_decomposition(i);
}

void print()
{
    int i;
    for(i=1;i<=n;i++)
        cout<<ans[i]+1<<" ";
    cout<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    init_();
    read();
    c_decomposition(1);
    print();
	return 0;
}


#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>

#define ll long long
#define ld long double
#define eps 1e-8
#define MOD 1000000007

#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f

// change if necessary
#define MAXN 200010

using namespace std;

int n;
vector<int> adj[MAXN];
string s;

int sz[MAXN];
bool vis[MAXN];

ll tmp[MAXN];
ll ans[MAXN];
int cnt[1 << 20];

int dfs_sz(int v, int p) {
    sz[v] = 1;
    for (int e : adj[v]) {
        if (e != p && !vis[e]) {
            sz[v] += dfs_sz(e, v);
        }
    }
    return sz[v];
}

int dfs_root(int v, int p, int n) {
    for (int e : adj[v]) {
        if (e != p && !vis[e] && 2 * sz[e] > n) {
            return dfs_root(e, v, n);
        }
    }
    return v;
}

vector<pair<int, int>> dfs_val(int v, int p, int cur) {
    int pp = s[v] - 'a';
    cur ^= 1 << pp;
    vector<pair<int, int>> res = {{cur, v}};
    tmp[v] = 0; // clearing out for later use

    for (int e : adj[v]) {
        if (e != p && !vis[e]) {
            auto vals = dfs_val(e, v, cur);
            if (vals.size() > res.size()) vals.swap(res);
            for (auto x : vals) res.push_back(x);
        }
    }

    return res;
}

void calc(int cur, int root, int on, int to_eq) {
    if (on == to_eq) {
        tmp[cur]++;
        tmp[root] += 2;
    }

    tmp[cur] += cnt[on ^ to_eq];
    tmp[root] += cnt[on ^ to_eq];
}

ll dfs_add(int v, int p) {
    for (int e : adj[v]) {
        if (e != p && !vis[e]) {
            tmp[v] += dfs_add(e, v);
        }
    }
    ans[v] += tmp[v];
    return tmp[v];
}

void proc(int v) {
    dfs_sz(v, -1);
    v = dfs_root(v, -1, sz[v]);
    vis[v] = true;

    vector<vector<pair<int, int>>> vals;
    for (int e : adj[v]) {
        if (!vis[e]) {
            vals.push_back(dfs_val(e, v, 0));
            for (auto p : vals.back()) {
                cnt[p.first]++;
            }
        }
    }

    tmp[v] = 2; // just node by itself, intentionally storing double to half later
    int root_on = 1 << (s[v] - 'a');
    for (const auto &arr : vals) {
        for (const auto &p : arr) {
            cnt[p.first]--;
        }

        for (const auto &p : arr) {
            calc(p.second, v, p.first, root_on);
            for (int i = 0; i < 20; i++) {
                calc(p.second, v, p.first, root_on ^ (1 << i));
            }
        }

        for (const auto &p : arr) {
            cnt[p.first]++;
        }
    }

    for (int e : adj[v]) {
        if (!vis[e]) {
            dfs_add(e, v);
        }
    }

    for (const auto &arr : vals) {
        for (const auto &p : arr) {
            cnt[p.first]--;
        }
    }

    ans[v] += tmp[v] / 2;

    for (int e : adj[v]) {
        if (!vis[e]) {
            proc(e);
        }
    }
}

int main() {
    cin.tie(0)->sync_with_stdio(0);

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

    cin >> s;

    proc(0);

    for (int i = 0; i < n; i++) {
        cout << ans[i] << ' ';
    }
    cout << '\n';

    return 0;
}


#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>

#define ll long long
#define ld long double
#define eps 1e-8
#define MOD 1000000007

#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f

// change if necessary
#define MAXN 200010

using namespace std;

int n;
vector<int> adj[MAXN];
string s;

int sz[MAXN];
bool vis[MAXN];

ll tmp[MAXN];
ll ans[MAXN];

int dfs_sz(int v, int p) {
    sz[v] = 1;
    for (int e : adj[v]) {
        if (e != p && !vis[e]) {
            sz[v] += dfs_sz(e, v);
        }
    }
    return sz[v];
}

int dfs_root(int v, int p, int n) {
    for (int e : adj[v]) {
        if (e != p && !vis[e] && 2 * sz[e] > n) {
            return dfs_root(e, v, n);
        }
    }
    return v;
}

vector<pair<int, int>> dfs_val(int v, int p, int cur) {
    int pp = s[v] - 'a';
    cur ^= 1 << pp;
    vector<pair<int, int>> res = {{cur, v}};
    tmp[v] = 0; // clearing out for later use

    for (int e : adj[v]) {
        if (e != p && !vis[e]) {
            auto vals = dfs_val(e, v, cur);
            if (vals.size() > res.size()) vals.swap(res);
            for (auto x : vals) res.push_back(x);
        }
    }

    return res;
}

void calc(int cur, int root, int on, int to_eq, const map<int, int> &cnt) {
    if (on == to_eq) {
        tmp[cur]++;
        tmp[root] += 2;
    }

    if (cnt.count(on ^ to_eq)) {
        tmp[cur] += cnt.at(on ^ to_eq);
        tmp[root] += cnt.at(on ^ to_eq);
    }
}

ll dfs_add(int v, int p) {
    for (int e : adj[v]) {
        if (e != p && !vis[e]) {
            tmp[v] += dfs_add(e, v);
        }
    }
    ans[v] += tmp[v];
    return tmp[v];
}

void proc(int v) {
    dfs_sz(v, -1);
    v = dfs_root(v, -1, sz[v]);
    vis[v] = true;

    vector<vector<pair<int, int>>> vals;
    map<int, int> cnt;
    for (int e : adj[v]) {
        if (!vis[e]) {
            vals.push_back(dfs_val(e, v, 0));
            for (auto p : vals.back()) {
                cnt[p.first]++;
            }
        }
    }

    tmp[v] = 2; // just node by itself, intentionally storing double to half later
    int root_on = 1 << (s[v] - 'a');
    for (const auto &arr : vals) {
        for (const auto &p : arr) {
            cnt[p.first]--;
        }

        for (const auto &p : arr) {
            calc(p.second, v, p.first, root_on, cnt);
            for (int i = 0; i < 20; i++) {
                calc(p.second, v, p.first, root_on ^ (1 << i), cnt);
            }
        }

        for (const auto &p : arr) {
            cnt[p.first]++;
        }
    }

    for (int e : adj[v]) {
        if (!vis[e]) {
            dfs_add(e, v);
        }
    }

    ans[v] += tmp[v] / 2;

    for (int e : adj[v]) {
        if (!vis[e]) {
            proc(e);
        }
    }
}

int main() {
    cin.tie(0)->sync_with_stdio(0);

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

    cin >> s;

    proc(0);

    for (int i = 0; i < n; i++) {
        cout << ans[i] << ' ';
    }
    cout << '\n';

    return 0;
}


//#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("Ofast")
#pragma GCC optimize("fast-math")
/*#pragma GCC optimize("section-anchors")
#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
#pragma GCC optimize("vpt")
#pragma GCC optimize("rename-registers")
#pragma GCC optimize("move-loop-invariants")
#pragma GCC optimize("unswitch-loops")
#pragma GCC optimize("function-sections")
#pragma GCC optimize("data-sections")
#pragma GCC optimize("branch-target-load-optimize")
#pragma GCC optimize("branch-target-load-optimize2")
#pragma GCC optimize("btr-bb-exclusive")*/
//#pragma GCC optimize("inline")
#pragma comment(linker, "/STACK:167077260")
#define _CRT_SECURE_NO_WARNINGS
#include <chrono>
#include <set>
#include <map>
#include <deque>
#include <string>
#include <cstdint>
#include <cmath>
#include <queue>
#include <cassert>
#include <random>
#include <bitset>
#include <iomanip>
#include <numeric>
#include <time.h>//////////////
#include <ctime>
#include <climits>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
//#define endl '\n'
#define mp make_pair
#define pbc push_back
#define pob pop_back()
#define empb emplace_back
#define queuel queue<long long>
#define sqr(a) ((a) * (a))
#define lsqr(a) (ld(a) * a)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pin(p) cin >> p.first >> p.second;
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define rev(v) reverse(v.begin(), v.end());
#define sout(s, c) for (auto i : s) cout << i << c;
#define pout(p) cout << p.first << " " << p.second;
#define er(v, l, r) erase(v.begin() + l, v.begin() + r);
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vout(v, c) for (int i = 0; i < v.size(); ++i) cout << v[i] << c;
#define pushi(v, a) for (int i = 0; i < a.size(); ++i) v.push_back(a[i]);
#define fastio() ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); srand(time(NULL))
#define dab(v) for(auto i:v)cout<<i<<' ';
#define sp system("pause")
#define left left228
#define calc calc228
#define next next228
#define type type1337
#define right right228
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
const ld EPS = 0;
const ld EPS2 = 1e-12;
const ld PI = acos(-1);
int mod = (int)998244353;
const int MOD7 = 1000000007;
const int MOD9 = 1000000009;
const int a228 = 18;
const int inf = 1e9;
mt19937 rnd(time(0));
const ll kekmod = 1791791791;
const ll bestmod = 1148822869;
const int MAXN = 2e5 + 1;
vector<int> g[MAXN];
int cc;
int sz[MAXN];
int a[MAXN];
int d[MAXN];
bool used[MAXN];
int hp;
int root;
int pwr[MAXN];
int pr[MAXN];
inline int add(int a, int b)
{
	a += b;
	if (a >= mod)a -= mod;
	if (a < 0)a += mod;
	return a;
}
inline int mul(int a, int b)
{
	return 1ll * a*b % mod;
}
void findcentr(int v, int p, int nsz)
{
	int mx = 0;
	sz[v] = 1;
	for (int i : g[v])
	{
		if (i != p && !used[i])
		{
			findcentr(i, v, nsz);
			sz[v] += sz[i];
			mx = max(mx, sz[i]);
		}
	}
	mx = max(mx, nsz - sz[v]);
	if (mx * 2 <= nsz)
	{
		cc = v;
	}
}
int cnt[1 << 21];
int radd;
int rv;
void dadd(int v, int p, int mask, int jj)
{
	mask ^= a[v];
	cnt[mask] += jj;
	cnt[mask] = max(cnt[mask], 0);
	for (int i : g[v])
	{
		if (i != p && !used[i])
		{
			dadd(i, v, mask, jj);
		}
	}
}
ll ans[MAXN];
int ppc[1 << 21];
ll dcnt(int v, int p, int mask)
{
	ll ret = 0;
	mask ^= a[v];
	for (int tbit = 0; tbit < 20; ++tbit)
	{
		int tmask = (mask ^ (1 << tbit));
		if(ppc[tmask^rv]<=1)
		ret += cnt[tmask^rv];
	}
	if(ppc[mask^rv]<=1)
	ret += cnt[mask^rv];
	for (int i : g[v])
	{
		if (i != p && !used[i])
		{
			ret += dcnt(i, v, mask);
		}
	}
	ans[v] += ret;
	return ret;
}
int secdfs(int v, int p, int msk)
{
	msk ^= a[v];
	int bret = 0;

	if (ppc[msk] <= 1) ans[root]++, bret++;;
	for (int i : g[v])
	{
		if (i != p && !used[i]) bret+=secdfs(i, v, msk);
	}
	ans[v] += bret;
	return bret;
}
void tdfs(int v, int tsz)
{
	findcentr(v, -1, tsz);
	v = cc;
	used[v] = 1;
	root = v;
	rv = a[v];
	radd = 0;
	for (int i : g[v])
	{
		if (!used[i])
		{
			dadd(i, v, 0, 1);
		}
	}
	ll addv = 0;
	for (int i : g[v])
	{
		if (used[i]) continue;
		dadd(i, v, 0, -1);
		addv += dcnt(i, v, 0);
		dadd(i, v, 0, 1);
	}
	for (int i : g[v])
	{
		if (!used[i])
		{
			dadd(i, v, 0, -123123123);
		}
	}
	for (int i : g[v])
	{
		if (!used[i])
		{
			secdfs(i, v, a[v]);
		}
	}
	addv = (addv - radd) / 2 + radd;
	ans[v] += addv;
	for (int i : g[v])
	{
		if (!used[i])
		{
			int x = sz[i];
			if (x > sz[v]) x = tsz - sz[v];
			tdfs(i, x);
		}
	}
}
signed main()
{
	fastio();
	for (int i = 1; i < (1 << 21); ++i) ppc[i] = (ppc[i >> 1]) + (i & 1);
	int n;
	cin >> n;
	for (int i = 0; i < n - 1; ++i)
	{
		int a, b;
		cin >> a >> b;
		g[a].pbc(b);
		g[b].pbc(a);
	}
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); ++i)
	{
		a[i + 1] = (1 << (s[i] - 'a'));
	}
	findcentr(1, -1, n);
	tdfs(cc, n);
	for (int i = 1; i <= n; ++i)
	{
		cout << ans[i] +1<< ' ';
	}
	//sp;
}


//#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("Ofast")
#pragma GCC optimize("fast-math")
/*#pragma GCC optimize("section-anchors")
#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
#pragma GCC optimize("vpt")
#pragma GCC optimize("rename-registers")
#pragma GCC optimize("move-loop-invariants")
#pragma GCC optimize("unswitch-loops")
#pragma GCC optimize("function-sections")
#pragma GCC optimize("data-sections")
#pragma GCC optimize("branch-target-load-optimize")
#pragma GCC optimize("branch-target-load-optimize2")
#pragma GCC optimize("btr-bb-exclusive")*/
//#pragma GCC optimize("inline")
#pragma comment(linker, "/STACK:167077260")
#define _CRT_SECURE_NO_WARNINGS
#include <chrono>
#include <set>
#include <map>
#include <deque>
#include <string>
#include <cstdint>
#include <cmath>
#include <queue>
#include <cassert>
#include <random>
#include <bitset>
#include <iomanip>
#include <numeric>
#include <time.h>//////////////
#include <ctime>
#include <climits>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
//#define endl '\n'
#define mp make_pair
#define pbc push_back
#define pob pop_back()
#define empb emplace_back
#define queuel queue<long long>
#define sqr(a) ((a) * (a))
#define lsqr(a) (ld(a) * a)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pin(p) cin >> p.first >> p.second;
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define rev(v) reverse(v.begin(), v.end());
#define sout(s, c) for (auto i : s) cout << i << c;
#define pout(p) cout << p.first << " " << p.second;
#define er(v, l, r) erase(v.begin() + l, v.begin() + r);
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vout(v, c) for (int i = 0; i < v.size(); ++i) cout << v[i] << c;
#define pushi(v, a) for (int i = 0; i < a.size(); ++i) v.push_back(a[i]);
#define fastio() ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); srand(time(NULL))
#define dab(v) for(auto i:v)cout<<i<<' ';
#define sp system("pause")
#define left left228
#define calc calc228
#define next next228
#define type type1337
#define right right228
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
const ld EPS = 0;
const ld EPS2 = 1e-12;
const ld PI = acos(-1);
int mod = (int)998244353;
const int MOD7 = 1000000007;
const int MOD9 = 1000000009;
const int a228 = 18;
const int inf = 1e9;
mt19937 rnd(time(0));
const ll kekmod = 1791791791;
const ll bestmod = 1148822869;
const int MAXN = 2e5 + 1;
#define int ll
vector<int> g[MAXN];
int cc;
int sz[MAXN];
int a[MAXN];
int d[MAXN];
bool used[MAXN];
int hp;
int root;
int pwr[MAXN];
int pr[MAXN];
void findcentr(int v, int p, int nsz)
{
	int mx = 0;
	sz[v] = 1;
	for (int i : g[v])
	{
		if (i != p && !used[i])
		{
			findcentr(i, v, nsz);
			sz[v] += sz[i];
			mx = max(mx, sz[i]);
		}
	}
	mx = max(mx, nsz - sz[v]);
	if (mx * 2 <= nsz)
	{
		cc = v;
	}
}
int cnt[1 << 21];
int radd;
int rv;
void dadd(int v, int p, int mask, int jj)
{
	mask ^= a[v];
	cnt[mask] += jj;
	cnt[mask] = max(cnt[mask], 0ll);
	for (int i : g[v])
	{
		if (i != p && !used[i])
		{
			dadd(i, v, mask, jj);
		}
	}
}
ll ans[MAXN];
int ppc[1 << 21];
ll dcnt(int v, int p, int mask)
{
	ll ret = 0;
	mask ^= a[v];
	for (int tbit = 0; tbit < 20; ++tbit)
	{
		int tmask = (mask ^ (1 << tbit));
		if(ppc[tmask^rv]<=1)
		ret += cnt[tmask^rv];
	}
	if(ppc[mask^rv]<=1)
	ret += cnt[mask^rv];
	for (int i : g[v])
	{
		if (i != p && !used[i])
		{
			ret += dcnt(i, v, mask);
		}
	}
	ans[v] += ret;
	return ret;
}
int secdfs(int v, int p, int msk)
{
	msk ^= a[v];
	int bret = 0;

	if (ppc[msk] <= 1) ans[root]++, bret++;;
	for (int i : g[v])
	{
		if (i != p && !used[i]) bret+=secdfs(i, v, msk);
	}
	ans[v] += bret;
	return bret;
}
void tdfs(int v, int tsz)
{
	findcentr(v, -1, tsz);
	v = cc;
	used[v] = 1;
	root = v;
	rv = a[v];
	radd = 0;
	for (int i : g[v])
	{
		if (!used[i])
		{
			dadd(i, v, 0, 1);
		}
	}
	ll addv = 0;
	for (int i : g[v])
	{
		if (used[i]) continue;
		dadd(i, v, 0, -1);
		addv += dcnt(i, v, 0);
		dadd(i, v, 0, 1);
	}
	for (int i : g[v])
	{
		if (!used[i])
		{
			dadd(i, v, 0, -123123123);
		}
	}
	for (int i : g[v])
	{
		if (!used[i])
		{
			secdfs(i, v, a[v]);
		}
	}
	addv = (addv - radd) / 2 + radd;
	ans[v] += addv;
	for (int i : g[v])
	{
		if (!used[i])
		{
			int x = sz[i];
			if (x > sz[v]) x = tsz - sz[v];
			tdfs(i, x);
		}
	}
}
signed main()
{
	fastio();
	for (int i = 1; i < (1 << 21); ++i) ppc[i] = (ppc[i >> 1]) + (i & 1);
	int n;
	cin >> n;
	for (int i = 0; i < n - 1; ++i)
	{
		int a, b;
		cin >> a >> b;
		g[a].pbc(b);
		g[b].pbc(a);
	}
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); ++i)
	{
		a[i + 1] = (1 << (s[i] - 'a'));
	}
	findcentr(1, -1, n);
	tdfs(cc, n);
	for (int i = 1; i <= n; ++i)
	{
		cout << ans[i] +1<< ' ';
	}
	//sp;
}


//#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("Ofast")
#pragma GCC optimize("fast-math")
/*#pragma GCC optimize("section-anchors")
#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
#pragma GCC optimize("vpt")
#pragma GCC optimize("rename-registers")
#pragma GCC optimize("move-loop-invariants")
#pragma GCC optimize("unswitch-loops")
#pragma GCC optimize("function-sections")
#pragma GCC optimize("data-sections")
#pragma GCC optimize("branch-target-load-optimize")
#pragma GCC optimize("branch-target-load-optimize2")
#pragma GCC optimize("btr-bb-exclusive")*/
//#pragma GCC optimize("inline")
#pragma comment(linker, "/STACK:167077260")
#define _CRT_SECURE_NO_WARNINGS
#include <chrono>
#include <set>
#include <map>
#include <deque>
#include <string>
#include <cstdint>
#include <cmath>
#include <queue>
#include <cassert>
#include <random>
#include <bitset>
#include <iomanip>
#include <numeric>
#include <time.h>//////////////
#include <ctime>
#include <climits>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
//#define endl '\n'
#define mp make_pair
#define pbc push_back
#define pob pop_back()
#define empb emplace_back
#define queuel queue<long long>
#define sqr(a) ((a) * (a))
#define lsqr(a) (ld(a) * a)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pin(p) cin >> p.first >> p.second;
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define rev(v) reverse(v.begin(), v.end());
#define sout(s, c) for (auto i : s) cout << i << c;
#define pout(p) cout << p.first << " " << p.second;
#define er(v, l, r) erase(v.begin() + l, v.begin() + r);
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vout(v, c) for (int i = 0; i < v.size(); ++i) cout << v[i] << c;
#define pushi(v, a) for (int i = 0; i < a.size(); ++i) v.push_back(a[i]);
#define fastio() ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); srand(time(NULL))
#define dab(v) for(auto i:v)cout<<i<<' ';
#define sp system("pause")
#define left left228
#define calc calc228
#define next next228
#define type type1337
#define right right228
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
const ld EPS = 0;
const ld EPS2 = 1e-12;
const ld PI = acos(-1);
int mod = (int)998244353;
const int MOD7 = 1000000007;
const int MOD9 = 1000000009;
const int a228 = 18;
const int inf = 1e9;
mt19937 rnd(time(0));
const ll kekmod = 1791791791;
const ll bestmod = 1148822869;
const int MAXN = 2e5 + 228;
#define int ll
vector<int> g[MAXN];
int cc;
int sz[MAXN];
int a[MAXN];
int d[MAXN];
bool used[MAXN];
int hp;
int root;
int pwr[MAXN];
int pr[MAXN];
void findcentr(int v, int p, int nsz)
{
	int mx = 0;
	sz[v] = 1;
	for (int i : g[v])
	{
		if (i != p && !used[i])
		{
			findcentr(i, v, nsz);
			sz[v] += sz[i];
			mx = max(mx, sz[i]);
		}
	}
	mx = max(mx, nsz - sz[v]);
	if (mx * 2 <= nsz)
	{
		cc = v;
	}
}
int cnt[1 << 21];
int radd;
int rv;
void dadd(int v, int p, int mask, int jj)
{
	mask ^= a[v];
	cnt[mask] += jj;
	cnt[mask] = max(cnt[mask], 0ll);
	for (int i : g[v])
	{
		if (i != p && !used[i])
		{
			dadd(i, v, mask, jj);
		}
	}
}
ll ans[MAXN];
int ppc[1 << 21];
ll dcnt(int v, int p, int mask)
{
	ll ret = 0;
	mask ^= a[v];
	for (int tbit = 0; tbit < 20; ++tbit)
	{
		int tmask = (mask ^ (1 << tbit));
//		if(ppc[tmask^rv]<=1)
		ret += cnt[tmask^rv];
	}
//	if(ppc[mask^rv]<=1)
	ret += cnt[mask^rv];
	for (int i : g[v])
	{
		if (i != p && !used[i])
		{
			ret += dcnt(i, v, mask);
		}
	}
	ans[v] += ret;
	return ret;
}
int secdfs(int v, int p, int msk)
{
	msk ^= a[v];
	int bret = 0;

	if (ppc[msk] <= 1) ans[root]++, bret++;;
	for (int i : g[v])
	{
		if (i != p && !used[i]) bret+=secdfs(i, v, msk);
	}
	ans[v] += bret;
	return bret;
}
void tdfs(int v, int tsz)
{
	findcentr(v, -1, tsz);
	v = cc;
	used[v] = 1;
	root = v;
	rv = a[v];
	radd = 0;
	for (int i : g[v])
	{
		if (!used[i])
		{
			dadd(i, v, 0, 1);
		}
	}
	ll addv = 0;
	for (int i : g[v])
	{
		if (used[i]) continue;
		dadd(i, v, 0, -1);
		addv += dcnt(i, v, 0);
		dadd(i, v, 0, 1);
	}
	for (int i : g[v])
	{
		if (!used[i])
		{
			dadd(i, v, 0, -123123123);
		}
	}
	for (int i : g[v])
	{
		if (!used[i])
		{
			secdfs(i, v, a[v]);
		}
	}
	addv = addv / 2;
	ans[v] += addv;
	for (int i : g[v])
	{
		if (!used[i])
		{
			int x = sz[i];
			if (x > sz[v]) x = tsz - sz[v];
			tdfs(i, x);
		}
	}
}
signed main()
{
	fastio();
	for (int i = 1; i < (1 << 21); ++i) ppc[i] = (ppc[i >> 1]) + (i & 1);
	int n;
	cin >> n;
	for (int i = 0; i < n - 1; ++i)
	{
		int a, b;
		cin >> a >> b;
		g[a].pbc(b);
		g[b].pbc(a);
	}
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); ++i)
	{
		a[i + 1] = (1 << (s[i] - 'a'));
	}
	findcentr(1, -1, n);
	tdfs(cc, n);
	for (int i = 1; i <= n; ++i)
	{
		cout << ans[i] +1<< ' ';
	}
//	sp;
}
/*4 1 2 2 3 3 4 abba*/


#include <bits/stdc++.h>
#define F first
#define S second
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<ll, ll> pll;
const int MOD = 1e9 + 7;
const int LOGN = 20;
const ll INF = 1e18;
ll __gcd(ll a, ll b) {
	if(b == 0)
		return a;
	return __gcd(b, a%b);
}
ll __lcm(ll a, ll b) {
	return ((a * b) / __gcd(a, b));
}
const int MAX = (1 << 21) + 100;
vector< set<int> > adj;
vi masks(MAX, 0);
vi subtree;
vll ans;
string s;
int n;
int nn = 0;
void dfs1(int u, int p) {
	subtree[u] = 1;
	nn++;
	for(auto v: adj[u]) {
		if(v == p)
			continue;
		dfs1(v, u);
		subtree[u] += subtree[v];
	}
}
int dfs2(int u, int p) {
	for(auto v: adj[u])
		if(v != p and subtree[v] > nn / 2)
			return dfs2(v, u);
	return u;
}
void dfs3(int u, int p, int mask, int add) {
	masks[mask] += add;
	for(auto v: adj[u]) {
		if(v == p)
			continue;
		dfs3(v, u, mask ^ (1 << (s[v] - 'a')), add);
	}
}
ll cnt = 0;
void dfs4(int u, int p, int mask, int centroid) {
	// ans[u] += masks[mask];
	if(mask == (1 << (s[centroid] - 'a')))
		cnt++;
	for(int i = 0; i <= 20; i++) {
		ans[u] += masks[mask ^ (1 << i)];
		if((mask ^ (1 << i)) == (1 << (s[centroid] - 'a')))
			cnt++;
	}
	for(auto v: adj[u]) {
		if(v == p)
			continue;
		dfs4(v, u, (mask ^ (1 << (s[v] - 'a'))), centroid);
		ans[u] += ans[v];
	}
}
void decompose(int root, int depth) {
	int x;
	nn = 0;
	dfs1(root, root);
	int centroid = dfs2(root, root);
	dfs3(centroid, centroid, (1 << (s[centroid] - 'a')), 1);
	cnt = 0;
	for(auto v: adj[centroid]) {
		int mask = (1 << (s[v] - 'a')) ^ (1 << (s[centroid] - 'a'));
		dfs3(v, centroid, mask, -1);
		dfs4(v, centroid, (1 << (s[v] - 'a')), centroid);
		dfs3(v, centroid, mask, 1);
		cnt += ans[v];
	}
	cnt /= 2;
	ans[centroid] += cnt;
	dfs3(centroid, centroid, (1 << (s[centroid] - 'a')), -1);
	for(auto v: adj[centroid]) {
		adj[v].erase(centroid);
		decompose(v, depth + 1);
	}
}
int main() {
	std :: ios_base :: sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	cin >> n;
	adj.assign(n, set<int>());
	subtree.assign(n, 0);
	ans.assign(n, 0);
	int x, y;
	for(int i = 0; i < n - 1; ++i) {
		cin >> x >> y;
		x--, y--;
		adj[x].insert(y);
		adj[y].insert(x);
	}
	cin >> s;
	decompose(0, 0);
	for(int i = 0; i < n; ++i)
		cout << ans[i] + 1 << " ";
	cout << endl;
}


#include <bits/stdc++.h>
#define F first
#define S second
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<ll, ll> pll;
const int MOD = 1e9 + 7;
const int LOGN = 20;
const ll INF = 1e18;
ll __gcd(ll a, ll b) {
	if(b == 0)
		return a;
	return __gcd(b, a%b);
}
ll __lcm(ll a, ll b) {
	return ((a * b) / __gcd(a, b));
}
const int MAX = (1 << 21) + 100;
vector< set<int> > adj;
vi masks(MAX, 0);
vi subtree;
vll ans;
string s;
int n;
int nn = 0;
void dfs1(int u, int p) {
	subtree[u] = 1;
	nn++;
	for(auto v: adj[u]) {
		if(v == p)
			continue;
		dfs1(v, u);
		subtree[u] += subtree[v];
	}
}
int dfs2(int u, int p) {
	for(auto v: adj[u])
		if(v != p and subtree[v] > nn / 2)
			return dfs2(v, u);
	return u;
}
void dfs3(int u, int p, int mask, int add) {
	masks[mask] += add;
	for(auto v: adj[u]) {
		if(v == p)
			continue;
		dfs3(v, u, mask ^ (1 << (s[v] - 'a')), add);
	}
}
ll cnt = 0;
void dfs4(int u, int p, int mask, int centroid) {

	ans[u] += masks[mask];
	if(mask == (1 << s[centroid]))
		cnt++;
	for(int i = 0; i <= 20; i++) {
		ans[u] += masks[mask ^ (1 << i)];
		if((mask ^ (1 << i)) == (1 << s[centroid]))
			cnt++;
	}
	for(auto v: adj[u]) {
		if(v == p)
			continue;
		dfs4(v, u, (mask ^ (1 << (s[v] - 'a'))), centroid);
		ans[u] += ans[v];
	}
}
void decompose(int root, int depth) {
	int x;
	nn = 0;
	dfs1(root, root);
	int centroid = dfs2(root, root);
	dfs3(centroid, centroid, (1 << (s[centroid] - 'a')), 1);
	cnt = 0;
	for(auto v: adj[centroid]) {
		int mask = (1 << (s[v] - 'a')) ^ (1 << (s[centroid] - 'a'));
		dfs3(v, centroid, mask, -1);
		dfs4(v, centroid, (1 << (s[v] - 'a')), centroid);
		dfs3(v, centroid, mask, 1);
		cnt += ans[v];
	}
	cnt /= 2;
	ans[centroid] += cnt;
	for(auto v: adj[centroid]) {
		int mask = (1 << (s[v] - 'a')) ^ (1 << (s[centroid] - 'a'));
		dfs3(v, centroid, mask, -1);
	}
	masks[1 << (s[centroid] - 'a')] = 0;
	for(auto v: adj[centroid]) {
		adj[v].erase(centroid);
		decompose(v, depth + 1);
	}
}
int main() {
	std :: ios_base :: sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	cin >> n;
	adj.assign(n, set<int>());
	subtree.assign(n, 0);
	ans.assign(n, 0);
	int x, y;
	for(int i = 0; i < n - 1; ++i) {
		cin >> x >> y;
		x--, y--;
		adj[x].insert(y);
		adj[y].insert(x);
	}
	cin >> s;
	decompose(0, 0);
	for(int i = 0; i < n; ++i)
		cout << ans[i] + 1 << " ";
	cout << endl;
}


#include <bits/stdc++.h>
#define F first
#define S second
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<ll, ll> pll;
const int MOD = 1e9 + 7;
const int LOGN = 20;
const ll INF = 1e18;
ll __gcd(ll a, ll b) {
	if(b == 0)
		return a;
	return __gcd(b, a%b);
}
ll __lcm(ll a, ll b) {
	return ((a * b) / __gcd(a, b));
}
const int MAX = (1 << 21) + 100;
vector< set<int> > adj;
vi masks(MAX, 0);
vi subtree;
vll ans;
string s;
int n;
int nn = 0;
void dfs1(int u, int p) {
	subtree[u] = 1;
	nn++;
	for(auto v: adj[u]) {
		if(v == p)
			continue;
		dfs1(v, u);
		subtree[u] += subtree[v];
	}
}
int dfs2(int u, int p) {
	for(auto v: adj[u])
		if(v != p and subtree[v] > nn / 2)
			return dfs2(v, u);
	return u;
}
void dfs3(int u, int p, int mask, int add) {
	masks[mask] += add;
	for(auto v: adj[u]) {
		if(v == p)
			continue;
		dfs3(v, u, mask ^ (1 << (s[v] - 'a')), add);
	}
}
ll cnt = 0;
void dfs4(int u, int p, int mask, int centroid) {
	ans[u] += masks[mask];
	if(mask == (1 << (s[centroid] - 'a')))
		cnt++;
	for(int i = 0; i <= 20; i++) {
		ans[u] += masks[mask ^ (1 << i)];
		if((mask ^ (1 << i)) == (1 << (s[centroid] - 'a')))
			cnt++;
	}
	for(auto v: adj[u]) {
		if(v == p)
			continue;
		dfs4(v, u, (mask ^ (1 << (s[v] - 'a'))), centroid);
		ans[u] += ans[v];
	}
}
void decompose(int root, int depth) {
	int x;
	nn = 0;
	dfs1(root, root);
	int centroid = dfs2(root, root);
	dfs3(centroid, centroid, (1 << (s[centroid] - 'a')), 1);
	cnt = 0;
	for(auto v: adj[centroid]) {
		int mask = (1 << (s[v] - 'a')) ^ (1 << (s[centroid] - 'a'));
		dfs3(v, centroid, mask, -1);
		dfs4(v, centroid, (1 << (s[v] - 'a')), centroid);
		dfs3(v, centroid, mask, 1);
		cnt += ans[v];
	}
	cnt /= 2;
	ans[centroid] += cnt;
	dfs3(centroid, centroid, (1 << (s[centroid] - 'a')), -1);
	for(auto v: adj[centroid]) {
		adj[v].erase(centroid);
		decompose(v, depth + 1);
	}
}
int main() {
	std :: ios_base :: sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	cin >> n;
	adj.assign(n, set<int>());
	subtree.assign(n, 0);
	ans.assign(n, 0);
	int x, y;
	for(int i = 0; i < n - 1; ++i) {
		cin >> x >> y;
		x--, y--;
		adj[x].insert(y);
		adj[y].insert(x);
	}
	cin >> s;
	decompose(0, 0);
	for(int i = 0; i < n; ++i)
		cout << ans[i] + 1 << " ";
	cout << endl;
}


#include <bits/stdc++.h>
#define F first
#define S second
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<ll, ll> pll;
const int MOD = 1e9 + 7;
const int LOGN = 20;
const ll INF = 1e18;
ll __gcd(ll a, ll b) {
	if(b == 0)
		return a;
	return __gcd(b, a%b);
}
ll __lcm(ll a, ll b) {
	return ((a * b) / __gcd(a, b));
}
const int MAX = (1 << 20) + 100;
vector< set<int> > adj;
vi masks(MAX, 0);
vi subtree;
vi ans;
string s;
int n;
int nn = 0;
void dfs1(int u, int p) {
	subtree[u] = 1;
	nn++;
	for(auto v: adj[u]) {
		if(v == p)
			continue;
		dfs1(v, u);
		subtree[u] += subtree[v];
	}
}
int dfs2(int u, int p) {
	for(auto v: adj[u])
		if(v != p and subtree[v] > nn / 2)
			return dfs2(v, u);
	return u;
}
void dfs3(int u, int p, int mask, int add) {
	masks[mask] += add;
	for(auto v: adj[u]) {
		if(v == p)
			continue;
		dfs3(v, u, mask ^ (1 << (s[v] - 'a')), add);
	}
}
int cnt = 0;
void dfs4(int u, int p, int mask, int centroid) {
	ans[u] += masks[mask];
	if(mask == (1 << s[centroid]))
		cnt++;
	for(int i = 0; i <= 20; i++) {
		ans[u] += masks[mask ^ (1 << i)];
		if((mask ^ (1 << i)) == (1 << s[centroid]))
			cnt++;
	}
	for(auto v: adj[u]) {
		if(v == p)
			continue;
		dfs4(v, u, (mask ^ (1 << (s[v] - 'a'))), centroid);
		ans[u] += ans[v];
	}
}
void decompose(int root, int depth) {
	int x;
	nn = 0;
	dfs1(root, root);
	int centroid = dfs2(root, root);
	dfs3(centroid, centroid, (1 << (s[centroid] - 'a')), 1);
	cnt = 0;
	for(auto v: adj[centroid]) {
		int mask = (1 << (s[v] - 'a')) ^ (1 << (s[centroid] - 'a'));
		dfs3(v, centroid, mask, -1);

		dfs4(v, centroid, (1 << (s[v] - 'a')), centroid);
		dfs3(v, centroid, mask, 1);
		cnt += ans[v];
	}
	cnt /= 2;
	ans[centroid] += cnt;
	for(auto v: adj[centroid]) {
		int mask = (1 << (s[v] - 'a')) ^ (1 << (s[centroid] - 'a'));
		dfs3(v, centroid, mask, -1);
	}
	masks[1 << (s[centroid] - 'a')] = 0;
	for(auto v: adj[centroid]) {
		adj[v].erase(centroid);
		decompose(v, depth + 1);
	}
}
int main() {
	std :: ios_base :: sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	cin >> n;
	adj.assign(n, set<int>());
	subtree.assign(n, 0);
	ans.assign(n, 0);
	int x, y;
	for(int i = 0; i < n - 1; ++i) {
		cin >> x >> y;
		x--, y--;
		adj[x].insert(y);
		adj[y].insert(x);
	}
	cin >> s;
	decompose(0, 0);
	for(int i = 0; i < n; ++i)
		cout << ans[i] + 1 << " ";
	cout << endl;
}


#include <bits/stdc++.h>
#define F first
#define S second
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<ll, ll> pll;
const int MOD = 1e9 + 7;
const int LOGN = 20;
const ll INF = 1e18;
ll __gcd(ll a, ll b) {
	if(b == 0)
		return a;
	return __gcd(b, a%b);
}
ll __lcm(ll a, ll b) {
	return ((a * b) / __gcd(a, b));
}
const int MAX = (1 << 21) + 100;
vector< set<int> > adj;
vi masks(MAX, 0);
vi subtree;
vi ans;
string s;
int n;
int nn = 0;
void dfs1(int u, int p) {
	subtree[u] = 1;
	nn++;
	for(auto v: adj[u]) {
		if(v == p)
			continue;
		dfs1(v, u);
		subtree[u] += subtree[v];
	}
}
int dfs2(int u, int p) {
	for(auto v: adj[u])
		if(v != p and subtree[v] > nn / 2)
			return dfs2(v, u);
	return u;
}
void dfs3(int u, int p, int mask, int add) {
	masks[mask] += add;
	for(auto v: adj[u]) {
		if(v == p)
			continue;
		dfs3(v, u, mask ^ (1 << (s[v] - 'a')), add);
	}
}
int cnt = 0;
void dfs4(int u, int p, int mask, int centroid) {

	ans[u] += masks[mask];
	if(mask == (1 << s[centroid]))
		cnt++;
	for(int i = 0; i <= 20; i++) {
		ans[u] += masks[mask ^ (1 << i)];
		if((mask ^ (1 << i)) == (1 << s[centroid]))
			cnt++;
	}
	for(auto v: adj[u]) {
		if(v == p)
			continue;
		dfs4(v, u, (mask ^ (1 << (s[v] - 'a'))), centroid);
		ans[u] += ans[v];
	}
}
void decompose(int root, int depth) {
	int x;
	nn = 0;
	dfs1(root, root);
	int centroid = dfs2(root, root);
	dfs3(centroid, centroid, (1 << (s[centroid] - 'a')), 1);
	cnt = 0;
	for(auto v: adj[centroid]) {
		int mask = (1 << (s[v] - 'a')) ^ (1 << (s[centroid] - 'a'));
		dfs3(v, centroid, mask, -1);
		dfs4(v, centroid, (1 << (s[v] - 'a')), centroid);
		dfs3(v, centroid, mask, 1);
		cnt += ans[v];
	}
	cnt /= 2;
	ans[centroid] += cnt;
	for(auto v: adj[centroid]) {
		int mask = (1 << (s[v] - 'a')) ^ (1 << (s[centroid] - 'a'));
		dfs3(v, centroid, mask, -1);
	}
	masks[1 << (s[centroid] - 'a')] = 0;
	for(auto v: adj[centroid]) {
		adj[v].erase(centroid);
		decompose(v, depth + 1);
	}
}
int main() {
	std :: ios_base :: sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	cin >> n;
	adj.assign(n, set<int>());
	subtree.assign(n, 0);
	ans.assign(n, 0);
	int x, y;
	for(int i = 0; i < n - 1; ++i) {
		cin >> x >> y;
		x--, y--;
		adj[x].insert(y);
		adj[y].insert(x);
	}
	cin >> s;
	decompose(0, 0);
	for(int i = 0; i < n; ++i)
		cout << ans[i] + 1 << " ";
	cout << endl;
}


#include <bits/stdc++.h>
#define F first
#define S second
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<ll, ll> pll;
const int MOD = 1e9 + 7;
const int LOGN = 20;
const ll INF = 1e18;
ll __gcd(ll a, ll b) {
	if(b == 0)
		return a;
	return __gcd(b, a%b);
}
ll __lcm(ll a, ll b) {
	return ((a * b) / __gcd(a, b));
}
const int MAX = (1 << 21) + 100;
vector< set<int> > adj;
vi masks(MAX, 0);
vi subtree;
vll ans;
vll temp_ans;
string s;
int n;
int nn = 0;
void dfs1(int u, int p) {
	subtree[u] = 1;
	temp_ans[u] = 0;
	nn++;
	for(auto v: adj[u]) {
		if(v == p)
			continue;
		dfs1(v, u);
		subtree[u] += subtree[v];
	}
}
int dfs2(int u, int p) {
	for(auto v: adj[u])
		if(v != p and subtree[v] > nn / 2)
			return dfs2(v, u);
	return u;
}
void dfs3(int u, int p, int mask, int add) {
	masks[mask] += add;
	for(auto v: adj[u]) {
		if(v == p)
			continue;
		dfs3(v, u, mask ^ (1 << (s[v] - 'a')), add);
	}
}
ll cnt = 0;
void dfs4(int u, int p, int mask, int centroid) {
	temp_ans[u] += masks[mask];
	if(mask == (1 << (s[centroid] - 'a')))
		cnt++;
	for(int i = 0; i <= 20; ++i) {
		int curr_mask = mask ^ (1 << i);
		temp_ans[u] += masks[curr_mask];
		if(curr_mask == (1 << (s[centroid] - 'a')))
			cnt++;
	}
	for(auto v: adj[u]) {
		if(v == p)
			continue;
		dfs4(v, u, mask ^ ((1 << s[v] - 'a')), centroid);
		temp_ans[u] += temp_ans[v];
	}
	ans[u] += temp_ans[u];
}
void decompose(int root, int depth) {
	nn = 0;
	dfs1(root, root);
	int centroid = dfs2(root, root);
	dfs3(centroid, centroid, (1 << (s[centroid] - 'a')), 1);
	cnt = 0;
	ll temp = 0;
	for(auto v: adj[centroid]) {
		int mask = (1 << (s[v] - 'a')) ^ (1 << (s[centroid] - 'a'));
		dfs3(v, centroid, mask, -1);
		dfs4(v, centroid, (1 << (s[v] - 'a')), centroid);
		dfs3(v, centroid, mask, 1);
		temp += temp_ans[v];
		temp += cnt;
		cnt = 0;
	}
	ans[centroid] += (temp / 2);
	dfs3(centroid, centroid, (1 << (s[centroid] - 'a')), -1);
	for(auto v: adj[centroid]) {
		adj[v].erase(centroid);
		decompose(v, depth + 1);
	}
}
int main() {
	std :: ios_base :: sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	cin >> n;
	adj.assign(n, set<int>());
	subtree.assign(n, 0);
	ans.assign(n, 0);
	temp_ans.assign(n, 0);
	int x, y;
	for(int i = 0; i < n - 1; ++i) {
		cin >> x >> y;
		x--, y--;
		adj[x].insert(y);
		adj[y].insert(x);
	}
	cin >> s;
	decompose(0, 0);
	for(int i = 0; i < n; ++i)
		cout << ans[i] + 1 << " ";
	cout << endl;
}