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>
long long shouldendl = 1;
long long INF = (long long)(1e16 + 7);
long long MOD = (long long)(1e9 + 7);
using namespace std;
long long modInverse(long long a) {
  long long m = MOD, m0 = m, y = 0, x = 1;
  if (m == 1) return 0;
  while (a > 1) {
    long long q = a / m, t = m;
    m = a % m, a = t, t = y;
    y = x - q * y, x = t;
  }
  if (x < 0) x += m0;
  return x;
}
long long add(long long a, long long b) {
  return ((a % MOD) + (b % MOD)) % MOD;
}
long long mul(long long a, long long b) {
  return ((a % MOD) * (b % MOD)) % MOD;
}
long long sub(long long a, long long b) {
  long long ans = ((a % MOD - b % MOD)) % MOD;
  if (ans < 0) ans += MOD;
  return ans;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
void MAIN(long long i, long long t);
int get(int f = 2) {
  if (f != 2) return 1;
  long long t;
  cin >> t;
  ;
  return t;
}
template <class T>
int logd(T name) {
  cout << name << endl;
  return 0;
}
void test(int t) {
  for (long long i = 1; i <= t; i++) {
    MAIN(i, t);
    if (shouldendl) cout << "\n";
  }
}
long long power(long long x, long long y) {
  if (y == 0) return 1;
  long long res = 1;
  x = x % MOD;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % MOD;
    y = y >> 1;
    x = (x * x) % MOD;
  }
  return res;
}
template <typename T, typename U>
std::pair<T, U> operator+(const std::pair<T, U> &l, const std::pair<T, U> &r) {
  return {l.first + r.first, l.second + r.second};
}
long long popcnt(long long x) { return __builtin_popcountll(x); }
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
template <class T>
bool input(vector<T> &v, long long n = -1) {
  if (n == -1) assert(v.size() != 0);
  if (n == -1) n = v.size();
  for (auto &i : v) cin >> i;
  return 0;
}
template <class T>
bool print(vector<T> v, long long l = 0, long long r = -1) {
  if (r == -1) r = v.size();
  for (int i = l; i < r; i++) cout << v[i] << " ";
  return 0;
}
map<int, bool> visited;
set<int> v[500];
long long dp[500];
long long dia = 0;
long long dfs(long long i) {
  visited[i] = true;
  vector<long long> temp;
  for (auto j : v[i])
    if (!visited[j]) temp.push_back(dfs(j));
  sort((temp).begin(), (temp).end());
  if (temp.size() == 0) {
    dia = max(1LL, dia);
    return 1;
  }
  if (temp.size() >= 2)
    dia = max(dia, temp.back() + temp[temp.size() - 2]);
  else
    dia = max(dia, temp.back());
  return temp.back() + 1;
}
void MAIN(long long current_test_case, long long total_test_cases) {
  long long n;
  cin >> n;
  vector<pair<int, int> > edges(n - 1);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    edges[i] = make_pair(a, b);
    v[a].insert(b);
    v[b].insert(a);
  }
  long long ans = 0;
  for (int i = 0; i < n - 1; i++) {
    pair<int, int> p = edges[i];
    v[p.first].erase(p.second);
    v[p.second].erase(p.first);
    visited.clear();
    long long sum = 1;
    long long count = 0;
    for (int j = 1; j <= n; j++) {
      if (p.first == j || p.second == j) continue;
      if (visited[j]) continue;
      dia = 0;
      dfs(j);
      count++;
      sum = sum * dia;
    }
    sum = sum * (count - 1);
    ans = max(sum, ans);
    v[p.first].insert(p.second);
    v[p.second].insert(p.first);
  }
  cout << ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  shouldendl = 1;
  test(get(1));
  return 0;
}
