/*
For even diameter D, label tree vertices with -D/2..D/2 so adjacent vertices have label diff <= 1,
and there are exactly one vertex labelled D/2 and one -D/2.
*/
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
const int MOD = 998244353;
struct Mint {
	int val;
	Mint() { val = 0; }
	Mint(const ll& x) {
		val = (-MOD <= x && x < MOD) ? x : x % MOD;
		if (val < 0) val += MOD;
	}
	template <typename U>
	explicit operator U() const { return (U)val; }
	friend bool operator==(const Mint& a, const Mint& b) { return a.val == b.val; }
	friend bool operator!=(const Mint& a, const Mint& b) { return !(a == b); }
	friend bool operator<(const Mint& a, const Mint& b) { return a.val < b.val; }
	Mint& operator+=(const Mint& m) { if ((val += m.val) >= MOD) val -= MOD; return *this; }
	Mint& operator-=(const Mint& m) { if ((val -= m.val) < 0) val += MOD; return *this; }
	Mint& operator*=(const Mint& m) { val = (ll)val * m.val % MOD; return *this; }
	friend Mint modex(Mint a, ll p) {
		assert(p >= 0);
		Mint ans = 1;
		for (; p; p >>= 1, a *= a) if (p & 1) ans *= a;
		return ans;
	}
	Mint& operator/=(const Mint& m) { return *this *= modex(m, MOD - 2); }
	Mint& operator++() { return *this += 1; }
	Mint& operator--() { return *this -= 1; }
	Mint operator++(int) { Mint result(*this); *this += 1; return result; }
	Mint operator--(int) { Mint result(*this); *this -= 1; return result; }
	Mint operator-() const { return Mint(-val); }
	friend Mint operator+(Mint a, const Mint& b) { return a += b; }
	friend Mint operator-(Mint a, const Mint& b) { return a -= b; }
	friend Mint operator*(Mint a, const Mint& b) { return a *= b; }
	friend Mint operator/(Mint a, const Mint& b) { return a /= b; }
	friend ostream& operator<<(ostream& os, const Mint& x) { return os << x.val; }
};
const int MAXN = 200005;
vector<int> E[MAXN];
Mint F[MAXN][3][3];
int lim;
void go(int x, int p = -1, int h = 0) {
	if (h == lim) return;
	vector<vector<Mint>> dp(3, vector<Mint>(3));
	dp[0][0] = 1;
	for (int y : E[x]) {
		if (y == p) continue;
		go(y, x, h + 1);
		vector<vector<Mint>> ndp(3, vector<Mint>(3));
		for (int a = 0; a < 3; ++a)
			for (int b = 0; b < 3; ++b) {
				for (int aa = 0; aa < 3; ++aa)
					for (int bb = 0; bb < 3; ++bb) {
						ndp[min(a + aa, 2)][b] += dp[a][b] * F[y][aa][bb];
						ndp[a][min(b + bb, 2)] += dp[a][b] * F[y][aa][bb];
						ndp[a][b] += dp[a][b] * F[y][aa][bb];
					}
				if (h + 1 == lim) {
					ndp[min(a + 1, 2)][b] += dp[a][b];
					ndp[a][min(b + 1, 2)] += dp[a][b];
					ndp[a][b] += dp[a][b];
				}
			}
		swap(dp, ndp);
	}
	for (int a = 0; a < 3; ++a)
		for (int b = 0; b < 3; ++b)
			F[x][a][b] = dp[a][b];
}
int pv[MAXN];
int mxh, mxv;
void dfs(int x, int p = -1, int h = 0) {
	if (h > mxh) {
		mxh = h;
		mxv = x;
	}
	for (int y : E[x]) {
		if (y == p) continue;
		pv[y] = x;
		dfs(y, x, h + 1);
	}
}
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i < n; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		E[a].push_back(b);
		E[b].push_back(a);
	}
	mxh = -1;
	dfs(1);
	mxh = -1;
	int diam1 = mxv;
	dfs(mxv);
	int diam2 = mxv;
	vector<int> path;
	for (int i = diam2;; i = pv[i]) {
		path.push_back(i);
		if (i == diam1) break;
	}
	if (mxh % 2 == 0) {
		lim = mxh / 2;
		int cen = path[lim];
		go(cen);
		assert(F[cen][0][1] == F[cen][1][0]);
		assert(F[cen][0][2] == F[cen][2][0]);
		Mint ans = F[cen][1][1] / 2;
		printf("%d\n", ans.val);
	} else {
		lim = mxh / 2;
		int cen1 = path[lim], cen2 = path[lim + 1];
		go(cen1, cen2);
		Mint ans = F[cen1][1][0] + F[cen1][1][1] + F[cen1][1][2];
		memset(F, 0, sizeof(F));
		go(cen2, cen1);
		ans *= F[cen2][0][1] + F[cen2][1][1] + F[cen2][2][1];
		printf("%d\n", ans.val);
	}
}


Measured memory_bytes: 42084