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.*;
import static java.lang.Math.*;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Double.parseDouble;
import static java.lang.String.*;

public class Main {
 
    static boolean [] vis;
    static List<Integer> [] g;
    static int leaf,lc;
    
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
                                            //(new FileReader("input.in"));
        StringBuilder out = new StringBuilder();
        StringTokenizer tk;
        Reader.init(System.in);
        //PrintWriter pw = new PrintWriter("output.out", "UTF-8");

        int n = parseInt(in.readLine());
        int i,a,b;
        g = new List[n];
        vis = new boolean[n];
        for(i=0; i<n; i++)
            g[i] = new ArrayList<Integer>();
        
        pair [] e = new pair[n-1];
        
        for(i=1; i<n; i++) {
            tk = new StringTokenizer(in.readLine());
            a = parseInt(tk.nextToken())-1;
            b = parseInt(tk.nextToken())-1;
            
            g[a].add(b);
            g[b].add(a);
            e[i-1] = new pair(a,b);
        }
        
        int ans = 0;
        int j,ta,tb,x,y;
        
        for(i=0; i<n-1; i++) {
            ta = e[i].first;
            tb = e[i].second;
            g[ta].remove(g[ta].indexOf(tb));
            g[tb].remove(g[tb].indexOf(ta));
            Arrays.fill(vis, false);
            
            x = y = -1;
            
            for(j=0; j<n; j++) {
                if(!vis[j]) {
                    if(x==-1) x = FLP(j);
                    else y = FLP(j);
                }
            }
            
            ans = max(ans, x*y);
            
            g[ta].add(tb);
            g[tb].add(ta);
        }
        
        System.out.println(ans);
    }
    
    static int FLP(int u) {
        leaf = lc = -1;
        DFS(u,-1,0);
        lc = -1;
        DFS(leaf,-1,0);
        return lc;
    }
    
    static void DFS(int u,int p,int c) {
        vis[u] = true;
        if(c > lc) {
            leaf = u;
            lc = c;
        }
        
        for(int v : g[u]) {
            if(v != p)
                DFS(v,u,c+1);
        }
    }
}

class pair {
    int first,second;
    
    public pair(int f,int s) {
        this.first = f;
        this.second = s;
    }
}

class Tools {
    
    public static boolean[] seive(int n) {
        boolean [] isPrime = new boolean[n+1];
        Arrays.fill(isPrime, true);
        
        for(int i=2; i*i<=n; i++)
            if(isPrime[i])
                for(int j=i; i*j<=n; j++)
                    isPrime[i*j] = false;
        
        isPrime[1] = false;
        
        return isPrime;
    }
    
    public static boolean next_permutation(int[] p, int len) {
        int a = len - 2;
        while (a >= 0 && p[a] >= p[a + 1]) {
            a--;
        }

        if (a == -1) {
            return false;
        }

        int b = len - 1;
        while (p[b] <= p[a]) {
            b--;
        }

        p[a] += p[b];
        p[b] = p[a] - p[b];
        p[a] -= p[b];

        for (int i = a + 1, j = len - 1; i < j; i++, j--) {
            p[i] += p[j];
            p[j] = p[i] - p[j];
            p[i] -= p[j];
        }

        return true;
    }
    
    public static int lower_bound(Comparable[] arr, Comparable key) {
        int len = arr.length;
        int lo = 0;
        int hi = len-1;
        int mid = (lo + hi)/2;
        while (true) {
            int cmp = arr[mid].compareTo(key);
            if (cmp == 0 || cmp > 0) {
                hi = mid-1;
                if (hi < lo)
                    return mid;
            } else {
                lo = mid+1;
                if (hi < lo)
                    return mid<len-1?mid+1:-1;
            }
            mid = (lo + hi)/2;
        }
    }

    public static int upper_bound(Comparable[] arr, Comparable key) {
        int len = arr.length;
        int lo = 0;
        int hi = len-1;
        int mid = (lo + hi)/2;
        while (true) {
            int cmp = arr[mid].compareTo(key);
            if (cmp == 0 || cmp < 0) {
                lo = mid+1;
                if (hi < lo)
                    return mid<len-1?mid+1:-1;
            } else {
                hi = mid-1;
                if (hi < lo)
                    return mid;
            }
            mid = (lo + hi)/2;
        }
    }
    
    public static int toDecimal(String s,int b) {
        int ans = 0;
        
        for(int i=0,j=s.length()-1; i<s.length(); i++,j--) {
            char c = s.charAt(i);
            int x = (c>='0' && c<='9' ? c-'0' : c-'A'+10);
            if(x>=b) return -1;
            ans += (c>='0' && c<='9' ? c-'0' : c-'A'+10)*(int)pow(b,j);
        }
        
        return ans;
    }
}

class Reader {

    static BufferedReader reader;
    static StringTokenizer tokenizer;

    static void init(InputStream input) throws UnsupportedEncodingException {
        reader = new BufferedReader(
                new InputStreamReader(input, "UTF-8"));
        tokenizer = new StringTokenizer("");
    }

    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine());
        }
        return tokenizer.nextToken();
    }

    static String nextLine() throws IOException {
        return reader.readLine();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
}