#include <bits/stdc++.h>
using namespace std;
int a, b, c, d, e, f, g, h, i, j, k;
int father[705];
int D[705];
vector<int> GG[705];
struct BigInt {
  int x[105];
  int len;
  void give(int xx) {
    memset(x, 0, sizeof(x));
    len = 1;
    x[1] = xx;
  }
  friend bool operator<(const BigInt &x, const BigInt &y) {
    int ii;
    int L = max(x.len, y.len);
    for (ii = L; ii >= 1; ii--)
      if (x.x[ii] < y.x[ii])
        return true;
      else if (x.x[ii] > y.x[ii])
        return false;
    return false;
  }
  friend BigInt operator+(const BigInt &x, const BigInt &y) {
    int ii, jj, kk;
    int jw = 0;
    int L = max(x.len, y.len);
    BigInt R;
    R.give(0);
    for (ii = 1; ii <= L + 1; ii++) {
      kk = x.x[ii] + y.x[ii] + jw;
      R.x[ii] = kk % 10000;
      jw = kk / 10000;
    }
    if (R.x[L + 1] == 0)
      R.len = L;
    else
      R.len = L + 1;
    return R;
  }
  friend BigInt operator*(const BigInt &x, const BigInt &y) {
    int ii, jj, kk;
    BigInt R;
    R.give(0);
    for (ii = 1; ii <= x.len; ii++)
      for (jj = 1; jj <= y.len; jj++) R.x[ii + jj - 1] += x.x[ii] * y.x[jj];
    for (ii = 1; ii <= x.len + y.len; ii++) {
      R.x[ii + 1] += R.x[ii] / 10000;
      R.x[ii] %= 10000;
    }
    R.len = x.len + y.len;
    while (R.len > 1 && R.x[R.len] == 0) R.len--;
    return R;
  }
};
BigInt F[705][705];
void soso(int x) {
  int ii, jj, kk;
  int cc, dd;
  BigInt tmp;
  BigInt ch;
  ch.give(0);
  D[x] = 1;
  F[x][0].give(0);
  F[x][1].give(1);
  for (ii = 0; ii < GG[x].size(); ii++) {
    jj = GG[x][ii];
    if (jj == father[x]) continue;
    father[jj] = x;
    soso(jj);
    for (cc = D[x]; cc > 0; cc--)
      for (dd = D[jj]; dd >= 0; dd--) {
        tmp = F[x][cc] * F[jj][dd];
        if (F[x][cc + dd] < tmp) F[x][cc + dd] = tmp;
      }
    D[x] += D[jj];
  }
  for (ii = 1; ii <= D[x]; ii++) {
    ch.x[1] = ii;
    tmp = ch * F[x][ii];
    if (F[x][0] < tmp) F[x][0] = tmp;
  }
}
void Print(BigInt x) {
  int ii, jj, kk;
  kk = 100;
  while (kk > 1 && x.x[kk] == 0) kk--;
  cout << x.x[kk];
  for (ii = kk - 1; ii >= 1; ii--) printf("%04d", x.x[ii]);
  cout << endl;
}
int main() {
  cin >> a;
  for (i = 1; i < a; i++) {
    scanf("%d%d", &c, &d);
    GG[c].push_back(d);
    GG[d].push_back(c);
  }
  soso(1);
  Print(F[1][0]);
  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 a, b, c, d, e, f, g, h, i, j, k;
int father[705];
int D[705];
vector<int> GG[705];
struct BigInt {
  int x[105];
  int len;
  void give(int xx) {
    memset(x, 0, sizeof(x));
    len = 1;
    x[1] = xx;
  }
  friend bool operator<(const BigInt &x, const BigInt &y) {
    int ii;
    int L = max(x.len, y.len);
    for (ii = L; ii >= 1; ii--)
      if (x.x[ii] < y.x[ii])
        return true;
      else if (x.x[ii] > y.x[ii])
        return false;
    return false;
  }
  friend BigInt operator+(const BigInt &x, const BigInt &y) {
    int ii, jj, kk;
    int jw = 0;
    int L = max(x.len, y.len);
    BigInt R;
    R.give(0);
    for (ii = 1; ii <= L + 1; ii++) {
      kk = x.x[ii] + y.x[ii] + jw;
      R.x[ii] = kk % 10000;
      jw = kk / 10000;
    }
    if (R.x[L + 1] == 0)
      R.len = L;
    else
      R.len = L + 1;
    return R;
  }
  friend BigInt operator*(const BigInt &x, const BigInt &y) {
    int ii, jj, kk;
    BigInt R;
    R.give(0);
    for (ii = 1; ii <= x.len; ii++)
      for (jj = 1; jj <= y.len; jj++) R.x[ii + jj - 1] += x.x[ii] * y.x[jj];
    for (ii = 1; ii <= x.len + y.len; ii++) {
      R.x[ii + 1] += R.x[ii] / 10000;
      R.x[ii] %= 10000;
    }
    R.len = x.len + y.len;
    while (R.len > 1 && R.x[R.len] == 0) R.len--;
    return R;
  }
};
BigInt F[705][705];
void soso(int x) {
  int ii, jj, kk;
  int cc, dd;
  BigInt tmp;
  BigInt ch;
  ch.give(0);
  D[x] = 1;
  F[x][0].give(0);
  F[x][1].give(1);
  for (ii = 0; ii < GG[x].size(); ii++) {
    jj = GG[x][ii];
    if (jj == father[x]) continue;
    father[jj] = x;
    soso(jj);
    for (cc = D[x]; cc > 0; cc--)
      for (dd = D[jj]; dd >= 0; dd--) {
        tmp = F[x][cc] * F[jj][dd];
        if (F[x][cc + dd] < tmp) F[x][cc + dd] = tmp;
      }
    D[x] += D[jj];
  }
  for (ii = 1; ii <= D[x]; ii++) {
    ch.x[1] = ii;
    tmp = ch * F[x][ii];
    if (F[x][0] < tmp) F[x][0] = tmp;
  }
}
void Print(BigInt x) {
  int ii, jj, kk;
  kk = 100;
  while (kk > 1 && x.x[kk] == 0) kk--;
  cout << x.x[kk];
  for (ii = kk - 1; ii >= 1; ii--) printf("%04d", x.x[ii]);
  cout << endl;
}
int main() {
  cin >> a;
  for (i = 1; i < a; i++) {
    scanf("%d%d", &c, &d);
    GG[c].push_back(d);
    GG[d].push_back(c);
  }
  soso(1);
  Print(F[1][0]);
  return 0;
}

```