#include <bits/stdc++.h>
using namespace std;
bool SR(int &x) { return scanf("%d", &x) == 1; }
bool SR(long long &x) { return scanf("%lld", &x) == 1; }
bool SR(double &x) { return scanf("%lf", &x) == 1; }
bool SR(char *s) { return scanf("%s", s) == 1; }
bool RI() { return true; }
template <typename I, typename... T>
bool RI(I &x, T &...tail) {
  return SR(x) && RI(tail...);
}
void SP(const int x) { printf("%d", x); }
void SP(const long long x) { printf("%lld", x); }
void SP(const double x) { printf("%.16lf", x); }
void SP(const char *s) { printf("%s", s); }
void PL() { puts(""); }
template <typename I, typename... T>
void PL(const I x, const T... tail) {
  SP(x);
  if (sizeof...(tail)) putchar(' ');
  PL(tail...);
}
const int maxn = 7e2 + 2;
int n;
vector<int> edge[maxn];
void read() {
  RI(n);
  for (int i = 0; i < int(n - 1); i++) {
    int a, b;
    RI(a, b);
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
}
int par[maxn];
vector<int> kid[maxn];
void dfs1(int u, int p) {
  par[u] = p;
  for (auto v : edge[u])
    if (v != p) kid[u].push_back(v);
  for (auto v : kid[u]) dfs1(v, u);
}
struct lll {
  vector<long long> dat;
  lll() {}
  lll(const long long &x) : dat(1, x) { assert(x < 100000000); }
  bool operator<(const lll &x) const {
    if (((int)(dat).size()) != ((int)(x.dat).size()))
      return ((int)(dat).size()) < ((int)(x.dat).size());
    for (int i = ((int)(dat).size()) - 1; i >= 0; i--)
      if (dat[i] != x.dat[i]) return dat[i] < x.dat[i];
    return 0;
  }
  lll operator*(const lll &x) const {
    lll ret;
    ret.dat.clear();
    ret.dat.resize(((int)(dat).size()) + ((int)(x.dat).size()) - 1, 0);
    for (int i = 0; i < int(((int)(dat).size())); i++)
      for (int j = 0; j < int(((int)(x.dat).size())); j++)
        ret.dat[i + j] += dat[i] * x.dat[j];
    for (int i = 0; i < int(((int)(ret.dat).size())); i++) {
      if (ret.dat[i] >= 100000000) {
        if (i == ((int)(ret.dat).size()) - 1) ret.dat.push_back(0);
        ret.dat[i + 1] += ret.dat[i] / 100000000;
        ret.dat[i] %= 100000000;
      }
    }
    return ret;
  }
};
vector<lll> dp[maxn];
void merge(vector<lll> &a, const vector<lll> &b) {
  vector<lll> c(((int)(a).size()) + ((int)(b).size()) - 1, 0);
  for (int i = 0; i < int(((int)(a).size())); i++)
    for (int j = 0; j < int(((int)(b).size())); j++)
      c[i + j] = max(c[i + j], a[i] * b[j]);
  a = c;
}
void dfs2(int u) {
  for (auto v : kid[u]) dfs2(v);
  if (((int)(kid[u]).size()) == 0) {
    for (int i = 0; i < int(2); i++) dp[u].push_back(1);
    return;
  }
  dp[u].push_back(1);
  for (auto v : kid[u]) merge(dp[u], dp[v]);
  dp[u].insert(dp[u].begin(), 1);
  for (int i = 0; i < int(((int)(dp[u]).size())); i++) {
    auto tmp = dp[u][i] * i;
    if (dp[u][0] < tmp) dp[u][0] = tmp;
  }
}
void build() {
  dfs1(1, 0);
  dfs2(1);
}
void print(const lll &x) {
  printf("%lld", x.dat.back());
  for (int i = ((int)(x.dat).size()) - 2; i >= 0; i--)
    printf("%08lld", x.dat[i]);
  PL();
}
void sol() { print(dp[1][0]); }
int main() {
  read();
  build();
  sol();
  return 0;
}

### Prompt

Develop a solution in Cpp to the problem described below:

Recently Bob invented a new game with a tree (we should remind you, that a tree is a connected graph without cycles): he deletes any (possibly, zero) amount of edges of the tree, and counts the product of sizes of the connected components left after the deletion. Your task is to find out the maximum number that Bob can get in his new game for a given tree.

Input

The first input line contains integer number n (1 ≤ n ≤ 700) — amount of vertices in the tree. The following n - 1 lines contain the description of the edges. Each line contains the pair of vertices' indexes, joined by an edge, ai, bi (1 ≤ ai, bi ≤ n). It's guaranteed that the graph described in the input is a tree.

Output

Output the only number — the maximum product of sizes of the connected components, that Bob can get after deleting some of the tree's edges.

Examples

Input

5
1 2
2 3
3 4
4 5


Output

6

Input

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


Output

18

Input

3
1 2
1 3


Output

3

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
bool SR(int &x) { return scanf("%d", &x) == 1; }
bool SR(long long &x) { return scanf("%lld", &x) == 1; }
bool SR(double &x) { return scanf("%lf", &x) == 1; }
bool SR(char *s) { return scanf("%s", s) == 1; }
bool RI() { return true; }
template <typename I, typename... T>
bool RI(I &x, T &...tail) {
  return SR(x) && RI(tail...);
}
void SP(const int x) { printf("%d", x); }
void SP(const long long x) { printf("%lld", x); }
void SP(const double x) { printf("%.16lf", x); }
void SP(const char *s) { printf("%s", s); }
void PL() { puts(""); }
template <typename I, typename... T>
void PL(const I x, const T... tail) {
  SP(x);
  if (sizeof...(tail)) putchar(' ');
  PL(tail...);
}
const int maxn = 7e2 + 2;
int n;
vector<int> edge[maxn];
void read() {
  RI(n);
  for (int i = 0; i < int(n - 1); i++) {
    int a, b;
    RI(a, b);
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
}
int par[maxn];
vector<int> kid[maxn];
void dfs1(int u, int p) {
  par[u] = p;
  for (auto v : edge[u])
    if (v != p) kid[u].push_back(v);
  for (auto v : kid[u]) dfs1(v, u);
}
struct lll {
  vector<long long> dat;
  lll() {}
  lll(const long long &x) : dat(1, x) { assert(x < 100000000); }
  bool operator<(const lll &x) const {
    if (((int)(dat).size()) != ((int)(x.dat).size()))
      return ((int)(dat).size()) < ((int)(x.dat).size());
    for (int i = ((int)(dat).size()) - 1; i >= 0; i--)
      if (dat[i] != x.dat[i]) return dat[i] < x.dat[i];
    return 0;
  }
  lll operator*(const lll &x) const {
    lll ret;
    ret.dat.clear();
    ret.dat.resize(((int)(dat).size()) + ((int)(x.dat).size()) - 1, 0);
    for (int i = 0; i < int(((int)(dat).size())); i++)
      for (int j = 0; j < int(((int)(x.dat).size())); j++)
        ret.dat[i + j] += dat[i] * x.dat[j];
    for (int i = 0; i < int(((int)(ret.dat).size())); i++) {
      if (ret.dat[i] >= 100000000) {
        if (i == ((int)(ret.dat).size()) - 1) ret.dat.push_back(0);
        ret.dat[i + 1] += ret.dat[i] / 100000000;
        ret.dat[i] %= 100000000;
      }
    }
    return ret;
  }
};
vector<lll> dp[maxn];
void merge(vector<lll> &a, const vector<lll> &b) {
  vector<lll> c(((int)(a).size()) + ((int)(b).size()) - 1, 0);
  for (int i = 0; i < int(((int)(a).size())); i++)
    for (int j = 0; j < int(((int)(b).size())); j++)
      c[i + j] = max(c[i + j], a[i] * b[j]);
  a = c;
}
void dfs2(int u) {
  for (auto v : kid[u]) dfs2(v);
  if (((int)(kid[u]).size()) == 0) {
    for (int i = 0; i < int(2); i++) dp[u].push_back(1);
    return;
  }
  dp[u].push_back(1);
  for (auto v : kid[u]) merge(dp[u], dp[v]);
  dp[u].insert(dp[u].begin(), 1);
  for (int i = 0; i < int(((int)(dp[u]).size())); i++) {
    auto tmp = dp[u][i] * i;
    if (dp[u][0] < tmp) dp[u][0] = tmp;
  }
}
void build() {
  dfs1(1, 0);
  dfs2(1);
}
void print(const lll &x) {
  printf("%lld", x.dat.back());
  for (int i = ((int)(x.dat).size()) - 2; i >= 0; i--)
    printf("%08lld", x.dat[i]);
  PL();
}
void sol() { print(dp[1][0]); }
int main() {
  read();
  build();
  sol();
  return 0;
}

```