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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author sumit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        ArrayList<Integer>[] list;
        int[] parent;
        int[] dist;
        int n;
        ArrayList<Integer> set1;
        ArrayList<Integer> set2;

        void dfs(int i, boolean w) {
            if (w)
                set1.add(i);
            else
                set2.add(i);

            for (int v : list[i]) {
                if (v != parent[i]) {
                    parent[v] = i;
                    dfs(v, w);
                }
            }
        }

        void dfs2(int a) {
            for (int v : list[a]) {
                if (v != parent[a]) {
                    parent[v] = a;
                    dist[v] = dist[a] + 1;
                    dfs2(v);
                }
            }
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {

            int ans = 0;

            n = in.nextInt();
            list = new ArrayList[n];
            pair[] edge = new pair[n - 1];
            for (int i = 0; i < n; i++) list[i] = new ArrayList<>();

            for (int i = 0; i < n - 1; i++) {
                int a = in.nextInt() - 1;
                int b = in.nextInt() - 1;
                list[a].add(b);
                list[b].add(a);
                edge[i] = new pair(a, b);

            }

            pair ans1, ans2;
            ans1 = new pair(-1, -1);
            ans2 = new pair(-1, -1);
            pair ase = new pair(-1, -1);


            for (int i = 0; i < n - 1; i++) {
                int max1 = Integer.MIN_VALUE;
                int max2 = Integer.MIN_VALUE;
                pair p = edge[i];
                int a = p.a;
                int b = p.b;
                parent = new int[n];
                parent[a] = b;
                parent[b] = a;
                dist = new int[n];

                set1 = new ArrayList<>();
                set2 = new ArrayList<>();

                pair e1 = new pair(-1, -1);
                pair e2 = new pair(-1, -1);

                dfs(p.a, true);
                dfs(p.b, false);


//            out.println("The set1 is ");
//            for(int temp:set1)
//                out.print(temp+" ");
//            out.println("\n the set2 is");
//            for(int temp:set2)
//                out.print(temp+" ");
//            out.println();


                for (int j = 0; j < set1.size(); j++) {
                    Arrays.fill(dist, 0);
                    Arrays.fill(parent, -1);
                    parent[a] = b;
                    parent[b] = a;
                    dfs2(set1.get(j));
                    for (int k = 0; k < set1.size(); k++) {
                        if (dist[set1.get(k)] > max1) {
                            max1 = dist[set1.get(k)];
                            e1 = new pair(set1.get(j), set1.get(k));
                        }
                    }

                }


                for (int j = 0; j < set2.size(); j++) {
                    Arrays.fill(dist, 0);
                    Arrays.fill(parent, -1);
                    parent[a] = b;
                    parent[b] = a;
                    dfs2(set2.get(j));
                    for (int k = 0; k < set2.size(); k++) {
                        if (dist[set2.get(k)] > max2) {
                            max2 = dist[set2.get(k)];
                            e2 = new pair(set2.get(j), set2.get(k));
                        }
                    }

                }


                if (max1 * max2 > ans) {

                    ans = max1 * max2;
                    ans1 = e1;
                    ans2 = e2;
                    ase = edge[i];
//
//            out.println("the dist array is ");
//            for(int j=0;j<n;j++)
//                out.print(dist[j]+"  ");
//            out.println();

                }


            }

            System.out.println((ans));


        }

        class pair {
            int a;
            int b;

            pair(int a, int b) {
                this.a = a;
                this.b = b;
            }

        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }


            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c & 15;

                c = read();
            } while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}

