#include<atcoder/modint>#include<bits/stdc++.h>usingnamespacestd;usingnamespaceatcoder;usingmint=modint998244353;classTree{public:intn;vector<vector<int>>adj;vector<vector<mint>>dp;// dp[i][d] is the count of induced connected subgraph such that the highest
// vertex is node i and it has degree d.
// All degrees >= 2 are treated as identical.
Tree(intn){this->n=n;adj.resize(n);dp.resize(n,vector<mint>(3,0));}voiddfs(intsrc,intpar){// Start with no children.
dp[src][0]=1;for(autochild:adj[src]){if(child==par){continue;}dfs(child,src);vector<mint>ndp(3);for(intd=0;d<3;d++){// Ignore this children.
ndp[d]+=dp[src][d];for(intnow=0;now<3;now++){intnxt=d+1;if(nxt>1){nxt=2;}// Append this children.
ndp[nxt]+=dp[src][d]*dp[child][now];}}swap(dp[src],ndp);}}};voidsolve(){intn;cin>>n;Treet(n);intm=n-1;for(inti=0;i<m;i++){intx,y;cin>>x>>y;x--;y--;t.adj[x].push_back(y);t.adj[y].push_back(x);}t.dfs(0,-1);mintans=0;auto&dp=t.dp;for(inti=0;i<n;i++){for(intd=0;d<3;d++){if(i==0){cout<<dp[i][d].val()<<" ";}ans+=dp[i][d];}}cout<<endl;cout<<ans.val()<<endl;}intmain(){intt;cin>>t;for(inti=0;i<t;i++){solve();}return0;}