Problem: We have a tree G with N vertices numbered 1 to N. The i-th edge of G connects Vertex a_i and Vertex b_i.

Consider adding zero or more edges in G, and let H be the graph resulted.

Find the number of graphs H that satisfy the following conditions, modulo 998244353.

* H does not contain self-loops or multiple edges.
* The diameters of G and H are equal.
* For every pair of vertices in H that is not directly connected by an edge, the addition of an edge directly connecting them would reduce the diameter of the graph.

Constraints

* 3 \le N \le 2 \times 10^5
* 1 \le a_i, b_i \le N
* The given graph is a tree.

Input

Input is given from Standard Input in the following format:


N
a_1 b_1
\vdots
a_{N-1} b_{N-1}


Output

Print the answer.

Examples

Input

6
1 6
2 1
5 2
3 4
2 3


Output

3


Input

3
1 2
2 3


Output

1


Input

9
1 2
2 3
4 2
1 7
6 1
2 5
5 9
6 8


Output

27


Input

19
2 4
15 8
1 16
1 3
12 19
1 18
7 11
11 15
12 9
1 6
7 14
18 2
13 12
13 5
16 13
7 1
11 10
7 17


Output

78732

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) int(a.size())
const int N=2e5+10;
const int mod=998244353;

int gi() {
	int x=0,o=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n,f[N][3][3],mx,p,fa[N],st[N],md[N],tp;
vi E[N];

void dfs(int u,int ff,int dis) {
	fa[u]=ff;
	if(dis>mx) mx=dis,p=u;
	for(auto v:E[u]) if(v!=ff) dfs(v,u,dis+1);
}

void dp(int u,int ff) {
	md[u]=0;
	for(auto v:E[u]) if(v!=ff) dp(v,u),md[u]=max(md[u],md[v]);
	if(md[u]==0) f[u][1][1]=1;
	else f[u][0][0]=1;
	for(auto v:E[u])
		if(v!=ff) {
			static int g[3][3];memset(g,0,sizeof(g));
			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++) {
							int &t=g[min(i+(md[u]==md[v]?k:0),2)][min(j+(md[u]==md[v]?l:0),2)];
							t=(t+1ll*f[u][i][j]*f[v][k][l])%mod;
						}
			for(int i=0;i<3;i++)
				for(int j=0;j<3;j++) f[u][i][j]=g[i][j];
		}
	if(ff) {
		static int g[3][3];memset(g,0,sizeof(g));
		for(int i=0;i<3;i++)
			for(int j=0;j<3;j++) {
				g[0][0]=(g[0][0]+f[u][i][j])%mod;
				g[i][0]=(g[i][0]+f[u][i][j])%mod;
				g[0][j]=(g[0][j]+f[u][i][j])%mod;
			}
		for(int i=0;i<3;i++)
			for(int j=0;j<3;j++) f[u][i][j]=g[i][j];
		++md[u];
	}
}

int main() {
	cin>>n;
	for(int i=1,u,v;i<n;i++) u=gi(),v=gi(),E[u].pb(v),E[v].pb(u);
	dfs(1,0,0);mx=0;dfs(p,0,0);
	for(int i=p;i;i=fa[i]) st[++tp]=i;
	if(tp&1) {
		int x=st[(tp+1)/2];
		//cerr<<x<<'\n';
		dp(x,0);cout<<1ll*f[x][1][1]*((mod+1)>>1)%mod;
	}
	else {
		int x=st[tp/2],y=st[tp/2+1];
		dp(x,y);dp(y,x);cout<<1ll*f[x][0][1]*f[y][1][0]%mod;
	}
	return 0;
}