#include <bits/stdc++.h>
using namespace std;
int Getchar() {
  int tmp = 0;
  char ch;
  while (ch = getchar())
    if (ch >= '0' && ch <= '9') break;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) tmp = tmp * 10 + ch - '0';
  return tmp;
}
struct bign {
  static const int maxlen = 30, limit = 10000, width = 4;
  int len, bit[maxlen];
  int& operator[](int p) { return bit[p]; }
  void ClearBit() { memset(bit, 0, sizeof(bit)); }
  void Delete0() {
    for (; !bit[len - 1] && len > 1; --len)
      ;
  }
  bign(int p = 0) { *this = p; }
  bign& operator=(int p) {
    ClearBit();
    len = p ? 0 : 1;
    for (; p; p /= limit) bit[len++] = p % limit;
    return *this;
  }
  bign(const char* p) { *this = p; }
  bign& operator=(const char* p) {
    ClearBit();
    len = 0;
    int now = 0;
    for (int i = strlen(p) - 1; i >= 0; i -= 4) {
      int now = 0;
      for (int j = max(0, i - width + 1); j <= i; ++j)
        now = now * 10 + (p[j] - '0');
      bit[len++] = now;
    }
    return *this;
  }
  bign& operator+=(bign b) {
    len = max(len, b.len) + 1;
    for (int i = 0; i < len; ++i)
      bit[i] += b[i], bit[i + 1] += bit[i] / limit, bit[i] %= limit;
    Delete0();
    return *this;
  }
  bign& operator-=(bign b) {
    for (int i = 0; i < len; ++i) {
      bit[i] -= b[i];
      if (bit[i] < 0) bit[i] += limit, --bit[i + 1];
    }
    Delete0();
    return *this;
  }
  bign& operator*=(bign b) {
    bign a = *this;
    ClearBit();
    len = a.len + b.len;
    for (int i = 0; i < a.len; ++i)
      for (int j = 0; j < b.len; ++j)
        bit[i + j] += a[i] * b[j], bit[i + j + 1] += bit[i + j] / limit,
            bit[i + j] %= limit;
    Delete0();
    return *this;
  }
  bign& operator/=(int b) {
    for (int i = len - 1; i > 0; --i)
      bit[i - 1] += limit * (bit[i] % b), bit[i] /= b;
    bit[0] /= b;
    Delete0();
    return *this;
  }
  bool operator<(bign b) const {
    if (len > b.len) return false;
    if (len < b.len) return true;
    for (int i = len - 1; i >= 0; --i)
      if (bit[i] != b[i]) return bit[i] < b[i];
    return bit[0] < b[0];
  }
  bool operator==(bign b) const { return !(*this < b) && !(b < *this); }
  bool operator!=(bign b) const { return !(*this == b); }
  bool operator>(bign b) const { return !(*this < b) && !(*this == b); }
  bool operator<=(bign b) const { return *this < b || *this == b; }
  bool operator>=(bign b) const { return *this > b || *this == b; }
};
bign operator+(bign a, bign b) { return a += b; }
bign operator-(bign a, bign b) { return a -= b; }
bign operator*(bign a, bign b) { return a *= b; }
bign operator/(bign a, int b) { return a /= b; }
istream& operator>>(istream& is, bign& p) {
  string s;
  is >> s;
  p = s.c_str();
  return is;
}
ostream& operator<<(ostream& os, bign p) {
  os.fill('0');
  os << p.bit[p.len - 1];
  for (int i = p.len - 2; i >= 0; --i) {
    os.width(bign::width);
    os << p.bit[i];
  }
  return os;
}
bign sqrt(bign x) {
  bign head = 1, tail = x;
  while (head <= tail) {
    bign mid = (head + tail) / 2;
    if (x < mid * mid)
      tail = mid - 1;
    else
      head = mid + 1;
  }
  return tail;
}
int n, m, tot;
int pre[111111], now[111111], son[111111];
bign f[710][710];
void cc(int a, int b) {
  pre[++tot] = now[a];
  now[a] = tot;
  son[tot] = b;
}
void init() {
  n = Getchar();
  for (int i = 1; i <= n - 1; i++) {
    int a = Getchar(), b = Getchar();
    cc(a, b);
    cc(b, a);
  }
}
int sum[789];
bign tmp[711];
void dfs(int x, int fa) {
  sum[x] = 1;
  f[x][1] = 1;
  for (int p = now[x]; p; p = pre[p])
    if (son[p] != fa) {
      dfs(son[p], x);
      for (int i = 1; i <= n; i++) tmp[i] = f[x][i];
      for (int i = 1; i <= sum[x]; i++)
        for (int j = 1; j <= sum[son[p]]; j++) {
          tmp[i + j] =
              max(tmp[i + j], f[son[p]][j] * f[x][i] / i / j * (i + j));
          tmp[i] = max(tmp[i], f[x][i] * f[son[p]][j]);
        }
      for (int i = 1; i <= n; i++) f[x][i] = tmp[i];
      sum[x] += sum[son[p]];
    }
}
void work() {
  dfs(1, 1);
  bign ans = 0;
  for (int i = 1; i <= n; i++) ans = max(ans, f[1][i]);
  cout << ans << endl;
}
int main() {
  init();
  work();
  return 0;
}

