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
import java.io.*;
import java.util.*;
import java.math.*;

public class Main implements Runnable {
  static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
  static StringTokenizer st = new StringTokenizer("");

  public static String next() {
    try {
    while (!st.hasMoreTokens()) {
      String s = br.readLine();
      if (s == null)
        return null;
      st = new StringTokenizer(s);
    }
    return st.nextToken();
    } catch(Exception e)  {
      return  null;
    }
  }

  public static void main(String[] asda) throws Exception {
    new Thread(null, new Main(), "Main", 1<<26).start();
  }

  public void run() {
    int N = Integer.parseInt( next() );
    g = new ArrayList[N];
    for (int k = 0; k < g.length; k++) {
      g[k] = new ArrayList<>();
      g[k].add( new Edge(-1, -1) );
    }
    empty = new Info();
    empty.deepestPath[0] = empty.deepestPath[1] = -1;
    for (int k = 1; k < N; k++) {
      int u = Integer.parseInt( next() ) - 1;
      int v = Integer.parseInt( next() ) - 1;
      g[u].add( new Edge(v, g[v].size()) );
      g[v].add( new Edge(u, g[u].size() - 1) );
    }

    dp = new Info[N][3][];
    for (int k = 0; k < N; k++) for (int m = 0; m < 3; m++) {
      dp[k][m] = new Info[ g[k].size() ];
      for (int p = 0; p < g[k].size(); p++) {
        dp[k][m][p] = new Info();
        dp[k][m][p].longestPath = -1;
      }
    }

    long ans = 0;
    level = 0;
    for (int vertex = 0; vertex < N; vertex++) for (int index = 1; index < g[vertex].size(); index++) {
      long x = dfs(vertex, index, 0).longestPath;
      long y = dfs( g[vertex].get(index).vertex, g[vertex].get(index).index, 0 ).longestPath;
   //   out.printf("remove (%d, %d) = (%d, %d)\n\n", vertex+1, g[vertex].get(index).vertex+1, x, y);
      ans = Math.max(ans, x*y);
    }
    out.println(ans);
    //
    out.flush();
    System.exit(0);
  }

  List<Edge>[] g;
  Info[][][] dp;
  Info empty;
  int level;
  Info dfs(int vertex, int index, int d)  {
    if ( d != 0 && (index <= 0 || index >= g[vertex].size()) )
      return empty;

 //   for (int k = 0; k < level; k++) out.print(" ");
 //   out.printf("dfs(%d, %d, %d)\n", vertex+1, g[vertex].get(index).vertex+1, d);
    if (dp[vertex][d + 1][index].longestPath != -1) {
      return dp[vertex][d + 1][index];
    }
    level++;
    Info answer = dp[vertex][d + 1][index];
    Info p1 = empty;
    Info p2 = empty;
    if (d != 0) {
      p1 = dfs( g[vertex].get(index).vertex, g[vertex].get(index).index, 0);
      p2 = dfs( vertex, index + d, d );
    } else  {
      p1 = dfs(vertex, index - 1, -1);
      p2 = dfs(vertex, index + 1, +1);
    }

    int[] deep = {
      p1.deepestPath[0], p1.deepestPath[1],
      p2.deepestPath[0], p2.deepestPath[1]
    };
    Arrays.sort(deep);
 //   out.println(Arrays.toString(deep));
    answer.longestPath = Math.max(p1.longestPath, p2.longestPath);
    answer.deepestPath[0] = deep[3];
    answer.deepestPath[1] = deep[2];
    if (d == 0) {
      answer.longestPath = Math.max( answer.longestPath, answer.deepestPath[0] + answer.deepestPath[1] + 2 );
      answer.deepestPath[0]++;
      answer.deepestPath[1] = -1;
    }

    level--;
    return answer;
  }
}

class Info {
  int longestPath = 0;
  int[] deepestPath = { 0, 0 };
}
class Edge {
  int vertex; // destiny of this edge
  int index; // g[to][index] = from
  Edge(int u, int v)  {
    this.vertex = u;
    this.index = v;
  }
}