#include <bits/stdc++.h>
void ActivateFastIO() {
  std::ios::sync_with_stdio(false);
  std::cout.tie(nullptr);
  std::cin.tie(nullptr);
}
template <typename type1, typename type2>
std::istream& operator>>(std::istream& in, std::pair<type1, type2>& p) {
  in >> p.first >> p.second;
  return in;
}
template <typename type1, typename type2>
std::ostream& operator<<(std::ostream& o, const std::pair<type1, type2>& p) {
  o << p.first << ' ' << p.second;
  return o;
}
template <typename type>
std::istream& operator>>(std::istream& in, std::vector<type>& v) {
  for (int i = 0; i < v.size(); ++i) {
    in >> v[i];
  }
  return in;
}
template <typename type>
std::ostream& operator<<(std::ostream& o, const std::vector<type>& v) {
  if (!v.empty()) {
    o << v.front();
  }
  for (int i = 1; i < v.size(); ++i) {
    o << ' ' << v[i];
  }
  return o;
}
std::vector<int> g[202];
bool visited[202];
void ResetVisited() {
  for (int i = 0; i < 202; ++i) {
    visited[i] = false;
  }
}
bool IsDeleted(int node1, int node2, std::pair<int, int> deletedPath) {
  return ((node1 == deletedPath.first && node2 == deletedPath.second) ||
          (node1 == deletedPath.second && node2 == deletedPath.first));
}
std::pair<int, int> dfs(int node, std::pair<int, int> deletedPath) {
  visited[node] = true;
  std::pair<int, int> ans{0, node};
  for (int to : g[node]) {
    if (!visited[to] && !IsDeleted(node, to, deletedPath)) {
      std::pair<int, int> temp = dfs(to, deletedPath);
      temp.first++;
      if (ans.first < temp.first) {
        ans = temp;
      }
    }
  }
  return ans;
}
int Get(int s, std::pair<int, int> deletedPath) {
  std::pair<int, int> ans1 = dfs(s, deletedPath);
  ResetVisited();
  std::pair<int, int> ans2 = dfs(ans1.second, deletedPath);
  ResetVisited();
  return ans2.first;
}
int main() {
  ActivateFastIO();
  int n;
  std::cin >> n;
  for (int i = 1; i < n; ++i) {
    int u, v;
    std::cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int node : g[i]) {
      std::pair<int, int> deletedPath{i, node};
      int ans1 = Get(i, deletedPath);
      int ans2 = Get(node, deletedPath);
      ans = std::max(ans, ans1 * 1ll * ans2);
    }
  }
  std::cout << ans << '\n';
  return 0;
}
