#include <bits/stdc++.h>
using namespace std;
int len, rt, n, m;
vector<int> g[210];
int a[210], b[210];
void dfs(int cur, int pre, int dep) {
  int i;
  if (dep > len) {
    len = dep;
    rt = cur;
  }
  for (i = 0; i < g[cur].size(); i++) {
    int u = g[cur][i];
    if (u == pre) continue;
    dfs(u, cur, dep + 1);
  }
}
int solve(int root) {
  rt = root;
  len = 0;
  dfs(root, root, 0);
  len = 0;
  dfs(rt, rt, 0);
  return len;
}
void Init() {
  for (int i = 1; i <= n; ++i) g[i].clear();
}
int main() {
  int i, j;
  scanf("%d", &n);
  for (i = 1; i < n; i++) scanf("%d%d", &a[i], &b[i]);
  int ans = 0;
  for (i = 1; i < n; i++) {
    Init();
    int x = a[i], y = b[i];
    for (j = 1; j < n; j++)
      if (i != j) {
        g[a[j]].push_back(b[j]);
        g[b[j]].push_back(a[j]);
      }
    ans = max(ans, solve(x) * solve(y));
  }
  printf("%d\n", ans);
  return 0;
}
