#include <bits/stdc++.h>
using namespace std;
vector<int> l[205];
int n, vis[205], pathLength, maxd1, maxd2, start;
void dfs(int node, int lvl) {
  vis[node] = 1;
  pathLength = max(pathLength, lvl);
  for (int i = 0; i < l[node].size(); i++) {
    if (vis[l[node][i]] == 0) {
      dfs(l[node][i], lvl + 1);
      if (node == start) {
        if (maxd2 <= pathLength) {
          maxd1 = max(maxd1, maxd2);
          maxd2 = pathLength;
          pathLength = lvl;
        } else {
          maxd1 = max(maxd1, pathLength);
          pathLength = lvl;
        }
      }
    }
  }
}
void addEdge(int a, int b) {
  l[a].push_back(b);
  l[b].push_back(a);
}
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    addEdge(a, b);
  }
  int maxProd = 0;
  for (int i = 1; i < n; i++) {
    for (int j = i + 1; j <= n; j++) {
      vis[j] = 1;
      start = i;
      dfs(i, 0);
      int t1 = maxd1 + maxd2;
      maxd1 = 0, maxd2 = 0;
      start = j;
      dfs(j, 0);
      int t2 = maxd1 + maxd2;
      maxd1 = 0, maxd2 = 0;
      memset(vis, 0, sizeof(vis));
      maxProd = max(maxProd, t1 * t2);
    }
  }
  cout << maxProd << '\n';
  return 0;
}
