#include using namespace std; using ll=long long; const ll mod=998244353; // v, Ke, maxTe // 1 0 0 ... invalid // 2 1 1 ... invalid (Ke is odd) // 3 3 2 ... invalid (Ke is odd) // 4 6 3 // 5 10 4 ... invalid // >5 ... invalid // tree of size 4 ... // a-b a-c a-d ... can't flip // a-b b-c c-d ... can flip int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int t; cin >> t; while(t>0){ t--; ll n; cin >> n; vector u(n),v(n); vector deg(n,0); for(ll i=1;i> u[i] >> v[i]; u[i]--; v[i]--; deg[u[i]]++; deg[v[i]]++; } ll res=0; for(ll i=1;i