#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pli = pair<ll, int>;
using pii = pair<int, int>;
constexpr ll mod = 1e9 + 7;
struct bign {
  int d[120], len;
  bign() {
    memset(d, 0, sizeof d);
    len = 1;
  }
  bign(int num) { *this = num; }
  bign(char* num) { *this = num; }
  bign operator=(const char* num) {
    len = strlen(num);
    for (int i = 0; i < len; i++) d[i] = num[len - i - 1] - '0';
    return *this;
  }
  bign operator=(int num) {
    char c[1010];
    sprintf(c, "%d", num);
    *this = c;
    return *this;
  }
  void clear() {
    while (len > 1 && !d[len - 1]) len--;
  }
  bign operator+(const bign& b) {
    bign c;
    c.len = 0;
    for (int i = 0, t = 0; t || i < len || i < b.len; i++) {
      if (i < len) t += d[i];
      if (i < b.len) t += b.d[i];
      c.d[c.len++] = t % 10;
      t /= 10;
    }
    return c;
  }
  bign operator-(const bign& b) {
    bign c;
    c.len = 0;
    for (int i = 0, t = 0; i < len; i++) {
      t += d[i];
      if (i < b.len) t -= b.d[i];
      c.d[c.len++] = (t + 10) % 10;
      if (t >= 0)
        t = 0;
      else
        t = -1;
    }
    c.clear();
    return c;
  }
  bign operator*(const bign& b) {
    bign c;
    c.len = len + b.len;
    for (int i = 0; i < len; i++)
      for (int j = 0; j < b.len; j++) c.d[i + j] += d[i] * b.d[j];
    for (int i = 0; i < c.len - 1; i++) c.d[i + 1] += c.d[i] / 10, c.d[i] %= 10;
    c.clear();
    return c;
  }
  bool operator<(const bign& b) {
    if (len != b.len) return len < b.len;
    for (int i = len - 1; i >= 0; i--)
      if (d[i] != b.d[i]) return d[i] < b.d[i];
    return false;
  }
  bool operator<=(const bign& b) {
    if (len != b.len) return len < b.len;
    for (int i = len - 1; i >= 0; i--)
      if (d[i] != b.d[i]) return d[i] < b.d[i];
    return true;
  }
  bool operator>(const bign& b) {
    if (len != b.len) return len > b.len;
    for (int i = len - 1; i >= 0; i--)
      if (d[i] != b.d[i]) return d[i] > b.d[i];
    return false;
  }
  bool operator>=(const bign& b) {
    if (len != b.len) return len > b.len;
    for (int i = len - 1; i >= 0; i--)
      if (d[i] != b.d[i]) return d[i] > b.d[i];
    return true;
  }
  bign operator+=(const bign& b) {
    *this = *this + b;
    return *this;
  }
  bign operator-=(const bign& b) {
    *this = *this - b;
    return *this;
  }
  bign operator*=(const bign& b) {
    *this = *this * b;
    return *this;
  }
  void print() {
    for (int i = len - 1; i >= 0; i--) std::cout << d[i];
    cout << '\n';
  }
  string str() {
    string res = "";
    for (int i = 0; i < len; i++) res = (char)(d[i] + '0') + res;
    return res;
  }
};
istream& operator>>(istream& in, bign& x) {
  string s;
  in >> s;
  x = s.c_str();
  return in;
}
ostream& operator<<(ostream& out, bign& x) {
  out << x.str();
  return out;
};
bign max(bign a, bign b) { return a > b ? a : b; }
constexpr int N = 710;
int h[N], e[2 * N], ne[2 * N], idx;
void add(int a, int b) { e[idx] = b, ne[idx] = h[a], h[a] = idx++; }
int sz[N], n;
bign f[N][N], ans;
void dfs(int u, int fa) {
  f[u][1] = 1;
  sz[u] = 1;
  for (int i = h[u]; i != -1; i = ne[i]) {
    int v = e[i];
    if (v == fa) continue;
    dfs(v, u);
    bign now = 1;
    for (int j = 1; j <= sz[v]; j++) now = max(now, f[v][j] * bign(j));
    for (int j = sz[u]; j >= 1; j--) {
      for (int k = sz[v]; k >= 1; k--)
        f[u][j + k] = max(f[u][j + k], f[u][j] * f[v][k]);
      f[u][j] = f[u][j] * now;
    }
    sz[u] += sz[v];
  }
  for (int j = 1; j <= sz[u]; j++) ans = max(ans, f[u][j] * bign(j));
}
int main() {
  int T = 1;
  while (T--) {
    cin >> n;
    memset(h, -1, sizeof h);
    for (int i = 1; i < n; i++) {
      int u, v;
      cin >> u >> v;
      add(u, v), add(v, u);
    }
    dfs(1, 0);
    ans.print();
  }
  return 0;
}

### Prompt

