#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 200010;

ll ans[N];
bool path[N];
vector <int> g[N];
int t, n, sub[N], p[N], ptr, in[N], out[N];

void go (int u, int par = -1) {
  in[u] = ++ptr;
  sub[u] = 1, p[u] = par;
  for (int v : g[u]) if (v != par and !path[v]) {
    go(v, u);
    sub[u] += sub[v];
  } 
  out[u] = ptr;
}

int main() {
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 0; i <= n; ++i) {
      g[i].clear(); path[i] = 0; 
      ans[i] = in[i] = out[i] = 0;
    }
    for (int i = 1, u, v; i < n; ++i) {
      scanf("%d %d", &u, &v);
      g[u].emplace_back(v);
      g[v].emplace_back(u);
    }
    ptr = 0; go(0);
    { // zero
      for (int u : g[0]) ans[0] += (ll) sub[u] * (sub[u] - 1) / 2;
    }
    { // one
      ans[1] += (ll) n * (n - 1) / 2 - ans[0];
      int u = 1;
      while (p[u]) u = p[u];
      ans[1] -= (ll) sub[1] * (n - sub[u]);
    }
    { // mark path
      int u = 1;
      while (u) path[u] = 1, u = p[u];
      path[0] = 1; ptr = 0; 
      for (int i = 0; i <= n; ++i) in[i] = out[i] = 0;
      go(0); go(1);
    }
    // for (int i = 0; i < n; ++i) cerr << sub[i] << " "; cerr << '\n';
    int A = 0, B = 1;
    for (int mex = 2; mex <= n; ++mex) {
      if (!path[mex]) {
        ll one = sub[A], two = sub[B];
        if (in[A] <= in[mex] and in[mex] <= out[A]) one -= sub[mex];
        if (in[B] <= in[mex] and in[mex] <= out[B]) two -= sub[mex];
        // cerr << mex << " --> " << one << " " << two << '\n';
        ans[mex] += one * two;
        if (in[A] <= in[mex] and in[mex] <= out[A]) {
          int u = mex;
          while (u ^ A) path[u] = 1, u = p[u];
          A = mex;
        }
        if (in[B] <= in[mex] and in[mex] <= out[B]) {
          int u = mex;
          while (u ^ B) path[u] = 1, u = p[u];
          B = mex;
        }
      }
      if (!path[mex]) break;
    }
    for (int i = 0; i <= n; ++i) printf("%lld ", ans[i]); puts("");
  }
  return 0;
}

