#include <bits/stdc++.h>
/*
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
*/
using namespace std;
const double eps = 1e-10;
const double pi = 3.1415926535897932384626433832795;
const double eln = 2.718281828459045235360287471352;
#define f(i, a, b) for (int i = a; i <= b; i++)
#define scan(x) scanf("%d", &x)
#define mp make_pair
#define pb push_back
#define lowbit(x) (x&(-x))
#define fi first
#define se second
#define SZ(x) int((x).size())
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define summ(a) (accumulate(all(a), 0ll))
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
using ll=long long;
struct lx{
mutable int l,r;
bool operator <(const lx& aa)const{
return r==aa.r?l<aa.l:r<aa.r;
}
};
ll tt,n,son[(int)2e5+9],sz[(int)2e5+9],ans,res[(int)2e5+9],cnt[(int)2e5+9];
vector<int> g[(int)2e5+9];
set<lx> s;
void dfs(int u,int fa){
for(auto it:g[u])if(it!=fa){
dfs(it,u);
sz[u]+=sz[it],son[u]=sz[son[u]]<sz[it]?it:son[u];
}
}
void cal(int u,int fa,int bson,int sta){
/*if(sta){
auto it=s.lower_bound({u,u});
if(it!=s.begin()&&it!=s.end()){
auto pr=prev(it);
if(pr->r==u-1&&it->l==u+1){
int lll=pr->l,rrr=it->r;
s.erase(pr,next(it)),s.insert({lll,rrr});
}else if(pr->r==u-1)pr->r=u;
else if(pr->l==u+1)pr->l=u;
else s.insert({u,u});
}else{
if(it!=s.end()&&it->l==u+1)it->l=u;
else if(it!=s.begin()){
it=prev(it);
if(it->r==u-1)it->r=u;
else s.insert({u,u});
}else s.insert({u,u});
}
}else{
auto it=s.lower_bound({u,u});
if(it->r==it->l&&it->l==u){
s.erase(it);
}else if(it->r==u){
it->r=u-1;
}else if(it->l==u){
it->l=u+1;
}else {
int tp=it->r;
it->r=u-1;
s.insert({u+1,tp});
}
}*/
if(sta){
if(cnt[u-1]&&cnt[u+1])cnt[u]=1,ans-=1;
else if(cnt[u-1]||cnt[u+1])cnt[u]=1;
else cnt[u]=1,ans+=1;
}else{
if(cnt[u-1]&&cnt[u+1])cnt[u]=0,ans+=1;
else if(cnt[u-1]||cnt[u+1])cnt[u]=0;
else cnt[u]=0,ans-=1;
}
for(auto it:g[u])if(it!=bson&&it!=fa)cal(it,u,bson,sta);
}
void dfs2(int u,int fa,int sta){
for(auto it:g[u])if(it!=fa&&it!=son[u])dfs2(it,u,0);
if(son[u])dfs2(son[u],u,1);
cal(u,fa,son[u],1);
res[u]=ans;
if(!sta)cal(u,fa,0,0);
}
void solve(){
cin>>n;
ans=cnt[0]=cnt[n+1]=cnt[n+2]=0;
f(i,1,n)g[i].clear(),sz[i]=1,son[i]=0,cnt[i]=0;
for(int i=1,x,y;i<n;++i){
cin>>x>>y;
g[x].push_back(y),g[y].push_back(x);
}
dfs(1,0);
dfs2(1,0,0);
for(int i=1;i<=n;++i)cout<<res[i]<<" \n"[i==n];
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin>>tt;
f(ss,1,tt){
cout<<"Case #"<<ss<<": ";
solve();
}
return 0;
}