#include <bits/stdc++.h>
using namespace std;
const int MAXN = 705;
struct BIGNUM {
  int l;
  int a[1000];
  BIGNUM() {
    l = 0;
    memset(a, 0, sizeof(a));
  }
};
struct Edge {
  int num, next;
} e[MAXN * 2];
int en = 0, start[MAXN];
inline void Add_edge(int p, int q) {
  en++;
  e[en].num = q;
  e[en].next = start[p];
  start[p] = en;
  en++;
  e[en].num = p;
  e[en].next = start[q];
  start[q] = en;
}
int ch[MAXN][MAXN], chn[MAXN];
bool u[MAXN];
int n;
BIGNUM f[MAXN], g[MAXN];
void dfs(int p) {
  u[p] = true;
  for (int i = start[p]; i != 0; i = e[i].next)
    if (!u[e[i].num]) {
      ch[p][++chn[p]] = e[i].num;
      dfs(e[i].num);
    }
}
BIGNUM operator*(BIGNUM a, BIGNUM b) {
  BIGNUM s;
  s.l = a.l + b.l;
  for (int i = 1; i <= a.l; i++)
    for (int j = 1; j <= b.l; j++) s.a[i + j - 1] += a.a[i] * b.a[j];
  for (int i = 1; i <= s.l; i++) {
    s.a[i + 1] += s.a[i] / 10;
    s.a[i] %= 10;
  }
  while (s.l != 0 && s.a[s.l] == 0) s.l--;
  return s;
}
BIGNUM operator*(BIGNUM a, int b) {
  for (int i = 1; i <= a.l; i++) a.a[i] *= b;
  for (int i = 1; i <= a.l; i++) {
    a.a[i + 1] += a.a[i] / 10;
    a.a[i] %= 10;
    if (i == a.l && a.a[i + 1] != 0) a.l++;
  }
  while (a.l != 0 && a.a[a.l] == 0) a.l--;
  return a;
}
bool operator<(BIGNUM a, BIGNUM b) {
  if (a.l != b.l) return a.l < b.l;
  for (int i = a.l; i >= 1; i--)
    if (a.a[i] < b.a[i])
      return true;
    else if (a.a[i] > b.a[i])
      return false;
  return false;
}
BIGNUM operator-(BIGNUM a, BIGNUM b) {
  for (int i = 1; i <= a.l; i++) {
    a.a[i] -= b.a[i];
    if (a.a[i] < 0) a.a[i + 1]--, a.a[i] += 10;
  }
  while (a.l != 0 && a.a[a.l] == 0) a.l--;
  return a;
}
BIGNUM operator/(BIGNUM a, BIGNUM b) {
  BIGNUM r;
  BIGNUM s;
  for (int i = a.l; i >= 1; i--) {
    r = r * 10;
    if (r.l == 0) r.l = 1;
    r.a[1] = a.a[i];
    for (int j = 9; j >= 1; j--) {
      if (!(r < b * j)) {
        r = r - b * j;
        if (s.l == 0) s.l = i;
        s.a[i] = j;
        break;
      }
    }
  }
  return s;
}
BIGNUM operator/(BIGNUM a, int b) {
  for (int i = a.l; i >= 1; i--) {
    a.a[i - 1] += a.a[i] % b * 10;
    a.a[i] = a.a[i] / b;
    if (i == a.l && a.a[i] == 0) a.l--;
  }
  return a;
}
inline bool cmp(const int &a, const int &b) {
  return f[a] * g[b] < f[b] * g[a];
}
void work(int p) {
  for (int i = 1; i <= chn[p]; i++) work(ch[p][i]);
  sort(ch[p] + 1, ch[p] + chn[p] + 1, cmp);
  g[p].l = 1;
  g[p].a[1] = 1;
  for (int i = 1; i <= chn[p]; i++) g[p] = g[p] * f[ch[p][i]];
  BIGNUM last = g[p];
  f[p] = g[p];
  for (int i = 1; i <= chn[p]; i++) {
    last = last / i * (i + 1);
    last = last / f[ch[p][i]] * g[ch[p][i]];
    if (f[p] < last) f[p] = last;
  }
  for (int i = 1; i <= chn[p]; i++) {
    last = g[p];
    last = last / f[ch[p][i]] * g[ch[p][i]];
    last = last * 2;
    int k = ch[p][i];
    for (int j = 1; j <= chn[k]; j++) {
      last = last / (j + 1) * (j + 2);
      last = last / f[ch[k][j]] * g[ch[k][j]];
      if (f[p] < last) f[p] = last;
    }
  }
}
void print_ans(BIGNUM x) {
  for (int i = x.l; i >= 1; i--) printf("%d", x.a[i]);
  printf("\n");
}
int main() {
  BIGNUM a;
  a.l = 2;
  a.a[1] = 2;
  a.a[2] = 4;
  BIGNUM b;
  b.l = 2;
  b.a[1] = 2;
  b.a[2] = 4;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int p, q;
    scanf("%d%d", &p, &q);
    Add_edge(p, q);
  }
  dfs(1);
  work(1);
  print_ans(f[1]);
  return 0;
}

### Prompt

Please formulate a CPP solution 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 MAXN = 705;
struct BIGNUM {
  int l;
  int a[1000];
  BIGNUM() {
    l = 0;
    memset(a, 0, sizeof(a));
  }
};
struct Edge {
  int num, next;
} e[MAXN * 2];
int en = 0, start[MAXN];
inline void Add_edge(int p, int q) {
  en++;
  e[en].num = q;
  e[en].next = start[p];
  start[p] = en;
  en++;
  e[en].num = p;
  e[en].next = start[q];
  start[q] = en;
}
int ch[MAXN][MAXN], chn[MAXN];
bool u[MAXN];
int n;
BIGNUM f[MAXN], g[MAXN];
void dfs(int p) {
  u[p] = true;
  for (int i = start[p]; i != 0; i = e[i].next)
    if (!u[e[i].num]) {
      ch[p][++chn[p]] = e[i].num;
      dfs(e[i].num);
    }
}
BIGNUM operator*(BIGNUM a, BIGNUM b) {
  BIGNUM s;
  s.l = a.l + b.l;
  for (int i = 1; i <= a.l; i++)
    for (int j = 1; j <= b.l; j++) s.a[i + j - 1] += a.a[i] * b.a[j];
  for (int i = 1; i <= s.l; i++) {
    s.a[i + 1] += s.a[i] / 10;
    s.a[i] %= 10;
  }
  while (s.l != 0 && s.a[s.l] == 0) s.l--;
  return s;
}
BIGNUM operator*(BIGNUM a, int b) {
  for (int i = 1; i <= a.l; i++) a.a[i] *= b;
  for (int i = 1; i <= a.l; i++) {
    a.a[i + 1] += a.a[i] / 10;
    a.a[i] %= 10;
    if (i == a.l && a.a[i + 1] != 0) a.l++;
  }
  while (a.l != 0 && a.a[a.l] == 0) a.l--;
  return a;
}
bool operator<(BIGNUM a, BIGNUM b) {
  if (a.l != b.l) return a.l < b.l;
  for (int i = a.l; i >= 1; i--)
    if (a.a[i] < b.a[i])
      return true;
    else if (a.a[i] > b.a[i])
      return false;
  return false;
}
BIGNUM operator-(BIGNUM a, BIGNUM b) {
  for (int i = 1; i <= a.l; i++) {
    a.a[i] -= b.a[i];
    if (a.a[i] < 0) a.a[i + 1]--, a.a[i] += 10;
  }
  while (a.l != 0 && a.a[a.l] == 0) a.l--;
  return a;
}
BIGNUM operator/(BIGNUM a, BIGNUM b) {
  BIGNUM r;
  BIGNUM s;
  for (int i = a.l; i >= 1; i--) {
    r = r * 10;
    if (r.l == 0) r.l = 1;
    r.a[1] = a.a[i];
    for (int j = 9; j >= 1; j--) {
      if (!(r < b * j)) {
        r = r - b * j;
        if (s.l == 0) s.l = i;
        s.a[i] = j;
        break;
      }
    }
  }
  return s;
}
BIGNUM operator/(BIGNUM a, int b) {
  for (int i = a.l; i >= 1; i--) {
    a.a[i - 1] += a.a[i] % b * 10;
    a.a[i] = a.a[i] / b;
    if (i == a.l && a.a[i] == 0) a.l--;
  }
  return a;
}
inline bool cmp(const int &a, const int &b) {
  return f[a] * g[b] < f[b] * g[a];
}
void work(int p) {
  for (int i = 1; i <= chn[p]; i++) work(ch[p][i]);
  sort(ch[p] + 1, ch[p] + chn[p] + 1, cmp);
  g[p].l = 1;
  g[p].a[1] = 1;
  for (int i = 1; i <= chn[p]; i++) g[p] = g[p] * f[ch[p][i]];
  BIGNUM last = g[p];
  f[p] = g[p];
  for (int i = 1; i <= chn[p]; i++) {
    last = last / i * (i + 1);
    last = last / f[ch[p][i]] * g[ch[p][i]];
    if (f[p] < last) f[p] = last;
  }
  for (int i = 1; i <= chn[p]; i++) {
    last = g[p];
    last = last / f[ch[p][i]] * g[ch[p][i]];
    last = last * 2;
    int k = ch[p][i];
    for (int j = 1; j <= chn[k]; j++) {
      last = last / (j + 1) * (j + 2);
      last = last / f[ch[k][j]] * g[ch[k][j]];
      if (f[p] < last) f[p] = last;
    }
  }
}
void print_ans(BIGNUM x) {
  for (int i = x.l; i >= 1; i--) printf("%d", x.a[i]);
  printf("\n");
}
int main() {
  BIGNUM a;
  a.l = 2;
  a.a[1] = 2;
  a.a[2] = 4;
  BIGNUM b;
  b.l = 2;
  b.a[1] = 2;
  b.a[2] = 4;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int p, q;
    scanf("%d%d", &p, &q);
    Add_edge(p, q);
  }
  dfs(1);
  work(1);
  print_ans(f[1]);
  return 0;
}

```