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
/**
 * @author Anil Kishore, IIIT-Hyderabad
 * May, 2010
 */

import java.io.*;
import java.util.*;
import java.util.ArrayList;
import static java.lang.Math.*;

public class CF14_D
{
    BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter stdout = new PrintWriter(new OutputStreamWriter(System.out));
    StringTokenizer st;
    StringBuilder sb = new StringBuilder();

    ArrayList< ArrayList<Integer> > edges = new ArrayList<ArrayList<Integer>>();

    boolean[] vis = new boolean[205];

    int getMaxPathLength(int sn, int N)
    {
        boolean[] v = new boolean[N+1];
        for(int i=1;i<=N;i++) v[i]=vis[i];

        int last = sn, maxd = 0;

        Queue<Integer> Q = new LinkedList<Integer>();
        Q.add(sn); v[sn]=true;
        while(!Q.isEmpty())
        {
            int cn = Q.remove(); last = cn;
            for(int nn:edges.get(cn)) if(!v[nn]){ v[nn]=true; Q.add(nn); }
        }

        Q.add(last); vis[last]=true;
        for(maxd=0;!Q.isEmpty();)
        {
            int curSize = Q.size();
            while(curSize-->0)
            {
                int cn = Q.remove();
                for(int nn:edges.get(cn)) if(!vis[nn]){ vis[nn]=true; Q.add(nn); }
            }

            if(!Q.isEmpty()) maxd++;
        }

        return maxd;
    }

    void solve() throws IOException
    {
        int N = INT();
        edges.add(new ArrayList<Integer>());
        for(int i=1;i<=N;i++) edges.add(new ArrayList<Integer>());
        int[] from = new int[N], to = new int[N];

        for(int i=1;i<N;i++)
        {
            int a = INT(), b = INT();
            from[i] = a; to[i] = b;
            edges.get(a).add(b);
            edges.get(b).add(a);
        }

        int ret = 0;
        for(int i=1;i<N;i++)
        {
            int a = from[i], b = to[i];
            edges.get(a).remove(new Integer(b));
            edges.get(b).remove(new Integer(a));

            Arrays.fill(vis,false);
            ArrayList<Integer> maxLenghts = new ArrayList<Integer>();
            for(int j=1;j<=N;j++)
            {
                if(!vis[j])
                {
                    int len = getMaxPathLength(j,N);
                    if(len>0) maxLenghts.add(len);
                }
            }

            if(maxLenghts.size()>1)
            {
                Collections.sort(maxLenghts);
                int s = maxLenghts.size(), x = maxLenghts.get(s-1)*maxLenghts.get(s-2);
                //System.out.print(a+"<---->"+b+"  :: ");
                //for(int y:maxLenghts) System.out.print(y+" ");
                //System.out.println("");
                ret = max( ret , x);
            }

            edges.get(a).add(b);
            edges.get(b).add(a);
        }

        stdout.println(ret);

        stdin.close();
        stdout.flush();
        stdout.close();
    }

    final int INT() throws IOException
    {
        return Integer.parseInt(TOK());
    }

    final String TOK() throws IOException
    {
        if(st==null || !st.hasMoreTokens()) st = new StringTokenizer(stdin.readLine());
        return st.nextToken();
    }

    public static void main(String[] args) throws IOException
    {
        (new CF14_D()).solve();
    }
}