#include <bits/stdc++.h>
const double inf = 1e20;
using namespace std;
pair<int, int> p[222];
int n, tre[222][222], dis[222], mxans;
int main() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    cin >> p[i].first >> p[i].second;
    tre[p[i].first][p[i].second] = tre[p[i].second][p[i].first] = 1;
  }
  for (int i = 0; i < n - 1; i++) {
    int ans = 1;
    tre[p[i].first][p[i].second] = tre[p[i].second][p[i].first] = 0;
    int mx = 0;
    memset(dis, 0, sizeof(dis));
    queue<int> q;
    q.push(p[i].first);
    dis[p[i].first] = 1;
    while (!q.empty()) {
      int t = q.front();
      q.pop();
      if (dis[t] > dis[mx]) mx = t;
      for (int j = 1; j <= n; j++)
        if (tre[t][j] && !dis[j]) q.push(j), dis[j] = dis[t] + 1;
    }
    memset(dis, 0, sizeof(dis));
    q.push(mx);
    dis[mx] = 1;
    mx = 0;
    while (!q.empty()) {
      int t = q.front();
      q.pop();
      if (dis[t] > dis[mx]) mx = t;
      for (int j = 1; j <= n; j++)
        if (tre[t][j] && !dis[j]) q.push(j), dis[j] = dis[t] + 1;
    }
    ans *= dis[mx] - 1;
    mx = 0;
    memset(dis, 0, sizeof(dis));
    q.push(p[i].second);
    dis[p[i].second] = 1;
    while (!q.empty()) {
      int t = q.front();
      q.pop();
      if (dis[t] > dis[mx]) mx = t;
      for (int j = 1; j <= n; j++)
        if (tre[t][j] && !dis[j]) q.push(j), dis[j] = dis[t] + 1;
    }
    memset(dis, 0, sizeof(dis));
    q.push(mx);
    dis[mx] = 1;
    mx = 0;
    while (!q.empty()) {
      int t = q.front();
      q.pop();
      if (dis[t] > dis[mx]) mx = t;
      for (int j = 1; j <= n; j++)
        if (tre[t][j] && !dis[j]) q.push(j), dis[j] = dis[t] + 1;
    }
    ans *= dis[mx] - 1;
    tre[p[i].first][p[i].second] = tre[p[i].second][p[i].first] = 1;
    if (ans > mxans) mxans = ans;
  }
  cout << mxans;
  return 0;
}
