#include <bits/stdc++.h>
using namespace std;
vector<int> v[250];
int visited[250];
vector<pair<int, int> > edges;
int vmx = 0, tmx = 0;
void dfs(int x, int panned, int len) {
  visited[x] = 1;
  if (len > vmx) {
    vmx = len;
    tmx = x;
  }
  for (int i = 0; i < (int)v[x].size(); i++) {
    int child = v[x][i];
    if (!visited[child] && child != panned) dfs(child, panned, len + 1);
  }
}
int main() {
  int n;
  scanf("%d", &n);
  int x, y;
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &x, &y);
    v[x].push_back(y);
    v[y].push_back(x);
    edges.push_back(make_pair(x, y));
  }
  long long ans = -1;
  for (int i = 0; i < n - 1; i++) {
    memset(visited, 0, sizeof(visited));
    tmx = 0, vmx = 0;
    dfs(edges[i].first, edges[i].second, 0);
    memset(visited, 0, sizeof(visited));
    dfs(tmx, edges[i].second, 0);
    long long res1 = vmx;
    tmx = 0, vmx = 0;
    dfs(edges[i].second, edges[i].first, 0);
    memset(visited, 0, sizeof(visited));
    dfs(tmx, edges[i].first, 0);
    long long res2 = vmx;
    ans = max(ans, res1 * res2);
  }
  cout << ans << endl;
  return 0;
}
