#include <bits/stdc++.h>
using namespace std;
const int N = 205;
int ans, i, n, x[N], y[N];
vector<int> g[N];
bool used[N];
inline int d(int node) {
  memset(used, 0, sizeof(used));
  used[x[i]] = used[y[i]] = true;
  queue<int> q;
  q.push(node);
  int last;
  while (!q.empty()) {
    last = q.front();
    q.pop();
    for (int i = 0; i < g[last].size(); i++) {
      int to = g[last][i];
      if (!used[to]) {
        used[to] = true;
        q.push(to);
      }
    }
  }
  memset(used, 0, sizeof(used));
  if (node == x[i]) {
    used[y[i]] = true;
  } else {
    used[x[i]] = true;
  }
  queue<pair<int, int> > qq;
  int ss;
  qq.push(make_pair(last, 0));
  used[last] = true;
  while (!qq.empty()) {
    int v = qq.front().first;
    ss = qq.front().second;
    qq.pop();
    for (int i = 0; i < g[v].size(); i++) {
      int to = g[v][i];
      if (!used[to]) {
        qq.push(make_pair(to, ss + 1));
        used[to] = true;
      }
    }
  }
  return ss;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (i = 1; i < n; i++) {
    cin >> x[i] >> y[i];
    g[x[i]].push_back(y[i]);
    g[y[i]].push_back(x[i]);
  }
  for (i = 1; i < n; i++) {
    ans = max(ans, d(x[i]) * d(y[i]));
  }
  cout << ans;
}
