#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> a[1024];
vector<int> a1[1024];
int d[12][1024][16];
int t[1024][16];
int c[1024];
bool u[1024];
void tolong(int *a, int k) {
  memset(a, 0, 16 * sizeof(a[0]));
  do {
    a[++a[0]] = k % 1000000000;
    k /= 1000000000;
  } while (k);
}
void multak(int *a, int k) {
  long long j = 0;
  for (int i = (1); i <= (int)(a[0]); i++) {
    j += (long long)a[i] * k;
    a[i] = j % 1000000000;
    j /= 1000000000;
  }
  if (j) a[++a[0]] = j;
  while (a[0] > 1 && !a[a[0]]) a[0]--;
}
void multab(int *a, int *b) {
  int c[16];
  memset(c, 0, sizeof(c));
  for (int i = (1); i <= (int)(a[0]); i++) {
    for (int j = (1); j <= (int)(b[0]); j++) {
      long long t = c[i + j - 1] + (long long)a[i] * b[j];
      c[i + j - 1] = t % 1000000000;
      c[i + j] += t / 1000000000;
    }
  }
  c[0] = a[0] + b[0];
  memcpy(a, c, sizeof(c));
  while (a[0] > 1 && !a[a[0]]) a[0]--;
}
bool lessab(int *a, int *b) {
  if (a[0] != b[0]) return a[0] < b[0];
  for (int i = (a[0]); i >= (int)(1); i--) {
    if (a[i] != b[i]) return a[i] < b[i];
  }
  return false;
}
int dfs1(int k) {
  u[k] = true;
  c[k] = 1;
  for (int i1 = 0; i1 < (int)(a1[k].size()); i1++) {
    int i = a1[k][i1];
    if (!u[i]) {
      a[k].push_back(i);
      c[k] += dfs1(i);
    }
  }
  return c[k];
}
void writelong(int *a) {
  printf("%d", a[a[0]]);
  for (int i = (a[0] - 1); i >= (int)(1); i--) {
    printf("%09d", a[i]);
  }
  puts("");
}
bool cmp(int p1, int p2) { return c[p1] > c[p2]; }
void dfs(int k, int h) {
  memset(d[h], 0, sizeof(d[h]));
  if (!a[k].size()) {
    tolong(d[h][0], 1);
    tolong(d[h][1], 1);
    return;
  }
  dfs(a[k][0], h);
  for (int i = (c[a[k][0]]); i >= (int)(0); i--) {
    memcpy(d[h][i + 1], d[h][i], sizeof(d[h][i]));
  }
  tolong(d[h][0], 0);
  int s = c[a[k][0]];
  for (int i1 = (1); i1 <= (int)(a[k].size() - 1); i1++) {
    int i = a[k][i1];
    dfs(i, h + 1);
    memset(t, 0, sizeof(t));
    for (int j = (1); j <= (int)(s + 1); j++) {
      int tmp[16];
      memcpy(tmp, d[h][j], sizeof(tmp));
      multab(tmp, d[h + 1][0]);
      if (lessab(t[j], tmp)) {
        memcpy(t[j], tmp, sizeof(tmp));
      }
      for (int l = (1); l <= (int)(c[i]); l++) {
        memcpy(tmp, d[h][j], sizeof(tmp));
        multab(tmp, d[h + 1][l]);
        if (lessab(t[j + l], tmp)) {
          memcpy(t[j + l], tmp, sizeof(tmp));
        }
      }
    }
    memcpy(d[h], t, sizeof(t));
    s += c[i];
  }
  for (int i = (1); i <= (int)(s + 1); i++) {
    int tmp[16];
    memcpy(tmp, d[h][i], sizeof(tmp));
    multak(tmp, i);
    if (lessab(d[h][0], tmp)) {
      memcpy(d[h][0], tmp, sizeof(tmp));
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < (int)(n - 1); i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--;
    y--;
    a1[x].push_back(y);
    a1[y].push_back(x);
  }
  memset(u, 0, sizeof(u));
  dfs1(0);
  for (int i = 0; i < (int)(n); i++) {
    sort(a[i].begin(), a[i].end(), cmp);
  }
  dfs(0, 0);
  writelong(d[0][0]);
  return 0;
}

### Prompt

Your challenge is to write 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;
int n;
vector<int> a[1024];
vector<int> a1[1024];
int d[12][1024][16];
int t[1024][16];
int c[1024];
bool u[1024];
void tolong(int *a, int k) {
  memset(a, 0, 16 * sizeof(a[0]));
  do {
    a[++a[0]] = k % 1000000000;
    k /= 1000000000;
  } while (k);
}
void multak(int *a, int k) {
  long long j = 0;
  for (int i = (1); i <= (int)(a[0]); i++) {
    j += (long long)a[i] * k;
    a[i] = j % 1000000000;
    j /= 1000000000;
  }
  if (j) a[++a[0]] = j;
  while (a[0] > 1 && !a[a[0]]) a[0]--;
}
void multab(int *a, int *b) {
  int c[16];
  memset(c, 0, sizeof(c));
  for (int i = (1); i <= (int)(a[0]); i++) {
    for (int j = (1); j <= (int)(b[0]); j++) {
      long long t = c[i + j - 1] + (long long)a[i] * b[j];
      c[i + j - 1] = t % 1000000000;
      c[i + j] += t / 1000000000;
    }
  }
  c[0] = a[0] + b[0];
  memcpy(a, c, sizeof(c));
  while (a[0] > 1 && !a[a[0]]) a[0]--;
}
bool lessab(int *a, int *b) {
  if (a[0] != b[0]) return a[0] < b[0];
  for (int i = (a[0]); i >= (int)(1); i--) {
    if (a[i] != b[i]) return a[i] < b[i];
  }
  return false;
}
int dfs1(int k) {
  u[k] = true;
  c[k] = 1;
  for (int i1 = 0; i1 < (int)(a1[k].size()); i1++) {
    int i = a1[k][i1];
    if (!u[i]) {
      a[k].push_back(i);
      c[k] += dfs1(i);
    }
  }
  return c[k];
}
void writelong(int *a) {
  printf("%d", a[a[0]]);
  for (int i = (a[0] - 1); i >= (int)(1); i--) {
    printf("%09d", a[i]);
  }
  puts("");
}
bool cmp(int p1, int p2) { return c[p1] > c[p2]; }
void dfs(int k, int h) {
  memset(d[h], 0, sizeof(d[h]));
  if (!a[k].size()) {
    tolong(d[h][0], 1);
    tolong(d[h][1], 1);
    return;
  }
  dfs(a[k][0], h);
  for (int i = (c[a[k][0]]); i >= (int)(0); i--) {
    memcpy(d[h][i + 1], d[h][i], sizeof(d[h][i]));
  }
  tolong(d[h][0], 0);
  int s = c[a[k][0]];
  for (int i1 = (1); i1 <= (int)(a[k].size() - 1); i1++) {
    int i = a[k][i1];
    dfs(i, h + 1);
    memset(t, 0, sizeof(t));
    for (int j = (1); j <= (int)(s + 1); j++) {
      int tmp[16];
      memcpy(tmp, d[h][j], sizeof(tmp));
      multab(tmp, d[h + 1][0]);
      if (lessab(t[j], tmp)) {
        memcpy(t[j], tmp, sizeof(tmp));
      }
      for (int l = (1); l <= (int)(c[i]); l++) {
        memcpy(tmp, d[h][j], sizeof(tmp));
        multab(tmp, d[h + 1][l]);
        if (lessab(t[j + l], tmp)) {
          memcpy(t[j + l], tmp, sizeof(tmp));
        }
      }
    }
    memcpy(d[h], t, sizeof(t));
    s += c[i];
  }
  for (int i = (1); i <= (int)(s + 1); i++) {
    int tmp[16];
    memcpy(tmp, d[h][i], sizeof(tmp));
    multak(tmp, i);
    if (lessab(d[h][0], tmp)) {
      memcpy(d[h][0], tmp, sizeof(tmp));
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < (int)(n - 1); i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--;
    y--;
    a1[x].push_back(y);
    a1[y].push_back(x);
  }
  memset(u, 0, sizeof(u));
  dfs1(0);
  for (int i = 0; i < (int)(n); i++) {
    sort(a[i].begin(), a[i].end(), cmp);
  }
  dfs(0, 0);
  writelong(d[0][0]);
  return 0;
}

```