#include <bits/stdc++.h>
using namespace std;
const int N = 203;
const int mod = 1e9 + 7;
vector<int> g[N];
int dp[N];
int ans, n;
int len1, len2;
void cal(int u, int fa, int &len) {
  dp[u] = 0;
  int &mx1 = dp[u], mx2 = 0;
  int v;
  for (__typeof((g[u]).begin()) v = (g[u]).begin(); v != (g[u]).end(); v++) {
    if (*v == fa) continue;
    cal(*v, u, len);
    if (mx2 < dp[*v] + 1) {
      mx2 = dp[*v] + 1;
      if (mx2 > mx1) swap(mx1, mx2);
    }
  }
  len = max(len, mx1 + mx2);
}
void dfs(int u, int fa) {
  int v;
  for (__typeof((g[u]).begin()) v = (g[u]).begin(); v != (g[u]).end(); v++) {
    if (*v == fa) continue;
    len1 = len2 = 0;
    cal(*v, u, len1);
    cal(u, *v, len2);
    ans = max(ans, len1 * len2);
    dfs(*v, u);
  }
}
int main() {
  int i, j;
  scanf("%d", &n);
  for (i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(1, 0);
  printf("%d\n", ans);
  return 0;
}
