#include <bits/stdc++.h>
using namespace std;
struct road {
  long long x, next;
} r[705 * 2];
struct big {
  long long a[16], len;
  void print() {
    printf("%I64d", a[len]);
    for (long long i = len - 1; i >= 1; i--) {
      if (a[i] / 10000000 == 0) printf("0");
      if (a[i] / 1000000 == 0) printf("0");
      if (a[i] / 100000 == 0) printf("0");
      if (a[i] / 10000 == 0) printf("0");
      if (a[i] / 1000 == 0) printf("0");
      if (a[i] / 100 == 0) printf("0");
      if (a[i] / 10 == 0) printf("0");
      printf("%I64d", a[i]);
    }
    printf("\n");
  }
  bool operator<(big b) const {
    if (len != b.len) return len < b.len;
    for (long long i = len; i >= 1; i--)
      if (a[i] != b.a[i]) return a[i] < b.a[i];
    return 0;
  }
  big operator*(big b) const {
    big c = {0, 0};
    if (!b.len || !len) return c;
    long long x = 0;
    c.len = len + b.len - 1;
    for (long long i = 1; i <= len; i++)
      for (long long j = 1; j <= b.len; j++) {
        c.a[i + j - 1] = c.a[i + j - 1] + a[i] * b.a[j];
      }
    for (long long i = 1; i <= len + b.len; i++)
      c.a[i] += x, x = c.a[i] / 100000000, c.a[i] %= 100000000;
    if (c.a[len + b.len]) c.len++;
    return c;
  }
  big operator*(long long b) const {
    long long x = 0;
    big c = {0, 0};
    for (long long i = 1; i <= len || x; i++) {
      c.a[i] = a[i] * b + x;
      x = c.a[i] / 100000000;
      c.a[i] %= 100000000;
      c.len = max(i, c.len);
    }
    return c;
  }
};
long long N;
long long st[705], w, fa[705];
big ans, f0[705], f1[705], f2[705][705];
void add(long long x, long long y) {
  r[++w].x = y;
  r[w].next = st[x];
  st[x] = w;
}
void dfs(long long x) {
  long long i, j, tmp;
  f2[x][1].a[1] = f1[x].a[1] = f2[x][1].len = f1[x].len = 1;
  f0[x].a[1] = f0[x].len = 1;
  for (i = st[x]; i; i = r[i].next) {
    tmp = r[i].x;
    if (fa[x] == tmp) continue;
    fa[tmp] = x, dfs(tmp);
    for (j = N; j >= 1; j--)
      f2[x][j] = max(f1[tmp] * f2[x][j - 1], f2[x][j] * f0[tmp]);
    f0[x] = f0[x] * f0[tmp];
    for (j = 1; j <= N; j++) f0[x] = max(f0[x], f1[x] * (f2[tmp][j] * (j + 1)));
    f1[x] = f1[x] * f0[tmp];
  }
  for (j = 1; j <= N; j++) f0[x] = max(f0[x], f2[x][j] * j);
}
int main() {
  long long i, j, fr, to;
  scanf("%I64d", &N);
  for (i = 1; i < N; i++) {
    scanf("%I64d %I64d", &fr, &to);
    add(fr, to), add(to, fr);
  }
  dfs(1);
  f0[1].print();
  return 0;
}

### Prompt

Generate 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;
struct road {
  long long x, next;
} r[705 * 2];
struct big {
  long long a[16], len;
  void print() {
    printf("%I64d", a[len]);
    for (long long i = len - 1; i >= 1; i--) {
      if (a[i] / 10000000 == 0) printf("0");
      if (a[i] / 1000000 == 0) printf("0");
      if (a[i] / 100000 == 0) printf("0");
      if (a[i] / 10000 == 0) printf("0");
      if (a[i] / 1000 == 0) printf("0");
      if (a[i] / 100 == 0) printf("0");
      if (a[i] / 10 == 0) printf("0");
      printf("%I64d", a[i]);
    }
    printf("\n");
  }
  bool operator<(big b) const {
    if (len != b.len) return len < b.len;
    for (long long i = len; i >= 1; i--)
      if (a[i] != b.a[i]) return a[i] < b.a[i];
    return 0;
  }
  big operator*(big b) const {
    big c = {0, 0};
    if (!b.len || !len) return c;
    long long x = 0;
    c.len = len + b.len - 1;
    for (long long i = 1; i <= len; i++)
      for (long long j = 1; j <= b.len; j++) {
        c.a[i + j - 1] = c.a[i + j - 1] + a[i] * b.a[j];
      }
    for (long long i = 1; i <= len + b.len; i++)
      c.a[i] += x, x = c.a[i] / 100000000, c.a[i] %= 100000000;
    if (c.a[len + b.len]) c.len++;
    return c;
  }
  big operator*(long long b) const {
    long long x = 0;
    big c = {0, 0};
    for (long long i = 1; i <= len || x; i++) {
      c.a[i] = a[i] * b + x;
      x = c.a[i] / 100000000;
      c.a[i] %= 100000000;
      c.len = max(i, c.len);
    }
    return c;
  }
};
long long N;
long long st[705], w, fa[705];
big ans, f0[705], f1[705], f2[705][705];
void add(long long x, long long y) {
  r[++w].x = y;
  r[w].next = st[x];
  st[x] = w;
}
void dfs(long long x) {
  long long i, j, tmp;
  f2[x][1].a[1] = f1[x].a[1] = f2[x][1].len = f1[x].len = 1;
  f0[x].a[1] = f0[x].len = 1;
  for (i = st[x]; i; i = r[i].next) {
    tmp = r[i].x;
    if (fa[x] == tmp) continue;
    fa[tmp] = x, dfs(tmp);
    for (j = N; j >= 1; j--)
      f2[x][j] = max(f1[tmp] * f2[x][j - 1], f2[x][j] * f0[tmp]);
    f0[x] = f0[x] * f0[tmp];
    for (j = 1; j <= N; j++) f0[x] = max(f0[x], f1[x] * (f2[tmp][j] * (j + 1)));
    f1[x] = f1[x] * f0[tmp];
  }
  for (j = 1; j <= N; j++) f0[x] = max(f0[x], f2[x][j] * j);
}
int main() {
  long long i, j, fr, to;
  scanf("%I64d", &N);
  for (i = 1; i < N; i++) {
    scanf("%I64d %I64d", &fr, &to);
    add(fr, to), add(to, fr);
  }
  dfs(1);
  f0[1].print();
  return 0;
}

```