#include <bits/stdc++.h>
using namespace std;
const int maxn = 211;
vector<pair<int, int> > con[maxn];
vector<pair<int, int> > edge;
bool vis[maxn];
int n, w, tmx, tv, ans;
void dfs(int x, int dis) {
  vis[x] = 1;
  if (dis > tmx) tmx = dis, tv = x;
  for (int i = 0; i < con[x].size(); i++)
    if (!vis[con[x][i].first] && w != con[x][i].second)
      dfs(con[x][i].first, dis + 1);
}
int go(int x) {
  memset(vis, 0, sizeof(vis));
  tmx = tv = 0, dfs(x, 0);
  memset(vis, 0, sizeof(vis));
  tmx = 0, dfs(tv, 0);
  return tmx;
}
int main() {
  scanf("%d", &n);
  int x, y;
  for (int i = 1; i < n; i++) {
    scanf("%d %d", &x, &y);
    con[x].push_back(make_pair(y, i));
    con[y].push_back(make_pair(x, i));
    edge.push_back(make_pair(x, y));
  }
  for (w = 1; w < n; w++)
    ans = max(ans, go(edge[w - 1].first) * go(edge[w - 1].second));
  printf("%d\n", ans);
  return 0;
}
