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

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;

#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ALL(a,n) a,a+n
#define ALLV(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=int(b); ++i)
#define rFOR(i,a,b) for(int i=a; i>=int(b); --i)

typedef long long ll;
typedef pair<int,int> pii;

struct{

    int N;
    vector<vector<int>> graph;
    vector<ll> sz;
    vector<ll> ans;
    vector<int> par;
    bitset<200005> removed, inseq;

    void init(int n){
        N = n;
        graph = vector<vector<int>>(N);
        sz = vector<ll>(N, 0);
        ans = vector<ll>(N+1, 0);
        par = vector<int>(N, -1);
        removed.reset();
        inseq.reset();
        REP(_, N-1){
            int a, b;
            cin >> a >> b;
            graph[a].pb(b);
            graph[b].pb(a);
        }
        dfs1();
    }

    void dfs1(int n=0, int p=-1){
        par[n] = p;
        sz[n] = 1;
        for(int v : graph[n]){
            if(v==p) continue;
            dfs1(v, n);
            sz[n] += sz[v];
        }
    }

    int dfs2(int n, int& s1, int& s2){
        if(n==1){
            inseq[n] = 1;
            s2 = sz[n];
            return sz[n];
        }
        if(n==0){
            inseq[n] = 1;
            vector<ll> vals;
            ll sm = 0;
            for(int v : graph[n]){
                int cnt = dfs2(v, s1, s2);
                if(cnt==0){
                    vals.pb(sz[v]);
                    s1 += sz[v];
                }else{
                    vals.pb(sz[v]-cnt);
                }
                sm += vals.back();
            }
            ++s1;
            ans[1] = (sm * (sm+1))/2;
            for(ll x : vals){
                ans[1] -= (x * (x-1))/2;
            }
        }else{
            for(int v : graph[n]){
                if(v==par[n]) continue;
                int cnt = dfs2(v, s1, s2);
                if(cnt){
                    inseq[n] = 1;
                    dfs3(n);
                    return cnt;
                }
            }
        }
        return 0;
    }

    void dfs3(int n){
        if(removed[n]) return;
        if(!inseq[n]) removed[n] = 1;
        for(int v : graph[n]){
            if(v==par[n] || inseq[v]) continue;
            dfs3(v);
        }
    }

    void solve(){
        for(int v : graph[0]){
            ans[0] += (sz[v] * (sz[v] - 1)) / 2;
        }

        int e1 = 0, e2 = 1;
        int s1 = 0, s2 = 0;
        dfs2(0, s1, s2);

        // cerr << ans[0] << " " << ans[1] << "\n";
        // cerr << e1 << " " << s1 << ", " << e2 << " " << s2 << "\n";
        ans[N] = 1;
        FOR(i, 2, N-1){
            if(removed[i]){
                ans[i] = 1LL*s1*s2;
                ans[N] = 0;
                break;
            }
            if(inseq[i]){
                continue;
            }

            vector<int> seq;
            seq.pb(i);
            inseq[i] = 1;
            while(true){
                int p = par[seq.back()];
                if(inseq[p]) break;
                seq.pb(p);
                inseq[p] = 1;
            }
            if(par[seq.back()]==e1){
                dfs3(e1);
                ans[i] = s2*(s1-sz[i]);
                s1 = sz[i];
                e1 = i;
            }else{
                dfs3(e2);
                ans[i] = s1*(s2-sz[i]);
                s2 = sz[i];
                e2 = i;
            }
            // cerr << e1 << " " << s1 << ", " << e2 << " " << s2 << "\n";
            FOR(i, 1, SZ(seq)-1){
                dfs3(seq[i]);
            }
        }
    }

    void print_ans(){
        REP(i, N+1){
            if(i) cout << " ";
            cout << ans[i];
        }
        cout << "\n";
    }

} sol;

void solve(){
    int n; cin >> n;
    sol.init(n);
    sol.solve();
    sol.print_ans();
}

int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    int tc; cin >> tc;
    REP(i, tc){
        solve();
    }
    return 0;
}