#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef __int128_t LL;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define F first
#define S second
#define pb push_back
mt19937 rnd;

const int N = 4e5 + 10;
ll cnt[N], ans[N];

#define data my_data

const int L = 22;
int depth[N], sz[N], in[N], out[N];
vector<int> g[N];
vector<int> tour;
int data[N], table[N][L];
int lg[N], pw[L];

void init(int n) {
    for (int i = 0; i <= n + 3; i++) {
        g[i].clear();
        cnt[i] = 0;
        ans[i] = 0;
        sz[i] = 0;
        in[i] = 0;
        out[i] = 0;
    }
    tour.clear();
}

void dfs_lca(int v = 0, int p = 0) {
    in[v] = tour.size();
    tour.pb(v);
    sz[v] = 1;
    for (int to : g[v]) {
        if (to != p) {
            depth[to] = depth[v] + 1;
            dfs_lca(to, v);
            sz[v] += sz[to];
            tour.pb(v);
        }
    }
    out[v] = tour.size() - 1;
}

void build_sparse_table(int n) {
    pw[0] = 1;
    for (int i = 1; i <= L - 1; i++) {
        pw[i] = pw[i - 1] << 1;
    }
    for (int i = 1, k = 0; i <= n + n - 1; i <<= 1, k++) {
        for (int j = 0; j <= i - 1 && i + j <= n + n - 1; j++) {
            lg[i + j] = k;
        }
    }
    for (int i = 1; i <= n; i++) {
        table[i][0] = i;
    }
    for (int k = 1; k <= L - 1; k++) {
        for (int i = 1; i + pw[k] - 1 <= n; i++) {
            if (data[table[i][k - 1]] < data[table[i + pw[k - 1]][k - 1]]) {
                table[i][k] = table[i][k - 1];
            }
            else {
                table[i][k] = table[i + pw[k - 1]][k - 1];
            }
        }
    }
}

int get_pos_min(int l, int r) {
    if (data[table[l][lg[r - l + 1]]] < data[table[r - pw[lg[r - l + 1]] + 1][lg[r - l + 1]]]) {
        return table[l][lg[r - l + 1]];
    }
    else {
        return table[r - pw[lg[r - l + 1]] + 1][lg[r - l + 1]];
    }
}

int lca(int u, int v) {
    if (out[u] > out[v]) {
        swap(u, v);
    }
    return tour[get_pos_min(in[u] + 1, out[v] + 1) - 1];
}

void precalc_lca() {
    dfs_lca();
    for (int i = 1; i <= tour.size(); i++) {
        data[i] = depth[tour[i - 1]];
    }
    build_sparse_table(tour.size());
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        init(n);
        for (int i = 1; i <= n - 1; i++) {
            int u, v;
            cin >> u >> v;
            g[u].pb(v);
            g[v].pb(u);
        }
        precalc_lca();
        for (int to : g[0]) {
            ans[0] += 1ll * sz[to] * (sz[to] - 1) / 2;
        }
        cnt[0] = 1ll * n * (n - 1) / 2 - ans[0];
        int lef = 0, root = 0, rig = 0, ptr_lef = 0, ptr_rig = 0;
        for (int v = 1; v <= n - 1; v++) {
            if (lca(lef, v) == v && lca(v, root) == root) {

            }
            else if (lca(rig, v) == v && lca(v, root) == root) {

            }
            else if (lca(v, lef) == lef && lca(v, rig) == root) {
                if (lef == root) {
                    for (int to : g[root]) {
                        if (lca(v, to) == to) {
                            ptr_lef = to;
                        }
                    }
                }
                lef = v;
            }
            else if (lca(v, rig) == rig && lca(v, lef) == root) {
                if (rig == root) {
                    for (int to : g[root]) {
                        if (lca(v, to) == to) {
                            ptr_rig = to;
                        }
                    }
                }
                rig = v;
            }
            else {
                break;
            }
            if (lef == root) {
                cnt[v] = 1ll * (n - sz[ptr_rig]) * sz[rig];
            }
            else if (rig == root) {
                cnt[v] = 1ll * (n - sz[ptr_lef]) * sz[lef];
            }
            else {
                cnt[v] = 1ll * sz[lef] * sz[rig];
            }
        }
        for (int i = 0; i <= n; i++) {
            if (i) ans[i] = cnt[i - 1] - cnt[i];
            cout << ans[i] << " ";
        }
        cout << "\n";
    }

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}
