// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;



typedef long long lint;

typedef long double louble;



template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}

template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}



const char lf = '\n';



namespace ae86

{

	const int bufl = 1 << 15;



	char buf[bufl],*s=buf,*t=buf;



	inline int fetch()

	{

		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}

		return *s++;

	}



	inline int ty()

	{

		int a=0;int b=1,c=fetch();

		while(!isdigit(c))b^=c=='-',c=fetch();

		while(isdigit(c))a=a*10+c-48,c=fetch();

		return b?a:-a;

	}

}

using ae86::ty;



const int _ = 200007 , mo = 998244353;



template<typename T1,typename T2> inline T1 ad(T1 &a,T2 b){return a=a+b>=mo?a+b-mo:a+b;}

template<typename T1,typename T2> inline T1 dl(T1 &a,T2 b){return a=a>=b?a-b:a-b+mo;}

template<typename T1,typename T2> inline T1 add(T1 a,T2 b){return a+b>=mo?a+b-mo:a+b;}

template<typename T1,typename T2> inline T1 del(T1 a,T2 b){return a>=b?a-b:a-b+mo;}



lint powa(lint a,lint t)

{

	lint b=1;a=(a+mo)%mo;

	while(t){if(t&1)b=b*a%mo;a=a*a%mo,t>>=1;}

	return b;

}



inline lint inva(lint a)

{

	return powa(a,mo-2);

}



vector<int> e[_];



int n,fa[_]={0},rt=0,mxdep=0;



void dfs(int x,int ff,int dep)

{

	fa[x]=ff;

	if(dep>mxdep)mxdep=dep,rt=x;

	for(auto b:e[x])if(b!=ff)dfs(b,x,dep+1);

}



int ps[_]={0},lps=0;

lint f[_][3][3]={0};



void dfs2(int x,int ff,int dep)

{

	fa[x]=ff;

	memset(f[x],0,sizeof(f[x]));

	if(dep==lps/2)f[x][1][1]=1;

	else f[x][0][0]=1;



	for(auto b:e[x])

	{

		if(b==ff)continue;

		dfs2(b,x,dep+1);

		lint sf[3][3];memset(sf,0,sizeof(sf));

		for(int i=0;i<3;i++)

			for(int j=0;j<3;j++)

				for(int p=0;p<3;p++)

					for(int q=0;q<3;q++)

						for(int r=-1;r<=1;r++)

						{

							int pp=r==1?p:0,qq=r==-1?q:0;

							pp=min(2,pp+i),qq=min(2,qq+j);

							ad(sf[pp][qq],f[x][i][j]*f[b][p][q]%mo);

						}

		memcpy(f[x],sf,sizeof(sf));

	}

}



int main()

{

	ios::sync_with_stdio(0),cout.tie(nullptr);



	n=ty();

	for(int i=1,a,b;i<n;i++)a=ty(),b=ty(),e[a].emplace_back(b),e[b].emplace_back(a);



	dfs(1,0,1),mxdep=0,dfs(rt,0,1);

	for(int i=rt;i;i=fa[i])ps[++lps]=i;



	if(lps&1)

	{

		int mid=ps[lps/2+1];

		dfs2(mid,0,0);

		cout<<f[mid][1][1]*inva(2)%mo<<lf;

		return 0;

	}

	

	int ll=ps[lps/2],rr=ps[lps/2+1];

	dfs2(ll,rr,1),dfs2(rr,ll,1);

	cout<<add(add(f[ll][1][0],f[ll][1][1]),f[ll][1][2])

		*add(add(f[rr][0][1],f[rr][1][1]),f[rr][2][1])%mo<<lf;



	return 0;

}


// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;



int read(){

	int a = 0; char c = getchar(); while(!isdigit(c)) c = getchar();

	while(isdigit(c)){a = a * 10 + c - 48; c = getchar();} return a;

}



const int _ = 2e5 + 7 , MOD = 998244353 , iv2 = (MOD + 1) / 2;

struct Edge{int end , upEd;}Ed[_ << 1];

int dp[_][3][3] , N , cntEd , head[_];

void addEd(int a , int b){Ed[++cntEd] = (Edge){b , head[a]}; head[a] = cntEd;}



int mx , id , pre[_];

void dfs1(int x , int p , int l){

	pre[x] = p; if(l > mx){mx = l; id = x;}

	for(int i = head[x] ; i ; i = Ed[i].upEd)

		if(Ed[i].end != p) dfs1(Ed[i].end , x , l + 1);

}



int mxdep[_];

void dfs2(int x , int p){

	for(int i = head[x] ; i ; i = Ed[i].upEd)

		if(Ed[i].end != p){dfs2(Ed[i].end , x); mxdep[x] = max(mxdep[x] , mxdep[Ed[i].end] + 1);}

}



void DP(int x , int p){

	dp[x][0][0] = 1; bool flg = 0;

	for(int i = head[x] ; i ; i = Ed[i].upEd)

		if(Ed[i].end != p){

			flg = 1; DP(Ed[i].end , x); static int tmp[3][3]; memset(tmp , 0 , sizeof(tmp));

			for(int j = 0 ; j < 3 ; ++j)

				for(int k = 0 ; k < 3 ; ++k)

					for(int p = 0 ; p < 3 ; ++p)

						for(int q = 0 ; q < 3 ; ++q){

							int coef = 3;

							if(mxdep[Ed[i].end] + 1 == mxdep[x]){

								tmp[min(j + p , 2)][k] = (tmp[min(j + p , 2)][k] + 1ll * dp[x][j][k] * dp[Ed[i].end][p][q]) % MOD;

								tmp[j][min(k + q , 2)] = (tmp[j][min(k + q , 2)] + 1ll * dp[x][j][k] * dp[Ed[i].end][p][q]) % MOD;

								coef -= 2;

							}

							tmp[j][k] = (tmp[j][k] + 1ll * coef * dp[x][j][k] * dp[Ed[i].end][p][q]) % MOD;

						}

			memcpy(dp[x] , tmp , sizeof(tmp));

		}

	if(!flg){dp[x][0][0] = 0; dp[x][1][1] = 1;}

}



int main(){

	N = read(); for(int i = 1 ; i < N ; ++i){int x = read() , y = read(); addEd(x , y); addEd(y , x);}

	dfs1(1 , 0 , 0); mx = 0; int t = id; dfs1(t , 0 , 0);

	for(int i = 0 ; i < mx / 2 ; ++i) id = pre[id];

	if(mx & 1){

		dfs2(id , pre[id]); DP(id , pre[id]); dfs2(pre[id] , id); DP(pre[id] , id); int sum = 0;

		for(int i = 0 ; i < 3 ; ++i)

			for(int j = 0 ; j < 3 ; ++j)

				for(int k = 0 ; k < 3 ; ++k)

					for(int l = 0 ; l < 3 ; ++l){

						if(i == 1 && l == 1) sum = (sum + 1ll * dp[id][i][j] * dp[pre[id]][k][l]) % MOD;

						if(j == 1 && k == 1) sum = (sum + 1ll * dp[id][i][j] * dp[pre[id]][k][l]) % MOD;

					}

		printf("%lld\n" , 1ll * sum * iv2 % MOD);

	}else{dfs2(id , 0); DP(id , 0); printf("%lld\n" , 1ll * iv2 * dp[id][1][1] % MOD);}

	return 0;

}


// Fastest known solution for this problem: