#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, inf = INT_MAX, mod = 1e9 + 7;
vector<int> v[202];
int p1, p2, n1;
bool vis[202];
void dfs(int node, int c, pair<int, int> del) {
  vis[node] = true;
  for (auto it : v[node])
    if (!((it == del.first && node == del.second) ||
          (it == del.second && node == del.first)) &&
        !vis[it]) {
      if (c > p1) p1 = c, n1 = it;
      dfs(it, c + 1, del);
    }
}
int main() {
  int n, ans = 0;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  for (int node1 = 1; node1 <= n; node1++)
    for (auto node2 : v[node1]) {
      pair<int, int> del = {node1, node2};
      p1 = 0;
      memset(vis, false, sizeof vis);
      n1 = 1;
      dfs(1, 1, del);
      p1 = 0;
      memset(vis, false, sizeof vis);
      dfs(n1, 1, del);
      p2 = p1;
      for (int i = 1; i <= n; i++)
        if (!vis[i]) {
          p1 = 0;
          n1 = i;
          dfs(i, 1, del);
          memset(vis, false, sizeof vis);
          p1 = 0;
          dfs(n1, 1, del);
          break;
        }
      ans = max(ans, p1 * p2);
    }
  cout << ans;
  return 0;
}
