#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200 + 10;
vector<int> g[MAXN], Q;
pair<int, int> E[MAXN];
int n, uu, vv, mark[MAXN], dis[MAXN], ans;
int bfs2(int v) {
  int MAX = 0;
  memset(mark, 0, sizeof(mark));
  memset(dis, 0, sizeof(dis));
  Q.clear();
  dis[v] = 0;
  mark[v] = 1;
  Q.push_back(v);
  for (int i = 0; i < (int)Q.size(); i++) {
    int u = Q[i];
    for (int j = 0; j < (int)g[u].size(); j++) {
      int x = g[u][j];
      if ((u == vv && x == uu) || (u == uu && x == vv)) continue;
      if (!mark[x]) {
        dis[x] = dis[u] + 1;
        Q.push_back(x);
        mark[x] = 1;
        MAX = max(MAX, dis[x]);
      }
    }
  }
  return MAX;
}
int bfs1(int v) {
  int MAX = 0, vertex = 0;
  memset(mark, 0, sizeof(mark));
  memset(dis, 0, sizeof(dis));
  Q.clear();
  dis[v] = 0;
  mark[v] = 1;
  Q.push_back(v);
  for (int i = 0; i < (int)Q.size(); i++) {
    int u = Q[i];
    for (int j = 0; j < (int)g[u].size(); j++) {
      int x = g[u][j];
      if ((u == vv && x == uu) || (u == uu && x == vv)) continue;
      if (!mark[x]) {
        dis[x] = dis[u] + 1;
        Q.push_back(x);
        mark[x] = 1;
        if (dis[x] > MAX) {
          MAX = dis[x];
          vertex = x;
        }
      }
    }
  }
  return vertex;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n - 1; i++) {
    int u, v;
    cin >> u >> v;
    E[i] = pair<int, int>(u, v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int count = 1; count <= n - 1; count++) {
    uu = E[count].first;
    vv = E[count].second;
    int temp = bfs2(bfs1(uu));
    temp *= bfs2(bfs1(vv));
    ans = max(ans, temp);
  }
  cout << ans << endl;
  return 0;
}
