#include <bits/stdc++.h>
using namespace std;
const int nmax = 710;
const int cnt_primes = 127;
const int base = 1e4;
vector<int> primes;
vector<vector<int> > factorization(nmax, vector<int>(cnt_primes));
bool operator<(const vector<int>& a, const vector<int>& b) {
  if ((int)(a).size() != (int)(b).size()) {
    return (int)(a).size() < (int)(b).size();
  }
  for (int i = (int)(a).size() - 1; i >= 0; --i) {
    if (a[i] != b[i]) {
      return a[i] < b[i];
    }
  }
  return false;
}
vector<int> operator*(const vector<int>& a, int b) {
  int n = (int)(a).size();
  if ((n == 1 && a[0] == 0) || b == 0) {
    return {0};
  }
  vector<int> ans;
  int c = 0;
  for (int i = 0; i < n; ++i) {
    c += a[i] * b;
    ans.push_back(c % base);
    c /= base;
  }
  if (c) {
    ans.push_back(c);
  }
  return ans;
}
struct number {
  vector<int> v;
  number() {}
  number(const vector<int>& v) : v(v) {}
  number operator*(const number& other) const {
    vector<int> ans(cnt_primes);
    for (int i = 0; i < cnt_primes; ++i) {
      ans[i] = v[i] + other.v[i];
    }
    return number(ans);
  }
  number operator/(const number& other) const {
    vector<int> ans(cnt_primes);
    for (int i = 0; i < cnt_primes; ++i) {
      ans[i] = v[i] - other.v[i];
    }
    return number(ans);
  }
  number& operator*=(const number& other) {
    for (int i = 0; i < cnt_primes; ++i) {
      v[i] += other.v[i];
    }
    return *this;
  }
  number& operator/=(const number& other) {
    for (int i = 0; i < cnt_primes; ++i) {
      v[i] -= other.v[i];
    }
    return *this;
  }
};
vector<int> convert(const number& d) {
  vector<int> ans = {1};
  for (int i = 0; i < cnt_primes; ++i) {
    for (int j = 0; j < d.v[i]; ++j) {
      ans = ans * primes[i];
    }
  }
  return ans;
}
vector<vector<number> > dp;
vector<vector<int> > g;
bool comp(int u, int v) {
  number x = dp[u][1] * dp[v][0];
  number y = dp[v][1] * dp[u][0];
  vector<int> a = convert(x);
  vector<int> b = convert(y);
  return b < a;
}
void out(const number& d) {
  vector<int> ans = convert(d);
  for (int i = (int)(ans).size() - 1; i >= 0; --i) {
    if (i != (int)(ans).size() - 1) {
      printf("%04d", ans[i]);
    } else {
      printf("%d", ans[i]);
    }
  }
  printf("\n");
}
void dfs(int v, int p) {
  if ((int)(g[v]).size() == 1 && g[v][0] == p) {
    dp[v][0].v = factorization[1];
    dp[v][1].v = factorization[1];
    return;
  }
  vector<int> sons;
  for (int to : g[v]) {
    if (to == p) {
      continue;
    }
    dfs(to, v);
    sons.push_back(to);
  }
  sort((sons).begin(), (sons).end(), comp);
  dp[v][1].v = factorization[1];
  for (int son : sons) {
    dp[v][1] *= dp[son][0];
  }
  dp[v][0].v = dp[v][1].v;
  int s = (int)(sons).size();
  number p_sons = dp[v][1];
  vector<int> curr = convert(dp[v][0]);
  for (int k = 0; k < s; ++k) {
    p_sons *= dp[sons[k]][1];
    p_sons /= dp[sons[k]][0];
    number upd = factorization[k + 2];
    upd *= p_sons;
    vector<int> relax = convert(upd);
    if (curr < relax) {
      dp[v][0] = upd;
      curr = relax;
    }
  }
  for (int son : sons) {
    p_sons = dp[son][1];
    p_sons *= dp[v][1];
    p_sons /= dp[son][0];
    vector<int> grandsons;
    for (int to : g[son]) {
      if (to != v) {
        grandsons.push_back(to);
      }
    }
    sort((grandsons).begin(), (grandsons).end(), comp);
    for (int k = 0; k < (int)(grandsons).size(); ++k) {
      p_sons *= dp[grandsons[k]][1];
      p_sons /= dp[grandsons[k]][0];
      number upd = factorization[k + 3];
      upd *= p_sons;
      vector<int> relax = convert(upd);
      if (curr < relax) {
        dp[v][0] = upd;
        curr = relax;
      }
    }
  }
}
int main() {
  vector<char> pp(nmax, true);
  for (int i = 2; i < nmax; ++i) {
    if (pp[i]) {
      primes.push_back(i);
      for (int j = 2 * i; j < nmax; j += i) {
        pp[j] = false;
      }
    }
  }
  for (int i = 2; i < nmax; ++i) {
    int x = i;
    for (int j = 0; j < cnt_primes; ++j) {
      while (x % primes[j] == 0) {
        ++factorization[i][j];
        x /= primes[j];
      }
    }
  }
  int n;
  scanf("%d", &n);
  g.resize(n);
  dp.resize(n);
  for (int i = 0; i < n; ++i) {
    dp[i].resize(2);
  }
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    --u, --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(0, 0);
  out(dp[0][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;
const int nmax = 710;
const int cnt_primes = 127;
const int base = 1e4;
vector<int> primes;
vector<vector<int> > factorization(nmax, vector<int>(cnt_primes));
bool operator<(const vector<int>& a, const vector<int>& b) {
  if ((int)(a).size() != (int)(b).size()) {
    return (int)(a).size() < (int)(b).size();
  }
  for (int i = (int)(a).size() - 1; i >= 0; --i) {
    if (a[i] != b[i]) {
      return a[i] < b[i];
    }
  }
  return false;
}
vector<int> operator*(const vector<int>& a, int b) {
  int n = (int)(a).size();
  if ((n == 1 && a[0] == 0) || b == 0) {
    return {0};
  }
  vector<int> ans;
  int c = 0;
  for (int i = 0; i < n; ++i) {
    c += a[i] * b;
    ans.push_back(c % base);
    c /= base;
  }
  if (c) {
    ans.push_back(c);
  }
  return ans;
}
struct number {
  vector<int> v;
  number() {}
  number(const vector<int>& v) : v(v) {}
  number operator*(const number& other) const {
    vector<int> ans(cnt_primes);
    for (int i = 0; i < cnt_primes; ++i) {
      ans[i] = v[i] + other.v[i];
    }
    return number(ans);
  }
  number operator/(const number& other) const {
    vector<int> ans(cnt_primes);
    for (int i = 0; i < cnt_primes; ++i) {
      ans[i] = v[i] - other.v[i];
    }
    return number(ans);
  }
  number& operator*=(const number& other) {
    for (int i = 0; i < cnt_primes; ++i) {
      v[i] += other.v[i];
    }
    return *this;
  }
  number& operator/=(const number& other) {
    for (int i = 0; i < cnt_primes; ++i) {
      v[i] -= other.v[i];
    }
    return *this;
  }
};
vector<int> convert(const number& d) {
  vector<int> ans = {1};
  for (int i = 0; i < cnt_primes; ++i) {
    for (int j = 0; j < d.v[i]; ++j) {
      ans = ans * primes[i];
    }
  }
  return ans;
}
vector<vector<number> > dp;
vector<vector<int> > g;
bool comp(int u, int v) {
  number x = dp[u][1] * dp[v][0];
  number y = dp[v][1] * dp[u][0];
  vector<int> a = convert(x);
  vector<int> b = convert(y);
  return b < a;
}
void out(const number& d) {
  vector<int> ans = convert(d);
  for (int i = (int)(ans).size() - 1; i >= 0; --i) {
    if (i != (int)(ans).size() - 1) {
      printf("%04d", ans[i]);
    } else {
      printf("%d", ans[i]);
    }
  }
  printf("\n");
}
void dfs(int v, int p) {
  if ((int)(g[v]).size() == 1 && g[v][0] == p) {
    dp[v][0].v = factorization[1];
    dp[v][1].v = factorization[1];
    return;
  }
  vector<int> sons;
  for (int to : g[v]) {
    if (to == p) {
      continue;
    }
    dfs(to, v);
    sons.push_back(to);
  }
  sort((sons).begin(), (sons).end(), comp);
  dp[v][1].v = factorization[1];
  for (int son : sons) {
    dp[v][1] *= dp[son][0];
  }
  dp[v][0].v = dp[v][1].v;
  int s = (int)(sons).size();
  number p_sons = dp[v][1];
  vector<int> curr = convert(dp[v][0]);
  for (int k = 0; k < s; ++k) {
    p_sons *= dp[sons[k]][1];
    p_sons /= dp[sons[k]][0];
    number upd = factorization[k + 2];
    upd *= p_sons;
    vector<int> relax = convert(upd);
    if (curr < relax) {
      dp[v][0] = upd;
      curr = relax;
    }
  }
  for (int son : sons) {
    p_sons = dp[son][1];
    p_sons *= dp[v][1];
    p_sons /= dp[son][0];
    vector<int> grandsons;
    for (int to : g[son]) {
      if (to != v) {
        grandsons.push_back(to);
      }
    }
    sort((grandsons).begin(), (grandsons).end(), comp);
    for (int k = 0; k < (int)(grandsons).size(); ++k) {
      p_sons *= dp[grandsons[k]][1];
      p_sons /= dp[grandsons[k]][0];
      number upd = factorization[k + 3];
      upd *= p_sons;
      vector<int> relax = convert(upd);
      if (curr < relax) {
        dp[v][0] = upd;
        curr = relax;
      }
    }
  }
}
int main() {
  vector<char> pp(nmax, true);
  for (int i = 2; i < nmax; ++i) {
    if (pp[i]) {
      primes.push_back(i);
      for (int j = 2 * i; j < nmax; j += i) {
        pp[j] = false;
      }
    }
  }
  for (int i = 2; i < nmax; ++i) {
    int x = i;
    for (int j = 0; j < cnt_primes; ++j) {
      while (x % primes[j] == 0) {
        ++factorization[i][j];
        x /= primes[j];
      }
    }
  }
  int n;
  scanf("%d", &n);
  g.resize(n);
  dp.resize(n);
  for (int i = 0; i < n; ++i) {
    dp[i].resize(2);
  }
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    --u, --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(0, 0);
  out(dp[0][0]);
}

```