#include <bits/stdc++.h>
using namespace std;
template <class T, class S>
inline bool CMX(T &a, S b) {
  return a < b ? a = b, true : false;
}
template <class T, class S>
inline bool CMN(T &a, S b) {
  return a > b ? a = b, true : false;
}
template <typename T>
inline void rd(T &x) {
  x = 0;
  int f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
}
const int N = 205;
struct Edge {
  int u, v, nxt;
} e[N << 1];
bool mark[N << 1];
int n, cnt, res, h[N], pre[N];
inline void add(int u, int v) {
  e[cnt] = Edge{u, v, h[u]};
  h[u] = cnt++;
}
void dfs(int u, int fa) {
  for (int i = h[u]; ~i; i = e[i].nxt) {
    int v = e[i].v;
    if (v == fa) continue;
    pre[v] = i;
    dfs(v, u);
  }
}
int dp1[N], dp2[N];
void DP(int u, int fa) {
  for (int i = h[u]; ~i; i = e[i].nxt)
    if (mark[i]) {
      int v = e[i].v;
      if (v == fa) continue;
      DP(v, u);
      if (dp1[v] + 1 > dp1[u])
        dp2[u] = dp1[u], dp1[u] = dp1[v] + 1;
      else if (dp1[v] + 1 > dp2[u])
        dp2[u] = dp1[v] + 1;
    }
  CMX(res, dp1[u] + dp2[u]);
}
int main() {
  memset(h, -1, sizeof(h));
  rd(n);
  for (int i = 2; i <= n; i++) {
    int u, v;
    rd(u);
    rd(v);
    add(u, v);
    add(v, u);
  }
  dfs(1, -1);
  int ans = -1e9;
  for (int i = 2; i <= n; i++) {
    memset(mark, true, sizeof(mark));
    int rt1 = e[pre[i]].u;
    int rt2 = i;
    mark[pre[i]] = mark[pre[i] ^ 1] = false;
    memset(dp1, 0, sizeof(dp1));
    memset(dp2, 0, sizeof(dp2));
    res = -1e9;
    DP(rt1, -1);
    int ans1 = res;
    memset(dp1, 0, sizeof(dp1));
    memset(dp2, 0, sizeof(dp2));
    res = -1e9;
    DP(rt2, -1);
    int ans2 = res;
    CMX(ans, ans1 * ans2);
  }
  printf("%d\n", ans);
}
