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;
const int iinf = 1e9 + 7;
const long long linf = 1ll << 60;
const double dinf = 1e60;
template <typename T>
inline void scf(T &x) {
  bool f = 0;
  x = 0;
  char c = getchar();
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') {
    f = 1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  if (f) x = -x;
  return;
}
template <typename T1, typename T2>
void scf(T1 &x, T2 &y) {
  scf(x);
  return scf(y);
}
template <typename T1, typename T2, typename T3>
void scf(T1 &x, T2 &y, T3 &z) {
  scf(x);
  scf(y);
  return scf(z);
}
template <typename T1, typename T2, typename T3, typename T4>
void scf(T1 &x, T2 &y, T3 &z, T4 &w) {
  scf(x);
  scf(y);
  scf(z);
  return scf(w);
}
inline char mygetchar() {
  char c = getchar();
  while (c == ' ' || c == '\n') c = getchar();
  return c;
}
template <typename T>
void chkmax(T &x, const T &y) {
  if (y > x) x = y;
  return;
}
template <typename T>
void chkmin(T &x, const T &y) {
  if (y < x) x = y;
  return;
}
const int N = 1e3 + 100;
const int mod = 1e9 + 7;
int n, diameter_length, min_D;
int dp[N][N / 2], tag[N / 2][N], current_time;
vector<int> g[N];
vector<int> diameter_path;
namespace TREE {
int par[N], dep[N];
void dfs(int u = 1, int fa = 0) {
  par[u] = fa;
  dep[u] = dep[fa] + 1;
  for (int v : g[u])
    if (v != fa) dfs(v, u);
  return;
}
void get_diameter() {
  dfs();
  int mx = -1, S, T;
  for (int i = (1); i <= (n); ++i)
    if (dep[i] > mx) mx = dep[i], S = i;
  dfs(S);
  mx = -1;
  for (int i = (1); i <= (n); ++i)
    if (dep[i] > mx) mx = dep[i], T = i;
  diameter_length = dep[T] - 1;
  min_D = dep[T] >> 1;
  int u = T;
  while (u != S) diameter_path.push_back(u), u = par[u];
  diameter_path.push_back(S);
  return;
}
}  // namespace TREE
void MEI() {
  scf(n);
  for (int i = 0; i < (n - 1); ++i) {
    int u, v;
    scf(u, v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  TREE::get_diameter();
  return;
}
namespace Bamboo {
void solve() {
  dp[0][0] = 1;
  for (int i = (1); i <= (n - 1); ++i) {
    dp[i][0] = dp[i][i] = 1;
    for (int j = (1); j <= (i - 1); ++j)
      dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j]) % mod;
  }
  printf("%d\n", dp[n - 1][min_D] * 2 % mod);
  return;
}
}  // namespace Bamboo
namespace Odd {
int root1, root2, only_down, only_up;
void DP1(int u, int par, int max_down, int max_up) {
  if (tag[u][max_down] == current_time) return;
  tag[u][max_down] = current_time;
  int &t = dp[u][max_down];
  t = 1;
  for (int v : g[u])
    if (v != par && v != root2) {
      int foo = 0;
      if (max_down) DP1(v, u, max_down - 1, max_up), foo += dp[v][max_down - 1];
      if (max_up) DP1(v, u, max_down, max_up - 1), foo += dp[v][max_down];
      t = 1ll * t * foo % mod;
    }
  if (u == root1 && max_down) {
    DP1(root2, root1, max_down, max_up);
    t = 1ll * t * dp[root2][max_down] % mod;
  }
  return;
}
void DP2(int u, int par, int max_down, int max_up) {
  if (tag[u][max_down] == current_time) return;
  tag[u][max_down] = current_time;
  int &t = dp[u][max_down];
  t = 1;
  for (int v : g[u])
    if (v != par) {
      int foo = 0;
      if (max_down && v != only_up)
        DP1(v, u, max_down - 1, max_up), foo += dp[v][max_down - 1];
      if (max_up && v != only_down)
        DP1(v, u, max_down, max_up - 1), foo += dp[v][max_down];
      t = 1ll * t * foo % mod;
    }
  return;
}
void solve() {
  int ans = 0;
  root1 = diameter_path[min_D], root2 = diameter_path[min_D - 1];
  for (int max_down = 0; max_down < (min_D); ++max_down) {
    current_time++;
    DP1(root1, 0, max_down, min_D - 1 - max_down);
    ans += dp[root1][max_down];
    if (ans >= mod) ans -= mod;
  }
  g[diameter_path.back()].push_back(n + 1);
  only_up = n + 1;
  only_down = root2;
  for (int max_down = (0); max_down <= (min_D); ++max_down) {
    current_time++;
    DP2(root1, 0, max_down, min_D - max_down);
    ans += dp[root1][max_down];
    if (ans >= mod) ans -= mod;
  }
  printf("%d\n", ans * 2 % mod);
  return;
}
}  // namespace Odd
namespace Even {
void DP(int u, int par, int max_down, int max_up) {
  if (tag[u][max_down] == current_time) return;
  tag[u][max_down] = current_time;
  int &t = dp[u][max_down];
  t = 1;
  for (int v : g[u])
    if (v != par) {
      int foo = 0;
      if (max_down) DP(v, u, max_down - 1, max_up), foo += dp[v][max_down - 1];
      if (max_up) DP(v, u, max_down, max_up - 1), foo += dp[v][max_down];
      t = 1ll * t * foo % mod;
    }
  return;
}
void solve() {
  int root = diameter_path[min_D];
  int ans = 0;
  for (int max_down = (0); max_down <= (min_D); ++max_down) {
    current_time++;
    DP(root, 0, max_down, min_D - max_down);
    ans += dp[root][max_down];
    if (ans >= mod) ans -= mod;
  }
  printf("%d\n", ans);
  return;
}
}  // namespace Even
void ZI() {
  if (diameter_length == n - 1)
    Bamboo::solve();
  else if (diameter_length & 1)
    Odd::solve();
  else
    Even::solve();
  return;
}
int main() {
  MEI();
  ZI();
  return 0;
}
