#include <bits/stdc++.h>
using namespace std;
const int maxn = 200 + 5;
int n;
int x[maxn], y[maxn];
vector<int> v[maxn];
int ans;
int mx, h;
void dfs(int x, int f, int num, int p) {
  if (num > mx) {
    mx = num;
    h = x;
  }
  for (int i = 0; i < v[x].size(); ++i) {
    int nxt = v[x][i];
    if (nxt == f) continue;
    if (nxt == p) continue;
    dfs(nxt, x, num + 1, p);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    scanf("%d%d", &x[i], &y[i]);
    v[x[i]].push_back(y[i]);
    v[y[i]].push_back(x[i]);
  }
  for (int i = 1; i < n; ++i) {
    mx = h = 0;
    dfs(x[i], y[i], 0, y[i]);
    mx = 0;
    dfs(h, 0, 0, y[i]);
    int res = mx;
    mx = h = 0;
    dfs(y[i], x[i], 0, x[i]);
    mx = 0;
    dfs(h, 0, 0, x[i]);
    int tmp = mx;
    ans = max(ans, res * tmp);
  }
  printf("%d\n", ans);
  return 0;
}
