There is a tree T with N vertices, numbered 1 through N. For each 1 ≤ i ≤ N - 1, the i-th edge connects vertices a_i and b_i.

Snuke is constructing a directed graph T' by arbitrarily assigning direction to each edge in T. (There are 2^{N - 1} different ways to construct T'.)

For a fixed T', we will define d(s,\ t) for each 1 ≤ s,\ t ≤ N, as follows:

* d(s,\ t) = (The number of edges that must be traversed against the assigned direction when traveling from vertex s to vertex t)



In particular, d(s,\ s) = 0 for each 1 ≤ s ≤ N. Also note that, in general, d(s,\ t) ≠ d(t,\ s).

We will further define D as the following:

3d2f3f88e8fa23f065c04cd175c14ebf.png

Snuke is constructing T' so that D will be the minimum possible value. How many different ways are there to construct T' so that D will be the minimum possible value, modulo 10^9 + 7?

Constraints

* 2 ≤ N ≤ 1000
* 1 ≤ a_i,\ b_i ≤ N
* The given graph is a tree.

Input

The input is given from Standard Input in the following format:


N
a_1 b_1
a_2 b_2
:
a_{N - 1} b_{N - 1}


Output

Print the number of the different ways to construct T' so that D will be the minimum possible value, modulo 10^9 + 7.

Examples

Input

4
1 2
1 3
1 4


Output

2


Input

4
1 2
2 3
3 4


Output

6


Input

6
1 2
1 3
1 4
2 5
2 6


Output

14


Input

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


Output

