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.util.*;
import java.util.regex.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.lang.Integer.*;
import static java.lang.Double.*;
import static java.util.Collections.*;

import java.awt.Point;
import java.io.*;

public class _14_D_Two_Paths {
	//->solution screencast http://youtu.be/oHg5SJYRHA0
	public void solve() {
		n = ni();
		m=new boolean[n][n];
		ArrayList<Point> roads = new ArrayList<Point>();
//		node root = new node();
		HashMap<Integer,node> map = new HashMap<Integer, _14_D_Two_Paths.node>();
		for (int i = 0; i < n-1; i++) {
			int a=ni()-1,b=ni()-1;
			roads.add(new Point(a,b));
			m[a][b]=m[b][a]=true;
//			if(map.containsKey(a)){
//				node anode=map.get(a);
//				if(map.containsKey(b)){
//					anode.add(map.get(b));
//				}else{
//					node bnode = new node(b);
//					anode.add(bnode);
//				}
//			}else{
//				node anode=new node(a);
//				if(map.containsKey(b)){
//					anode.add(map.get(b));
//				}else{
//					node bnode = new node(b);
//					anode.add(bnode);
//				}				
//			}
		}
//		pr(left);
		int max=0;
		for (int i = 0; i < n-1 ; i++) {
			int a = roads.get(i).x;
			int b = roads.get(i).y;
			m[a][b]=m[b][a]=false;
			ArrayList<Integer> sa = new ArrayList<Integer>();
			boolean [] me = new boolean[n];
//			me[a]=true;
			getNe(a,me,sa);
			int dp[][]=new int[n+1][n+1];
			for (int j = 0; j < dp.length; j++) {
				fill(dp[j],-1);
			}
			
			int maxa=0;
			for (int j = 0; j < sa.size(); j++) {
				maxa=max(maxa,go(n,sa.get(j),dp,new boolean[n]));
			}
			ArrayList<Integer> sb = new ArrayList<Integer>();
			me = new boolean[n];
//			me[b]=true;
			getNe(b,me,sb);
			
			int maxb=0;
			dp=new int[n+1][n+1];
			for (int j = 0; j < dp.length; j++) {
				fill(dp[j],-1);
			}
			for (int j = 0; j < sb.size(); j++) {
				maxb=max(maxb,go(n,sb.get(j),dp,new boolean[n]));
			}
			pr(sa,sb);
			pr(maxa,maxb);
//			pr();
			max=max(max,maxa*maxb);
			m[a][b]=m[b][a]=true;
		}
		out.println(max);
	}
	boolean [][]m;
	int []left;
	int []right;
	int n;
	
	void getNe(int i, boolean vis[], ArrayList<Integer> s){
		s.add(i);
		vis[i]=true;
		for (int j = 0; j < m.length; j++) {
				if(j!=i && m[i][j] && !vis[j] ){
//					vis[j]=true;
//					s.add(j);
					getNe(j, vis, s);
				}
		}
	}
	
	int go(int k, int i,  int [][] dp,boolean memo[]){
		memo[i]=true;
		if(dp[k][i]!=-1)
			return dp[k][i];
		int r=0;
		for (int j= 0; j < n; j++) {
			if(j!=i && m[i][j] && !memo[j]){
//				memo[i][j]=true;
				r = max(r,1+go(i,j,dp,memo));
			}
		}
		return dp[k][i]=r;
	}
	
	class node{
		public node(int n) {
			this.idx=n;
		}
		int idx;
		Set<node> neis=new  HashSet<_14_D_Two_Paths.node>();
		void add(node n){
			neis.add(n);
		}
		
		@Override
		public boolean equals(Object obj) {
			node b = (node)obj;
			return idx==b.idx;
		}
	}
	
	
	// IO methods
		
	void run() throws Exception {
		long s = System.currentTimeMillis();
		solve();
		out.flush();
		pr(System.currentTimeMillis() - s + "ms");
	}
	public static void main(String[] args) throws Exception {new _14_D_Two_Paths().run();}

	InputStream in=System.in;
	PrintWriter out=new PrintWriter(System.out);
	
	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private byte[] inbuf = new byte[1024];
	private int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = in.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {return !(c >= 33 && c <= 126);}
	private int skip() {int b;while ((b = readByte()) != -1 && isSpaceChar(b));return b;}

	public String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != // ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	
	public char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}
	
	public char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}
	
	public int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	
	
	public int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	
	public long nl(){
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}
		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	void pr(Object... ob) {if (!oj)System.out.println(Arrays.deepToString(ob).replace("],", "],\n"));}
}

