#include <bits/stdc++.h>
using namespace std;
struct big_int {
  vector<int> C;
  big_int(int from = 0) { C.push_back(from); }
  void print() {
    printf("%d", C.back());
    for (int i = (int)C.size() - 2; i >= 0; --i) printf("%08d", C[i]);
  }
  void read() {
    char D[100];
    scanf("%s", &D);
    C.clear();
    for (int i = (int)strlen(D); i > 0; i -= 8) {
      D[i] = 0;
      C.push_back(atoi(i >= 8 ? D + i - 8 : D));
    }
  }
  big_int operator+(big_int w) {
    big_int ret;
    ret.C.clear();
    int carry = 0;
    for (int i = 0; i < max(C.size(), w.C.size()) || carry; ++i) {
      ret.C.push_back(carry + ((i < C.size()) ? C[i] : 0) +
                      ((i < w.C.size()) ? w.C[i] : 0));
      carry = (ret.C.back() >= 100000000);
      if (carry) ret.C.back() -= 100000000;
    }
    return ret;
  }
  big_int operator-(big_int w) {
    big_int ret;
    ret.C.clear();
    int carry = 0;
    for (int i = 0; i < w.C.size() || carry; ++i) {
      ret.C.push_back(C[i] - ((i < w.C.size()) ? w.C[i] : 0) - carry);
      carry = (ret.C.back() < 0);
      if (carry) ret.C.back() += 100000000;
    }
    while (ret.C.size() > 1 && ret.C.back() == 0) ret.C.pop_back();
    return ret;
  }
  big_int operator*(big_int w) {
    big_int ret;
    ret.C.resize(C.size() + w.C.size());
    for (int i = 0; i < C.size(); ++i)
      for (int j = 0, carry = 0; j < w.C.size() || carry; ++j) {
        long long T =
            ret.C[i + j] + carry + C[i] * 1ll * (j < w.C.size() ? w.C[j] : 0);
        ret.C[i + j] = T % 100000000;
        carry = T / 100000000;
      }
    while (ret.C.size() > 1 && ret.C.back() == 0) ret.C.pop_back();
    return ret;
  }
  bool operator<(const big_int& w) const {
    if (C.size() != w.C.size()) return (C.size() < w.C.size());
    for (int i = C.size() - 1; i >= 0; --i)
      if (C[i] != w.C[i]) return (C[i] < w.C[i]);
    return false;
  }
};
int n;
vector<int> fo[701];
big_int dp[701], pn[701];
bool compare(const int& a, const int& b) {
  return (pn[b] * dp[a] < pn[a] * dp[b]);
}
big_int dpl[701], dpr[701], pnl[701];
big_int dpr1[701], pnl1[701];
void dfs(int v, int prev = -1) {
  int i, j = -1, S;
  for (int i = 0; i < fo[v].size(); ++i)
    if (fo[v][i] != prev)
      dfs(fo[v][i], v);
    else
      j = i;
  if (j >= 0) fo[v].erase(fo[v].begin() + j);
  sort(fo[v].begin(), fo[v].end(), compare);
  S = fo[v].size();
  if (S == 0) {
    dp[v] = 1;
    pn[v] = 1;
    return;
  }
  big_int A(0), B(0), C(0), cur, oc;
  dpl[0] = dp[fo[v][0]];
  for (i = 1; i < S; ++i) dpl[i] = dpl[i - 1] * dp[fo[v][i]];
  dpr[S - 1] = dp[fo[v][S - 1]];
  for (i = S - 2; i >= 0; --i) dpr[i] = dpr[i + 1] * dp[fo[v][i]];
  pnl[0] = pn[fo[v][0]];
  for (i = 1; i < S; ++i) pnl[i] = pnl[i - 1] * pn[fo[v][i]];
  pn[v] = dpr[0];
  A = pn[v];
  for (int P = 0; P < S; ++P) {
    cur = ((big_int)(P + 2)) * pnl[P];
    if (P + 1 < S) cur = cur * dpr[P + 1];
    if (B < cur) B = cur;
  }
  for (int P = 0; P < S; ++P) {
    int V = fo[v][P], S1 = fo[V].size();
    if (S1 == 0) continue;
    dpr1[S1 - 1] = dp[fo[V][S1 - 1]];
    for (i = S1 - 2; i >= 0; --i) dpr1[i] = dpr1[i + 1] * dp[fo[V][i]];
    pnl1[0] = pn[fo[V][0]];
    for (i = 1; i < S1; ++i) pnl1[i] = pnl1[i - 1] * pn[fo[V][i]];
    oc = 1;
    if (P > 0) oc = oc * dpl[P - 1];
    if (P + 1 < S) oc = oc * dpr[P + 1];
    for (i = 0; i < S1; ++i) {
      cur = oc * ((big_int)(i + 3)) * pnl1[i];
      if (i + 1 < S1) cur = cur * dpr1[i + 1];
      if (C < cur) C = cur;
    }
  }
  if (A < B) {
    if (B < C)
      dp[v] = C;
    else
      dp[v] = B;
  } else {
    if (A < C)
      dp[v] = C;
    else
      dp[v] = A;
  }
}
int main() {
  int i, j, k, l;
  scanf("%d", &n);
  for (i = 1; i < n; ++i) {
    scanf("%d%d", &k, &l);
    --k;
    --l;
    fo[k].push_back(l);
    fo[l].push_back(k);
  }
  dfs(0);
  dp[0].print();
  printf("\n");
  return 0;
}

