#include <bits/stdc++.h>
using namespace std;
template <typename T, typename T1>
ostream &operator<<(ostream &out, pair<T, T1> obj) {
  out << "(" << obj.first << "," << obj.second << ")";
  return out;
}
template <typename T, typename T1>
ostream &operator<<(ostream &out, map<T, T1> cont) {
  typename map<T, T1>::const_iterator itr = cont.begin();
  typename map<T, T1>::const_iterator ends = cont.end();
  for (; itr != ends; ++itr) out << *itr << " ";
  out << endl;
  return out;
}
template <typename T>
ostream &operator<<(ostream &out, set<T> cont) {
  typename set<T>::const_iterator itr = cont.begin();
  typename set<T>::const_iterator ends = cont.end();
  for (; itr != ends; ++itr) out << *itr << " ";
  out << endl;
  return out;
}
template <typename T>
ostream &operator<<(ostream &out, multiset<T> cont) {
  typename multiset<T>::const_iterator itr = cont.begin();
  typename multiset<T>::const_iterator ends = cont.end();
  for (; itr != ends; ++itr) out << *itr << " ";
  out << endl;
  return out;
}
template <typename T,
          template <typename ELEM, typename ALLOC = allocator<ELEM>> class CONT>
ostream &operator<<(ostream &out, CONT<T> cont) {
  typename CONT<T>::const_iterator itr = cont.begin();
  typename CONT<T>::const_iterator ends = cont.end();
  for (; itr != ends; ++itr) out << *itr << " ";
  out << endl;
  return out;
}
template <typename T, unsigned int N, typename CTy, typename CTr>
typename enable_if<!is_same<T, char>::value, basic_ostream<CTy, CTr> &>::type
operator<<(basic_ostream<CTy, CTr> &out, const T (&arr)[N]) {
  for (auto i = 0; i < N; ++i) out << arr[i] << " ";
  out << endl;
  return out;
}
template <typename T>
T gcd(T a, T b) {
  T min_v = min(a, b);
  T max_v = max(a, b);
  while (min_v) {
    T temp = max_v % min_v;
    max_v = min_v;
    min_v = temp;
  }
  return max_v;
}
template <typename T>
T lcm(T a, T b) {
  return (a * b) / gcd(a, b);
}
template <typename T>
T fast_exp_pow(T base, T exp, T mod) {
  long long res = 1;
  while (exp) {
    if (exp & 1) {
      res *= base;
      res %= mod;
    }
    exp >>= 1;
    base *= base;
    base %= mod;
  }
  return res % mod;
}
int N, A, B, long_dist, long_node, answer;
vector<int> graph[210];
vector<pair<int, int>> road;
void create_semi_graph(vector<int> semi_graph[210][210], int node, int par,
                       int cnt) {
  for (auto conn_node : graph[node]) {
    if (conn_node != par) {
      semi_graph[cnt][conn_node].push_back(node);
      semi_graph[cnt][node].push_back(conn_node);
      create_semi_graph(semi_graph, conn_node, node, cnt);
    }
  }
}
void longest_path(vector<int> semi_graph[210][210], int cnt, int node, int par,
                  int dist) {
  if (dist > long_dist) {
    long_dist = dist;
    long_node = node;
  }
  for (auto conn_node : semi_graph[cnt][node]) {
    if (conn_node != par)
      longest_path(semi_graph, cnt, conn_node, node, dist + 1);
  }
}
int find_diameter(vector<int> semi_graph[210][210], int cnt, int node) {
  long_dist = 0, long_node = 0;
  longest_path(semi_graph, cnt, node, 0, 0);
  long_dist = 0;
  longest_path(semi_graph, cnt, long_node, 0, 0);
  return long_dist;
}
void solve(int node_1, int node_2) {
  vector<int> semi_graph[2][210];
  int mx_1 = 0, mx_2 = 0;
  create_semi_graph(semi_graph, node_1, node_2, 0);
  create_semi_graph(semi_graph, node_2, node_1, 1);
  for (auto i = 0; i < 2; ++i) {
    int node = (!i ? node_1 : node_2);
    int ret = find_diameter(semi_graph, i, node);
    if (ret > mx_1) {
      mx_2 = mx_1;
      mx_1 = ret;
    } else if (ret > mx_2)
      mx_2 = ret;
  }
  answer = max(answer, mx_1 * mx_2);
}
int main() {
  scanf("%d", &N);
  for (auto i = 0; i < N - 1; ++i) {
    scanf("%d%d", &A, &B);
    graph[A].push_back(B);
    graph[B].push_back(A);
    road.emplace_back(A, B);
  }
  for (auto elem : road) solve(elem.first, elem.second);
  printf("%d\n", answer);
  return 0;
}
