#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const double PI = 4 * atan(1);
using namespace std;
const long long int N = 201;
vector<long long int> v[N + 1];
long long int deg[N + 1], vis[N + 1];
long long int dfs(long long int node, long long int u1, long long int u2,
                  long long int &f) {
  long long int x = 0;
  vis[node] = 1;
  if (node == u2) f = 1;
  for (auto t : v[node]) {
    if (!vis[t] and !(node == u1 and t == u2) and !(node == u2 and t == u1)) {
      x = max(x, 1 + dfs(t, u1, u2, f));
    }
  }
  return x;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  memset(deg, 0, sizeof(deg));
  vector<pair<long long int, long long int>> edges;
  pair<long long int, long long int> ans = make_pair(0, 0);
  for (long long int i = 0; i < n - 1; i++) {
    long long int x, y;
    cin >> x >> y;
    edges.push_back(make_pair(x, y));
    deg[x]++;
    deg[y]++;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  long long int abc = 0;
  for (auto temp : edges) {
    ans = make_pair(0, 0);
    long long int x = temp.first;
    long long int y = temp.second;
    long long int an1 = 0, an2 = 0;
    for (long long int i = 1; i <= n; ++i) {
      if (deg[i] == 1) {
        memset(vis, 0, sizeof(vis));
        long long int f = 0;
        long long int ret = dfs(i, x, y, f);
        if (f == 0)
          an1 = max(an1, ret);
        else
          an2 = max(an2, ret);
      }
    }
    abc = max(abc, an1 * an2);
  }
  cout << abc << endl;
  return 0;
}