### Prompt

Please provide a cpp coded solution 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;
struct big_int {
  vector<int> C;
  big_int(int from = 0) { C.push_back(from); }
  void print() {
    printf("%d", C.back());
    for (int i = (int)C.size() - 2; i >= 0; --i) printf("%08d", C[i]);
  }
  void read() {
    char D[100];
    scanf("%s", &D);
    C.clear();
    for (int i = (int)strlen(D); i > 0; i -= 8) {
      D[i] = 0;
      C.push_back(atoi(i >= 8 ? D + i - 8 : D));
    }
  }
  big_int operator+(big_int w) {
    big_int ret;
    ret.C.clear();
    int carry = 0;
    for (int i = 0; i < max(C.size(), w.C.size()) || carry; ++i) {
      ret.C.push_back(carry + ((i < C.size()) ? C[i] : 0) +
                      ((i < w.C.size()) ? w.C[i] : 0));
      carry = (ret.C.back() >= 100000000);
      if (carry) ret.C.back() -= 100000000;
    }
    return ret;
  }
  big_int operator-(big_int w) {
    big_int ret;
    ret.C.clear();
    int carry = 0;
    for (int i = 0; i < w.C.size() || carry; ++i) {
      ret.C.push_back(C[i] - ((i < w.C.size()) ? w.C[i] : 0) - carry);
      carry = (ret.C.back() < 0);
      if (carry) ret.C.back() += 100000000;
    }
    while (ret.C.size() > 1 && ret.C.back() == 0) ret.C.pop_back();
    return ret;
  }
  big_int operator*(big_int w) {
    big_int ret;
    ret.C.resize(C.size() + w.C.size());
    for (int i = 0; i < C.size(); ++i)
      for (int j = 0, carry = 0; j < w.C.size() || carry; ++j) {
        long long T =
            ret.C[i + j] + carry + C[i] * 1ll * (j < w.C.size() ? w.C[j] : 0);
        ret.C[i + j] = T % 100000000;
        carry = T / 100000000;
      }
    while (ret.C.size() > 1 && ret.C.back() == 0) ret.C.pop_back();
    return ret;
  }
  bool operator<(const big_int& w) const {
    if (C.size() != w.C.size()) return (C.size() < w.C.size());
    for (int i = C.size() - 1; i >= 0; --i)
      if (C[i] != w.C[i]) return (C[i] < w.C[i]);
    return false;
  }
};
int n;
vector<int> fo[701];
big_int dp[701], pn[701];
bool compare(const int& a, const int& b) {
  return (pn[b] * dp[a] < pn[a] * dp[b]);
}
big_int dpl[701], dpr[701], pnl[701];
big_int dpr1[701], pnl1[701];
void dfs(int v, int prev = -1) {
  int i, j = -1, S;
  for (int i = 0; i < fo[v].size(); ++i)
    if (fo[v][i] != prev)
      dfs(fo[v][i], v);
    else
      j = i;
  if (j >= 0) fo[v].erase(fo[v].begin() + j);
  sort(fo[v].begin(), fo[v].end(), compare);
  S = fo[v].size();
  if (S == 0) {
    dp[v] = 1;
    pn[v] = 1;
    return;
  }
  big_int A(0), B(0), C(0), cur, oc;
  dpl[0] = dp[fo[v][0]];
  for (i = 1; i < S; ++i) dpl[i] = dpl[i - 1] * dp[fo[v][i]];
  dpr[S - 1] = dp[fo[v][S - 1]];
  for (i = S - 2; i >= 0; --i) dpr[i] = dpr[i + 1] * dp[fo[v][i]];
  pnl[0] = pn[fo[v][0]];
  for (i = 1; i < S; ++i) pnl[i] = pnl[i - 1] * pn[fo[v][i]];
  pn[v] = dpr[0];
  A = pn[v];
  for (int P = 0; P < S; ++P) {
    cur = ((big_int)(P + 2)) * pnl[P];
    if (P + 1 < S) cur = cur * dpr[P + 1];
    if (B < cur) B = cur;
  }
  for (int P = 0; P < S; ++P) {
    int V = fo[v][P], S1 = fo[V].size();
    if (S1 == 0) continue;
    dpr1[S1 - 1] = dp[fo[V][S1 - 1]];
    for (i = S1 - 2; i >= 0; --i) dpr1[i] = dpr1[i + 1] * dp[fo[V][i]];
    pnl1[0] = pn[fo[V][0]];
    for (i = 1; i < S1; ++i) pnl1[i] = pnl1[i - 1] * pn[fo[V][i]];
    oc = 1;
    if (P > 0) oc = oc * dpl[P - 1];
    if (P + 1 < S) oc = oc * dpr[P + 1];
    for (i = 0; i < S1; ++i) {
      cur = oc * ((big_int)(i + 3)) * pnl1[i];
      if (i + 1 < S1) cur = cur * dpr1[i + 1];
      if (C < cur) C = cur;
    }
  }
  if (A < B) {
    if (B < C)
      dp[v] = C;
    else
      dp[v] = B;
  } else {
    if (A < C)
      dp[v] = C;
    else
      dp[v] = A;
  }
}
int main() {
  int i, j, k, l;
  scanf("%d", &n);
  for (i = 1; i < n; ++i) {
    scanf("%d%d", &k, &l);
    --k;
    --l;
    fo[k].push_back(l);
    fo[l].push_back(k);
  }
  dfs(0);
  dp[0].print();
  printf("\n");
  return 0;
}

```