#include <bits/stdc++.h>
using namespace std;
int n;
bool explored[205];
int dfs1(int u, int& dist, vector<vector<int>>& g) {
  explored[u] = true;
  int d = 0;
  int ee = u;
  for (auto& v : g[u]) {
    if (!explored[v]) {
      int a = 0;
      int w = dfs1(v, a, g);
      if (a + 1 > d) {
        d = a + 1;
        ee = w;
      }
    }
  }
  dist += d;
  return ee;
}
int diam(int u, vector<vector<int>>& g) {
  int ans = 0;
  int v = dfs1(u, ans, g);
  for (int i = 0; i < n; i++) explored[i] = false;
  ans = 0;
  dfs1(v, ans, g);
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int u, v;
  cin >> n;
  vector<vector<int>> graph(n);
  vector<pair<int, int>> edges(n - 1);
  for (int i = 0; i < n - 1; i++) {
    cin >> u >> v;
    u--;
    v--;
    edges[i] = {u, v};
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  int ans = 0;
  for (int i = 0; i < n - 1; i++) {
    u = edges[i].first;
    v = edges[i].second;
    if (graph[u].size() < 2) continue;
    if (graph[v].size() < 2) continue;
    vector<vector<int>> g1(n);
    for (int j = 0; j < n - 1; j++) {
      if (j == i) continue;
      g1[edges[j].first].push_back(edges[j].second);
      g1[edges[j].second].push_back(edges[j].first);
    }
    for (int i = 0; i < n; i++) explored[i] = false;
    ans = max(ans, diam(u, g1) * diam(v, g1));
  }
  cout << ans << '\n';
  return 0;
}
