#include <bits/stdc++.h>
using namespace std;
vector<int> V[201];
int deep = 0;
int dfs(int i, int pre) {
  int s = 0, max1 = 0, max2 = 0;
  for (int k = 0; k < V[i].size(); k++) {
    if (V[i][k] != pre) {
      s = max(dfs(V[i][k], i), s);
      if (deep > max1) {
        max2 = max1;
        max1 = deep;
      } else
        max2 = max(max2, deep);
    }
  }
  s = max(s, max1 + max2), deep = max1 + 1;
  return s;
}
int main() {
  int n;
  int point1, point2;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    cin >> point1 >> point2;
    V[point1].push_back(point2);
    V[point2].push_back(point1);
  }
  int mp1, mp2;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < V[i].size(); j++) {
      mp1 = dfs(i, V[i][j]);
      mp2 = dfs(V[i][j], i);
      ans = max(ans, mp1 * mp2);
    }
  }
  cout << ans << endl;
  return 0;
}