102
#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
inline void chmin(A &a, B b) {
  if (a > b) a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b) {
  if (a < b) a = b;
}
const long long mod = 1000000007;
inline void add(long long &a, long long b) {
  a += b;
  if (a >= mod) a -= mod;
}
long long mpow(long long n, long long m) {
  long long ret = 1;
  while (m) {
    if (m & 1) ret = ret * n % mod;
    n = n * n % mod;
    m >>= 1;
  }
  return ret;
}
const long long FACT_SIZE = 1111111;
long long fact[FACT_SIZE];
long long inv[FACT_SIZE];
struct fact_exec {
  fact_exec() {
    fact[0] = 1;
    for (long long i = 1; i < FACT_SIZE; i++) fact[i] = fact[i - 1] * i % mod;
    inv[FACT_SIZE - 1] = mpow(fact[FACT_SIZE - 1], mod - 2);
    for (long long i = FACT_SIZE - 2; i >= 0; i--)
      inv[i] = inv[i + 1] * (i + 1) % mod;
  }
} factexec;
long long nCk(long long n, long long k) {
  if (n < 0 | k < 0 || k > n) return 0;
  return fact[n] * inv[k] % mod * inv[n - k] % mod;
}
long long nPk(long long n, long long k) {
  if (n < 0 || k < 0 || k > n) return 0;
  return fact[n] * inv[n - k] % mod;
}
long long N;
vector<long long> G[1111];
long long dist[1111];
void dfs(long long v, long long p, long long d) {
  dist[v] = d;
  for (auto u : G[v]) {
    if (u == p) continue;
    dfs(u, v, d + 1);
  }
}
long long D;
long long X;
long long dp[1111][1111];
void dfs2(long long v, long long p, long long d) {
  for (long long i = 0; i < (D / 2 + 1); i++) dp[v][i] = 1;
  for (auto u : G[v]) {
    if (u == p) continue;
    dfs2(u, v, d + 1);
    for (long long i = 0; i < (D / 2 + 1); i++)
      dp[v][i] = dp[v][i] * (dp[u][i] + dp[u][i + 1]) % mod;
  }
  for (long long i = 0; i < (D / 2 + 1); i++)
    if (i > X || d - i > D / 2 - X) dp[v][i] = 0;
}
void solve(long long c) {
  long long ans = 0;
  for (X = 0; X <= D / 2; X++) {
    memset(dp, 0, sizeof(dp));
    dfs2(c, -1, 0);
    add(ans, dp[c][0]);
  }
  cout << ans << endl;
}
signed main() {
  cin >> N;
  for (long long i = 0; i < (N - 1); i++) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dfs(0, -1, 0);
  long long v = 0;
  for (long long i = 0; i < (N); i++)
    if (dist[i] > dist[v]) v = i;
  dfs(v, -1, 0);
  long long u = 0;
  for (long long i = 0; i < (N); i++)
    if (dist[i] > dist[u]) u = i;
  vector<long long> latte(N);
  for (long long i = 0; i < (N); i++) latte[i] = dist[i];
  dfs(u, -1, 0);
  for (long long i = 0; i < (N); i++) chmax(latte[i], dist[i]);
  vector<long long> lis;
  for (long long i = 0; i < (N); i++)
    if (latte[i] <= (dist[v] + 1) / 2) lis.push_back(i);
  D = dist[v];
  if (lis.size() == 1) {
    solve(lis[0]);
  } else {
    long long u = lis[0], v = lis[1];
    vector<long long> x(N), y(N), z(N), w(N);
    for (X = 0; X <= D / 2; X++) {
      memset(dp, 0, sizeof(dp));
      dfs2(u, v, 0);
      x[X] = dp[u][0];
      y[X] = dp[v][0];
    }
    D++;
    for (X = 0; X <= D / 2; X++) {
      memset(dp, 0, sizeof(dp));
      dfs2(u, v, 0);
      z[X] = dp[u][0];
      memset(dp, 0, sizeof(dp));
      dfs2(v, u, 0);
      w[X] = dp[v][0];
    }
    D--;
    z[0] = w[0] = 0;
    for (long long i = 1; i < N; i++)
      z[i] = (z[i] - x[i] - x[i - 1] + mod * 2) % mod;
    for (long long i = 1; i < N; i++)
      w[i] = (w[i] - y[i] - y[i - 1] + mod * 2) % mod;
    long long ans = 0;
    for (long long i = 0; i <= D / 2; i++) {
      for (long long j = 0; j <= D / 2; j++) {
        long long a = i;
        long long b = D / 2 - i;
        long long c = j;
        long long d = D / 2 - j;
        if (a + d <= D / 2 + 1 && b + c + 1 <= D / 2 + 1)
          add(ans, x[i] * y[j] % mod);
        if (a + d + 1 <= D / 2 + 1 && b + c <= D / 2 + 1)
          add(ans, x[i] * y[j] % mod);
      }
    }
    for (long long i = 0; i <= D / 2; i++) {
      for (long long j = 0; j <= D / 2 + 1; j++) {
        long long a = i;
        long long b = D / 2 - i;
        long long c = j;
        long long d = D / 2 + 1 - j;
        if (a + d <= D / 2 + 1 && b + c + 1 <= D / 2 + 1)
          add(ans, x[i] * w[j] % mod);
        if (a + d + 1 <= D / 2 + 1 && b + c <= D / 2 + 1)
          add(ans, x[i] * w[j] % mod);
      }
    }
    for (long long i = 0; i <= D / 2 + 1; i++) {
      for (long long j = 0; j <= D / 2 + 1; j++) {
        long long a = i;
        long long b = D / 2 + 1 - i;
        long long c = j;
        long long d = D / 2 + 1 - j;
        if (a + d <= D / 2 + 1 && b + c + 1 <= D / 2 + 1)
          add(ans, z[i] * w[j] % mod);
        if (a + d + 1 <= D / 2 + 1 && b + c <= D / 2 + 1)
          add(ans, z[i] * w[j] % mod);
      }
    }
    for (long long i = 0; i <= D / 2 + 1; i++) {
      for (long long j = 0; j <= D / 2; j++) {
        long long a = i;
        long long b = D / 2 + 1 - i;
        long long c = j;
        long long d = D / 2 - j;
        if (a + d <= D / 2 + 1 && b + c + 1 <= D / 2 + 1)
          add(ans, z[i] * y[j] % mod);
        if (a + d + 1 <= D / 2 + 1 && b + c <= D / 2 + 1)
          add(ans, z[i] * y[j] % mod);
      }
    }
    cout << ans << endl;
  }
  return 0;
}
