As you know, Bob's brother lives in Flatland. In Flatland there are n cities, connected by n - 1 two-way roads. The cities are numbered from 1 to n. You can get from one city to another moving along the roads.

The «Two Paths» company, where Bob's brother works, has won a tender to repair two paths in Flatland. A path is a sequence of different cities, connected sequentially by roads. The company is allowed to choose by itself the paths to repair. The only condition they have to meet is that the two paths shouldn't cross (i.e. shouldn't have common cities).

It is known that the profit, the «Two Paths» company will get, equals the product of the lengths of the two paths. Let's consider the length of each road equals 1, and the length of a path equals the amount of roads in it. Find the maximum possible profit for the company.

Input

The first line contains an integer n (2 ≤ n ≤ 200), where n is the amount of cities in the country. The following n - 1 lines contain the information about the roads. Each line contains a pair of numbers of the cities, connected by the road ai, bi (1 ≤ ai, bi ≤ n).

Output

Output the maximum possible profit.

Examples

Input

4
1 2
2 3
3 4


Output

1


Input

7
1 2
1 3
1 4
1 5
1 6
1 7


Output

0


Input

6
1 2
2 3
2 4
5 4
6 4


Output

4
#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;
}
