#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;
const int iinf = 1 << 29;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;
#define pb push_back
#define ff first
#define ss second
#define sz(a) ((int)(a).size())
#define all(x) (x).begin(),(x).end()
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll mrand(ll B) {
  return (ull)rng() % B;
}

ll cross(pair<ll, ll> p1, pair<ll, ll> p2) {
    return p1.first*p2.second - p2.first*p1.second;
}

bool online(pair<ll, ll> a, pair<ll, ll> b, pair<ll, ll> c) {
    pair<ll, ll> p1{b.first-a.first, b.second-a.second};
    pair<ll, ll> p2{c.first-a.first, c.second-a.second};
    return cross(p1, p2) == 0;
}

void z_func(vector<int> &z, vector<int> &s, int n) {
    int L = 0, R = 0;
    for (int i = 1; i < n; i++) {
        if (i > R) {
            L = R = i;
            while (R < n && s[R-L] == s[R]) R++;
            z[i] = R-L; R--;
        } else {
            int k = i-L;
            if (z[k] < R-i+1) z[i] = z[k];
            else {
                L = i;
                while (R < n && s[R-L] == s[R]) R++;
                z[i] = R-L; R--;
            }
        }
    }
}

inline long long ceil(long long x, long long y) {
    return (x + y - 1LL) / y;
}

ll n, ans0, nsub1, sum0;
bool saw1;

ll precompute(int node, int par, vector<vector<int>> &g, vector<int> &parent, vector<ll> &sub) {
    if (node == 1) saw1 = true;
    parent[node] = par;
    ll nsub = 0;
    for (auto u : g[node]) {
        if (u == par) continue;

        ll res = precompute(u, node, g, parent, sub);
        nsub += res;

        if (node == 0) {
            ans0 += ((res - 1LL) * res) >> 1;
            if (saw1) {
                saw1 = false;
                nsub1 = res;
                nsub -= res;
            } else {
                sum0 += (nsub - res) * res;
            }
        }
    }
    sub[node] = nsub;
    return nsub + 1LL;
}

void work() {
    cin >> n;
    vector<vector<int>> g(n);
    for (int i = 1; i < n; i++) {
        int u, v; cin >> u >> v;
        g[u].pb(v); g[v].pb(u);
    }
    vector<ll> nsub(n); vector<int> parent(n);
    ans0 = 0; saw1 = false; sum0 = 0;
    precompute(0, -1, g, parent, nsub);
    cout << ans0 << ' ';
    vector<bool> in_path(n, false);
    in_path[0] = true;
    int p = 1, prev_p = 1;
    while (p) {
        in_path[p] = true;
        prev_p = p;
        p = parent[p];
    }
    int l = 0, r = 1;
    ll ans1 = sum0 + nsub[0] + (nsub[0] + 1LL) * (nsub1 - nsub[1] - 1LL);
    cout << ans1;

    for (int i = 2; i < n; i++) {
        if (in_path[i]) { cout << " 0"; continue; }

        p = parent[i], prev_p = i;
        in_path[i] = true;
        while (!in_path[p]) {
            in_path[p] = true;
            prev_p = p;
            p = parent[p];
        }

        if (p != l && p != r) {
            cout << ' ' << (nsub[l] + 1LL) * (nsub[r] + 1LL);
            for (int j = i + 1; j <= n; j++) cout << " 0";
            cout << '\n';
            return;
        }

        cout << ' ';
        if (p == l) {
            cout << (nsub[r] + 1LL) * (nsub[l] + 1LL - nsub[i] - 1LL);
            l = i;
        } else {
            cout << (nsub[l] + 1LL) * (nsub[r] + 1LL - nsub[i] - 1LL);
            r = i;
        }
    }

    if (n >= 2) {
        int n2 = 0, n1 = 0;
        for (int i = 0; i < n; i++) {
            if (sz(g[i]) == 1) n1++;
            if (sz(g[i]) == 2) n2++;
        }
        if (n1 == 2 && n2 == n - 2)
            cout << " 1";
        else
            cout << " 0";
    }
    cout << '\n';
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int nt; cin>>nt; while (nt--) work();
    //work();
    return 0;
}
