#include <bits/stdc++.h>
const long long mod = 1000000007ll;
const double pi = acos(-1.0);
using namespace std;
int n;
std::vector<int> v[208];
std::vector<pair<int, int> > edges;
bool isedge[208][208];
int lpath = 0, lnode = 0;
void dfs(int cur, int par, int dis) {
  if (dis >= lpath) {
    lnode = cur;
    lpath = dis;
  }
  for (int child : v[cur]) {
    if (child != par && isedge[cur][child]) {
      dfs(child, cur, dis + 1);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  int a, b;
  for (int i = 0; i < n - 1; i++) {
    cin >> a >> b;
    edges.push_back(make_pair(a, b));
    v[a].push_back(b);
    v[b].push_back(a);
    isedge[a][b] = 1;
    isedge[b][a] = 1;
  }
  int ans = -1;
  for (int i = 0; i < edges.size(); i++) {
    a = edges[i].first;
    b = edges[i].second;
    isedge[a][b] = isedge[b][a] = 0;
    lpath = 0;
    dfs(a, 0, 0);
    lpath = 0;
    dfs(lnode, 0, 0);
    int path1 = lpath;
    lpath = 0;
    dfs(b, 0, 0);
    lpath = 0;
    dfs(lnode, 0, 0);
    int path2 = lpath;
    ans = max(ans, path1 * path2);
    isedge[a][b] = isedge[b][a] = 1;
  }
  cout << ans << "\n";
  return 0;
}
