#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> g(200);
bool u[200];
int bv, d;
void dfs(int v, int k) {
  if (k > d) {
    d = k;
    bv = v;
  }
  u[v] = true;
  for (auto x : g[v])
    if (!u[x]) dfs(x, k + 1);
}
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<pair<int, int>> r;
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    g[a].push_back(b);
    g[b].push_back(a);
    r.emplace_back(a, b);
  }
  int res = 0;
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    tie(a, b) = r[i];
    fill(u, u + n, false);
    u[b] = true;
    d = -1;
    dfs(a, 0);
    fill(u, u + n, false);
    u[b] = true;
    d = -1;
    dfs(bv, 0);
    int d1 = d;
    fill(u, u + n, false);
    u[a] = true;
    d = -1;
    dfs(b, 0);
    fill(u, u + n, false);
    u[a] = true;
    d = -1;
    dfs(bv, 0);
    int d2 = d;
    if (d1 * d2 > res) res = d1 * d2;
  }
  cout << res;
  return 0;
}
