#include <bits/stdc++.h>
void recorrido();
int trabajo(int k, int fa);
int sin_u[212];
int sin_f[212];
int aux[212];
int map[212][212];
int dob[212][212];
int dob_f[212][2];
int n;
int main() {
  int i, o, j, p = 0;
  recorrido();
  for (i = 1; i <= n; ++i) {
    for (o = 0; o < 212; ++o) {
      aux[o] = 0;
      sin_f[o] = 0;
      sin_u[o] = 0;
      dob_f[o][0] = 0;
      dob_f[o][1] = 0;
      for (j = 0; j < 212; ++j) dob[o][j] = 0;
    }
    o = trabajo(i, 0);
    if (o > p) p = o;
  }
  printf("%d\n", p);
  return 0;
}
void recorrido() {
  int i;
  int x, y;
  scanf("%d", &n);
  for (i = 1; i < n; ++i) {
    scanf("%d %d", &x, &y);
    map[x][y] = 1;
    map[y][x] = 1;
  }
}
int trabajo(int k, int fa) {
  int i, o, p, j;
  int a[212];
  int x, y;
  aux[k] = 1;
  a[0] = 0;
  for (i = 1; i <= n; ++i) {
    if (aux[i] == 0 && map[k][i] == 1) {
      trabajo(i, k);
      a[++a[0]] = i;
    }
  }
  if (a[0] == 0) {
    for (i = 1; i < 212; ++i) dob[k][i] = -1;
    return 0;
  }
  for (i = 1; i <= a[0]; ++i)
    if (sin_u[a[i]] > sin_u[k]) sin_u[k] = sin_u[a[i]];
  ++sin_u[k];
  if (a[0] >= 2) {
    p = -1;
    for (i = 1; i <= a[0]; ++i)
      if (sin_u[a[i]] > p) {
        x = i;
        p = sin_u[a[i]];
      }
    p = -1;
    for (i = 1; i <= a[0]; ++i)
      if (sin_u[a[i]] > p && i != x) {
        y = i;
        p = sin_u[a[i]];
      }
    sin_f[k] = sin_u[a[x]] + sin_u[a[y]] + 2;
  }
  for (i = 1; i <= a[0]; ++i)
    if (sin_f[a[i]] > sin_f[k]) sin_f[k] = sin_f[a[i]];
  if (sin_u[k] > sin_f[k]) sin_f[k] = sin_u[k];
  for (i = 0; i < 212; ++i) dob[k][i] = -1;
  for (i = 1; i <= a[0]; ++i)
    if (dob[k][0] < sin_f[a[i]]) dob[k][0] = sin_f[a[i]];
  for (i = 1; i <= a[0]; ++i)
    for (j = 0; dob[a[i]][j] != -1; ++j)
      if (dob[k][j + 1] < dob[a[i]][j]) dob[k][j + 1] = dob[a[i]][j];
  for (i = 1; i <= a[0]; ++i)
    for (j = 1; j <= a[0]; ++j)
      if (i != j) {
        x = sin_u[a[i]] + 1;
        y = sin_f[a[j]];
        for (o = x; o >= 1; --o)
          if (dob[k][o] < y) {
            dob[k][o] = y;
          }
      }
  for (i = 1; i <= a[0]; ++i)
    for (j = 1; j <= a[0]; ++j)
      if (i != j) {
        for (o = 0; dob[a[i]][o] != -1; ++o) {
          x = sin_u[a[j]] + 2 + o;
          y = dob[a[i]][o];
          if (x * y > dob_f[k][0] * dob_f[k][1]) {
            dob_f[k][0] = x;
            dob_f[k][1] = y;
          }
        }
        if (sin_f[a[i]] * sin_f[a[j]] > dob_f[k][0] * dob_f[k][1]) {
          dob_f[k][0] = sin_f[a[i]];
          dob_f[k][1] = sin_f[a[j]];
        }
      }
  for (i = 1; i <= a[0]; ++i) {
    if (dob_f[a[i]][0] * dob_f[a[i]][1] > dob_f[k][0] * dob_f[k][1]) {
      dob_f[k][0] = dob_f[a[i]][0];
      dob_f[k][1] = dob_f[a[i]][1];
    }
  }
  for (i = 0; dob[k][i] != -1; ++i) {
    if (dob[k][i] * i > dob_f[k][0] * dob_f[k][1]) {
      dob_f[k][0] = dob[k][i];
      dob_f[k][1] = i;
    }
  }
  return (dob_f[k][0] * dob_f[k][1]);
}
