#include <bits/stdc++.h>
using namespace std;
const int MAX_N = (200 + 20);
int N, ed, maxlen, ans, dp[MAX_N], pre[MAX_N];
vector<int> g[MAX_N];
void dfs(int u, int fa, int len, int limit) {
  dp[u] = len;
  pre[u] = fa;
  for (int i = (0); i < ((int)g[u].size()); ++i) {
    int v = g[u][i];
    if (v != fa && v != limit) dfs(v, u, len + 1, limit);
  }
}
int gao(int u, int v) {
  memset(dp, 0, sizeof(dp));
  dfs(u, -1, 0, v);
  maxlen = 0;
  ed = u;
  for (int i = (1); i <= (N); ++i)
    if (dp[i] > maxlen) maxlen = dp[i], ed = i;
  dfs(ed, -1, 0, v);
  maxlen = 0;
  for (int i = (1); i <= (N); ++i)
    if (dp[i] > maxlen) maxlen = dp[i], ed = i;
  return maxlen;
}
int main() {
  while (cin >> N) {
    for (int i = (1); i < (N + 1); ++i) g[i].clear();
    for (int i = (1); i < (N); ++i) {
      int u, v;
      cin >> u >> v;
      g[u].push_back(v);
      g[v].push_back(u);
    }
    ans = 0;
    for (int i = (1); i <= (N); ++i) {
      for (int j = (0); j < ((int)g[i].size()); ++j) {
        int l = gao(i, g[i][j]);
        int r = gao(g[i][j], i);
        ans = max(ans, l * r);
      }
    }
    cout << ans << endl;
  }
  return 0;
}
