#include <bits/stdc++.h>
long long max(long long x, long long y) { return x > y ? x : y; }
long long min(long long x, long long y) { return x < y ? x : y; }
using namespace std;
const long long N = 200 + 5;
long long n, ans;
long long dis[N];
bool mark[N][N];
bool flag[N];
pair<long long, long long> yal[N], u;
void dfs(long long root) {
  flag[root] = true;
  for (long long i = 1; i <= n; i++)
    if (mark[root][i] && !flag[i]) {
      dis[i] = dis[root] + 1;
      dfs(i);
    }
  if (dis[root] > u.first) u = make_pair(dis[root], root);
}
int main() {
  cin >> n;
  for (long long i = 1; i < n; i++) {
    long long u1, u2;
    cin >> u1 >> u2;
    mark[u1][u2] = mark[u2][u1] = true;
    yal[i] = make_pair(u1, u2);
  }
  for (long long i = 1; i < n; i++) {
    memset(flag, false, sizeof flag);
    mark[yal[i].first][yal[i].second] = mark[yal[i].second][yal[i].first] =
        false;
    vector<long long> v;
    for (long long j = 1; j <= n; j++)
      if (!flag[j]) {
        u = make_pair(0, 0);
        dis[j] = 0;
        dfs(j);
        dis[u.second] = 0;
        memset(flag, false, sizeof flag);
        dfs(u.second);
        v.push_back(u.first);
      }
    ans = max(ans, v[0] * v[1]);
    mark[yal[i].first][yal[i].second] = mark[yal[i].second][yal[i].first] =
        true;
  }
  cout << ans << endl;
  return 0;
}
