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 <class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& p) {
  return o << "(" << p.first << "," << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& vc) {
  o << "sz = " << vc.size() << endl << "[";
  for (const T& v : vc) o << v << ",";
  o << "]";
  return o;
}
struct mint {
  using ll = long long;
  const static ll mod = 1000000007;
  ll a;
  mint() : a(0) {}
  mint(ll a) : a((a % mod + mod) % mod) {}
  mint& operator+=(const mint& b) {
    if ((a += b.a) >= mod) a -= mod;
    return *this;
  }
  mint& operator-=(const mint& b) {
    if ((a += mod - b.a) >= mod) a -= mod;
    return *this;
  }
  mint& operator*=(const mint& b) {
    (a *= b.a) %= mod;
    return *this;
  }
  mint operator+(const mint& b) const { return mint(*this) += b; }
  mint operator-(const mint& b) const { return mint(*this) -= b; }
  mint operator*(const mint& b) const { return mint(*this) *= b; }
  mint operator-() const { return mint(-a); }
  ll extgcd(ll a, ll b, ll& x, ll& y) const {
    ll u[] = {a, 1, 0}, v[] = {b, 0, 1};
    while (*v) {
      ll t = *u / *v;
      for (int i = 0; i < (int)(3); i++) swap(u[i] -= t * v[i], v[i]);
    }
    if (u[0] < 0)
      for (int i = 0; i < (int)(3); i++) u[i] = -u[i];
    x = u[1], y = u[2];
    return u[0];
  }
  mint inv() const {
    ll x, y;
    extgcd(a, mod, x, y);
    if (x < 0) x += mod;
    return mint(x);
  }
  mint& operator/=(const mint& b) {
    (*this) *= b.inv();
    return *this;
  }
  mint operator/(const mint& b) const { return mint(*this) /= b; }
  bool operator==(const mint& b) const { return a == b.a; }
  bool operator!=(const mint& b) const { return a != b.a; }
  friend istream& operator>>(istream& o, mint& x) {
    ll tmp;
    o >> tmp;
    x = mint(tmp);
    return o;
  }
  friend ostream& operator<<(ostream& o, const mint& x) { return o << x.a; }
};
int inf = 1e8;
const int MN = 1000;
int N;
vector<int> G[MN];
vector<int> chs[MN];
vector<int> ord;
int depth[MN];
int dp[MN][MN];
int tmp[MN][MN];
bool can(int X) {
  for (int i = 0; i < (int)(N); i++)
    for (int j = 0; j < (int)(N); j++) dp[i][j] = inf;
  for (int v : ord) {
    int n = chs[v].size();
    for (int i = 0; i < (int)(n + 1); i++)
      for (int j = 0; j < (int)(N); j++) tmp[i][j] = inf;
    tmp[0][0] = 0;
    for (int ui = 0; ui < (int)(n); ui++) {
      int u = chs[v][ui];
      for (int a = 0; a < (int)(depth[v] + 1); a++)
        if (tmp[ui][a] != inf) {
          int b = tmp[ui][a];
          for (int ua = 0; ua < (int)(depth[u] + 1); ua++) {
            int ub = dp[u][ua];
            if (ub == inf) continue;
            for (int dir = 0; dir < (int)(2); dir++) {
              int aa = ua + dir;
              int bb = ub + (1 - dir);
              if (a + bb > X || b + aa > X) continue;
              int nui = ui + 1;
              int na = max(a, aa);
              int nb = max(b, bb);
              tmp[nui][na] = min(tmp[nui][na], nb);
            }
          }
        }
    }
    for (int a = 0; a < (int)(depth[v] + 1); a++) dp[v][a] = tmp[n][a];
  }
  int root = ord.back();
  for (int a = 0; a < (int)(depth[root] + 1); a++)
    if (dp[root][a] != inf) return 1;
  return 0;
}
typedef pair<int, mint> P;
P dpa[MN][MN];
P tmpa[MN][MN];
mint count(int X) {
  for (int i = 0; i < (int)(N); i++)
    for (int j = 0; j < (int)(N); j++) dpa[i][j] = P(inf, 0);
  for (int v : ord) {
    int n = chs[v].size();
    for (int i = 0; i < (int)(n + 1); i++)
      for (int j = 0; j < (int)(N); j++) tmpa[i][j] = P(inf, 0);
    tmpa[0][0] = P(0, 1);
    for (int ui = 0; ui < (int)(n); ui++) {
      int u = chs[v][ui];
      for (int a = 0; a < (int)(depth[v] + 1); a++)
        if (tmpa[ui][a].first != inf) {
          int b = tmpa[ui][a].first;
          mint num = tmpa[ui][a].second;
          for (int ua = 0; ua < (int)(depth[u] + 1); ua++) {
            int ub = dpa[u][ua].first;
            mint unum = dpa[u][ub].second;
            if (ub == inf) continue;
            mint coef = num * unum;
            for (int dir = 0; dir < (int)(2); dir++) {
              int aa = ua + dir;
              int bb = ub + (1 - dir);
              if (a + bb > X || b + aa > X) continue;
              int nui = ui + 1;
              int na = max(a, aa);
              int nb = max(b, bb);
              if (tmpa[nui][na].first > nb) {
                tmpa[nui][na] = P(nb, coef);
              } else if (tmpa[nui][na].first == nb) {
                tmpa[nui][na].second += coef;
              }
            }
          }
        }
    }
    for (int a = 0; a < (int)(depth[v] + 1); a++) dpa[v][a] = tmpa[n][a];
  }
  int root = ord.back();
  mint ans = 0;
  for (int a = 0; a < (int)(depth[root] + 1); a++)
    if (dpa[root][a].first != inf) {
      ans += dpa[root][a].second;
    }
  return ans;
}
int predfs(int v, int p = -1) {
  int dep = 0;
  for (int u : G[v])
    if (u != p) dep = max(dep, predfs(u, v) + 1), chs[v].push_back(u);
  depth[v] = dep;
  ord.push_back(v);
  return dep;
}
int main() {
  int root = 0;
  cin >> N;
  for (int i = 0; i < (int)(N - 1); i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  predfs(root);
  int ub = N - 1, lb = -1;
  while (ub - lb > 1) {
    int m = (ub + lb) / 2;
    if (can(m))
      ub = m;
    else
      lb = m;
  }
  cout << count(ub) << endl;
}
