#include <bits/stdc++.h>
using namespace std;
vector<int> adj[210];
int N;
int A[210][2], essa;
int dp[210];
int cor[210];
void dfs(int no, int c, int pai) {
  if (cor[no] != -1) return;
  cor[no] = c;
  for (int i = adj[no].size() - 1; i >= 0; i--) {
    int adjj = adj[no][i];
    if (adjj != pai) dfs(adjj, c, no);
  }
}
int go(int no, int pai) {
  int& res = dp[no];
  if (res == -1) {
    res = 0;
    for (int i = adj[no].size() - 1; i >= 0; i--) {
      int adjj = adj[no][i];
      if (adjj == pai || (no == A[essa][0] && adjj == A[essa][1]) ||
          (adjj == A[essa][0] && no == A[essa][1])) {
        continue;
      }
      res = max(res, go(adjj, no) + 1);
    }
  }
  return res;
}
int main() {
  scanf("%d", &N);
  int a, b;
  for (int i = 1; i < N; i++) {
    scanf("%d %d", &a, &b);
    A[i][0] = --a, A[i][1] = --b;
    adj[a].push_back(b), adj[b].push_back(a);
  }
  int best = 0;
  for (int i = 1; i < N; i++) {
    essa = i;
    memset(cor, -1, sizeof(cor));
    dfs(A[essa][0], 0, A[essa][1]);
    dfs(A[essa][1], 1, A[essa][0]);
    int best1 = 0, best2 = 0;
    for (int j = 0; j < N; j++) {
      memset(dp, -1, sizeof(dp));
      if (cor[j] == 0) {
        best1 = max(best1, go(j, -1));
      } else {
        best2 = max(best2, go(j, -1));
      }
    }
    best = max(best, best1 * best2);
  }
  printf("%d\n", best);
  return (0);
}
