#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 200 + 20;
vector<int> adj[MAX_N];
int d[MAX_N];
int a[MAX_N][3];
int n, ans;
int dfs(int v, int Par) {
  d[v] = a[v][0] = a[v][1] = a[v][2] = 0;
  int ret = 0;
  for (int i(0); i < int(adj[v].size()); i++) {
    int u = adj[v][i];
    if (u != Par) {
      ret = max(ret, dfs(u, v));
      d[v] = max(d[v], d[u] + 1);
      a[v][2] = d[u] + 1;
      sort(a[v], a[v] + 3, greater<int>());
    }
  }
  int di = a[v][0] + a[v][1];
  return max(di, ret);
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i(0); i < int(n - 1); i++) {
    int v, u;
    cin >> v >> u;
    --v, u--;
    adj[v].push_back(u);
    adj[u].push_back(v);
  }
  for (int v(0); v < int(n - 1); v++)
    for (int i(0); i < int(adj[v].size()); i++) {
      int u = adj[v][i];
      ans = max(ans, dfs(v, u) * dfs(u, v));
    }
  cout << ans << endl;
  return 0;
}