### Prompt

Please create a solution in CPP to the following problem:

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;
int Getchar() {
  int tmp = 0;
  char ch;
  while (ch = getchar())
    if (ch >= '0' && ch <= '9') break;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) tmp = tmp * 10 + ch - '0';
  return tmp;
}
struct bign {
  static const int maxlen = 30, limit = 10000, width = 4;
  int len, bit[maxlen];
  int& operator[](int p) { return bit[p]; }
  void ClearBit() { memset(bit, 0, sizeof(bit)); }
  void Delete0() {
    for (; !bit[len - 1] && len > 1; --len)
      ;
  }
  bign(int p = 0) { *this = p; }
  bign& operator=(int p) {
    ClearBit();
    len = p ? 0 : 1;
    for (; p; p /= limit) bit[len++] = p % limit;
    return *this;
  }
  bign(const char* p) { *this = p; }
  bign& operator=(const char* p) {
    ClearBit();
    len = 0;
    int now = 0;
    for (int i = strlen(p) - 1; i >= 0; i -= 4) {
      int now = 0;
      for (int j = max(0, i - width + 1); j <= i; ++j)
        now = now * 10 + (p[j] - '0');
      bit[len++] = now;
    }
    return *this;
  }
  bign& operator+=(bign b) {
    len = max(len, b.len) + 1;
    for (int i = 0; i < len; ++i)
      bit[i] += b[i], bit[i + 1] += bit[i] / limit, bit[i] %= limit;
    Delete0();
    return *this;
  }
  bign& operator-=(bign b) {
    for (int i = 0; i < len; ++i) {
      bit[i] -= b[i];
      if (bit[i] < 0) bit[i] += limit, --bit[i + 1];
    }
    Delete0();
    return *this;
  }
  bign& operator*=(bign b) {
    bign a = *this;
    ClearBit();
    len = a.len + b.len;
    for (int i = 0; i < a.len; ++i)
      for (int j = 0; j < b.len; ++j)
        bit[i + j] += a[i] * b[j], bit[i + j + 1] += bit[i + j] / limit,
            bit[i + j] %= limit;
    Delete0();
    return *this;
  }
  bign& operator/=(int b) {
    for (int i = len - 1; i > 0; --i)
      bit[i - 1] += limit * (bit[i] % b), bit[i] /= b;
    bit[0] /= b;
    Delete0();
    return *this;
  }
  bool operator<(bign b) const {
    if (len > b.len) return false;
    if (len < b.len) return true;
    for (int i = len - 1; i >= 0; --i)
      if (bit[i] != b[i]) return bit[i] < b[i];
    return bit[0] < b[0];
  }
  bool operator==(bign b) const { return !(*this < b) && !(b < *this); }
  bool operator!=(bign b) const { return !(*this == b); }
  bool operator>(bign b) const { return !(*this < b) && !(*this == b); }
  bool operator<=(bign b) const { return *this < b || *this == b; }
  bool operator>=(bign b) const { return *this > b || *this == b; }
};
bign operator+(bign a, bign b) { return a += b; }
bign operator-(bign a, bign b) { return a -= b; }
bign operator*(bign a, bign b) { return a *= b; }
bign operator/(bign a, int b) { return a /= b; }
istream& operator>>(istream& is, bign& p) {
  string s;
  is >> s;
  p = s.c_str();
  return is;
}
ostream& operator<<(ostream& os, bign p) {
  os.fill('0');
  os << p.bit[p.len - 1];
  for (int i = p.len - 2; i >= 0; --i) {
    os.width(bign::width);
    os << p.bit[i];
  }
  return os;
}
bign sqrt(bign x) {
  bign head = 1, tail = x;
  while (head <= tail) {
    bign mid = (head + tail) / 2;
    if (x < mid * mid)
      tail = mid - 1;
    else
      head = mid + 1;
  }
  return tail;
}
int n, m, tot;
int pre[111111], now[111111], son[111111];
bign f[710][710];
void cc(int a, int b) {
  pre[++tot] = now[a];
  now[a] = tot;
  son[tot] = b;
}
void init() {
  n = Getchar();
  for (int i = 1; i <= n - 1; i++) {
    int a = Getchar(), b = Getchar();
    cc(a, b);
    cc(b, a);
  }
}
int sum[789];
bign tmp[711];
void dfs(int x, int fa) {
  sum[x] = 1;
  f[x][1] = 1;
  for (int p = now[x]; p; p = pre[p])
    if (son[p] != fa) {
      dfs(son[p], x);
      for (int i = 1; i <= n; i++) tmp[i] = f[x][i];
      for (int i = 1; i <= sum[x]; i++)
        for (int j = 1; j <= sum[son[p]]; j++) {
          tmp[i + j] =
              max(tmp[i + j], f[son[p]][j] * f[x][i] / i / j * (i + j));
          tmp[i] = max(tmp[i], f[x][i] * f[son[p]][j]);
        }
      for (int i = 1; i <= n; i++) f[x][i] = tmp[i];
      sum[x] += sum[son[p]];
    }
}
void work() {
  dfs(1, 1);
  bign ans = 0;
  for (int i = 1; i <= n; i++) ans = max(ans, f[1][i]);
  cout << ans << endl;
}
int main() {
  init();
  work();
  return 0;
}

```