#include <bits/stdc++.h>
using namespace std;
string postFile = "test.txt";
vector<vector<int> > a(300, vector<int>(300));
vector<int> can;
vector<int> dist;
void init() {}
void dfs(int now, int d, int n, int& last, int mark) {
  if (can[now] == mark) return;
  can[now] = mark;
  dist[now] = d;
  if (d > dist[last]) last = now;
  for (int _n(n), i(0); i < _n; i++)
    if (a[now][i] == 1) dfs(i, d + 1, n, last, mark);
}
void solve() {
  int n;
  cin >> n;
  for (int _n(n - 1), i(0); i < _n; i++) {
    int x, y;
    cin >> x >> y;
    --x;
    --y;
    a[x][y] = a[y][x] = 1;
  }
  int res = 0;
  for (int _n(n), i(0); i < _n; i++) {
    for (int _n(n), j(i + 1); j < _n; j++) {
      if (!a[i][j]) continue;
      can = vector<int>(n);
      a[i][j] = a[j][i] = 0;
      int ind = 0;
      int tres = 1;
      int t = 0;
      for (int _n(n), k(0); k < _n; k++) {
        if (can[k] != 0) continue;
        dist = vector<int>(n);
        int last = k;
        dfs(k, 0, n, last, 1);
        dfs(last, 0, n, last, 2);
        tres *= dist[last];
      }
      res = max(res, tres);
      a[i][j] = a[j][i] = 1;
    }
  }
  cout << res << endl;
}
int main() {
  init();
  solve();
}
