#include <bits/stdc++.h>
using namespace std;
const int MX = 205;
vector<int> g[MX], v[MX];
int n, x, mx, k, id, l[MX], r[MX], d[MX];
void dfs(int u, int p) {
  if (p) {
    d[u] = d[p] + 1;
    if (d[u] > k) {
      k = d[u];
      id = u;
    }
  }
  for (auto v : g[u]) {
    if (v == p) continue;
    dfs(v, u);
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    cin >> l[i] >> r[i];
    v[l[i]].push_back(r[i]);
    v[r[i]].push_back(l[i]);
  }
  for (int i = 0; i < n - 1; i++) {
    if (v[l[i]].size() < 2 || v[r[i]].size() < 2) continue;
    for (int j = 0; j <= n; j++) g[j].clear();
    for (int j = 0; j < n - 1; j++) {
      if (j - i) {
        g[l[j]].push_back(r[j]);
        g[r[j]].push_back(l[j]);
      }
    }
    x = 1;
    k = 0;
    memset(d, 0, sizeof(d));
    dfs(l[i], 0);
    memset(d, 0, sizeof(d));
    dfs(id, 0);
    x *= k;
    k = 0;
    memset(d, 0, sizeof(d));
    dfs(r[i], 0);
    memset(d, 0, sizeof(d));
    dfs(id, 0);
    x *= k;
    mx = max(mx, x);
  }
  cout << mx;
  return 0;
}
