#include <bits/stdc++.h>
using namespace std;
int dist[210], a, b, n;
bool color[210];
vector<int> adj[210];
pair<int, int> aristas[210];
int bfs(int node) {
  memset(color, false, sizeof(color));
  memset(dist, 0, sizeof(dist));
  queue<int> Q;
  color[node] = true;
  Q.push(node);
  dist[node] = 0;
  while (!Q.empty()) {
    node = Q.front();
    Q.pop();
    for (int i = 0; i < adj[node].size(); i++) {
      int next = adj[node][i];
      if ((node == a && next == b) || (node == b && next == a)) continue;
      if (color[next] == false) {
        color[next] = true;
        dist[next] = dist[node] + 1;
        Q.push(next);
      }
    }
  }
  return node;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d %d", &a, &b);
    a--;
    b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
    aristas[i] = make_pair(a, b);
  }
  int ans = 0;
  for (int i = 1; i < n; i++) {
    a = aristas[i].first;
    b = aristas[i].second;
    bfs(bfs(a));
    int maximo = 0;
    for (int k = 0; k < n; k++) maximo = max(maximo, dist[k]);
    bfs(bfs(b));
    int maximo2 = 0;
    for (int k = 0; k < n; k++) maximo2 = max(maximo2, dist[k]);
    ans = max(ans, maximo * maximo2);
  }
  printf("%d\n", ans);
  return 0;
}