In CPP, your task is to solve 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>
#pragma GCC optimize(2)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pli = pair<ll, int>;
using pii = pair<int, int>;
constexpr ll mod = 1e9 + 7;
struct bign {
  int d[120], len;
  bign() {
    memset(d, 0, sizeof d);
    len = 1;
  }
  bign(int num) { *this = num; }
  bign(char* num) { *this = num; }
  bign operator=(const char* num) {
    len = strlen(num);
    for (int i = 0; i < len; i++) d[i] = num[len - i - 1] - '0';
    return *this;
  }
  bign operator=(int num) {
    char c[1010];
    sprintf(c, "%d", num);
    *this = c;
    return *this;
  }
  void clear() {
    while (len > 1 && !d[len - 1]) len--;
  }
  bign operator+(const bign& b) {
    bign c;
    c.len = 0;
    for (int i = 0, t = 0; t || i < len || i < b.len; i++) {
      if (i < len) t += d[i];
      if (i < b.len) t += b.d[i];
      c.d[c.len++] = t % 10;
      t /= 10;
    }
    return c;
  }
  bign operator-(const bign& b) {
    bign c;
    c.len = 0;
    for (int i = 0, t = 0; i < len; i++) {
      t += d[i];
      if (i < b.len) t -= b.d[i];
      c.d[c.len++] = (t + 10) % 10;
      if (t >= 0)
        t = 0;
      else
        t = -1;
    }
    c.clear();
    return c;
  }
  bign operator*(const bign& b) {
    bign c;
    c.len = len + b.len;
    for (int i = 0; i < len; i++)
      for (int j = 0; j < b.len; j++) c.d[i + j] += d[i] * b.d[j];
    for (int i = 0; i < c.len - 1; i++) c.d[i + 1] += c.d[i] / 10, c.d[i] %= 10;
    c.clear();
    return c;
  }
  bool operator<(const bign& b) {
    if (len != b.len) return len < b.len;
    for (int i = len - 1; i >= 0; i--)
      if (d[i] != b.d[i]) return d[i] < b.d[i];
    return false;
  }
  bool operator<=(const bign& b) {
    if (len != b.len) return len < b.len;
    for (int i = len - 1; i >= 0; i--)
      if (d[i] != b.d[i]) return d[i] < b.d[i];
    return true;
  }
  bool operator>(const bign& b) {
    if (len != b.len) return len > b.len;
    for (int i = len - 1; i >= 0; i--)
      if (d[i] != b.d[i]) return d[i] > b.d[i];
    return false;
  }
  bool operator>=(const bign& b) {
    if (len != b.len) return len > b.len;
    for (int i = len - 1; i >= 0; i--)
      if (d[i] != b.d[i]) return d[i] > b.d[i];
    return true;
  }
  bign operator+=(const bign& b) {
    *this = *this + b;
    return *this;
  }
  bign operator-=(const bign& b) {
    *this = *this - b;
    return *this;
  }
  bign operator*=(const bign& b) {
    *this = *this * b;
    return *this;
  }
  void print() {
    for (int i = len - 1; i >= 0; i--) std::cout << d[i];
    cout << '\n';
  }
  string str() {
    string res = "";
    for (int i = 0; i < len; i++) res = (char)(d[i] + '0') + res;
    return res;
  }
};
istream& operator>>(istream& in, bign& x) {
  string s;
  in >> s;
  x = s.c_str();
  return in;
}
ostream& operator<<(ostream& out, bign& x) {
  out << x.str();
  return out;
};
bign max(bign a, bign b) { return a > b ? a : b; }
constexpr int N = 710;
int h[N], e[2 * N], ne[2 * N], idx;
void add(int a, int b) { e[idx] = b, ne[idx] = h[a], h[a] = idx++; }
int sz[N], n;
bign f[N][N], ans;
void dfs(int u, int fa) {
  f[u][1] = 1;
  sz[u] = 1;
  for (int i = h[u]; i != -1; i = ne[i]) {
    int v = e[i];
    if (v == fa) continue;
    dfs(v, u);
    bign now = 1;
    for (int j = 1; j <= sz[v]; j++) now = max(now, f[v][j] * bign(j));
    for (int j = sz[u]; j >= 1; j--) {
      for (int k = sz[v]; k >= 1; k--)
        f[u][j + k] = max(f[u][j + k], f[u][j] * f[v][k]);
      f[u][j] = f[u][j] * now;
    }
    sz[u] += sz[v];
  }
  for (int j = 1; j <= sz[u]; j++) ans = max(ans, f[u][j] * bign(j));
}
int main() {
  int T = 1;
  while (T--) {
    cin >> n;
    memset(h, -1, sizeof h);
    for (int i = 1; i < n; i++) {
      int u, v;
      cin >> u >> v;
      add(u, v), add(v, u);
    }
    dfs(1, 0);
    ans.print();
  }
  return 0;
}

```