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.IOException; 
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*; 

public class Main 
{ 	


    public final static int OO = Integer.MAX_VALUE;
    private static Reader r; 	


	public static void main(String[] args)throws Exception 	 	
	{ 	 		
		r = new Reader(); 	 

		r.readLine();
		int n = r.readInt(0);

		List<List<Integer>> graph = new ArrayList<>();

		for (int i=0;i <= n;++i)
			graph.add(new ArrayList<Integer>());

		List<Pair> edges = new ArrayList<>();

		for (int i=1;i < n;++i)
		{
			r.readLine();
			int f = r.readInt(0);
			int t = r.readInt(1);
			graph.get(f).add(t);
			graph.get(t).add(f);

			edges.add(new Pair(f, t));
		}

		int res = 0;
		for (int i=0;i < edges.size();++i)
		{
			int cc = 0;
			int f = -1;
			int s = -1;
			boolean flag[] = new boolean[n + 1];

			Pair rPath = edges.get(i);

			for (int j=1;j <= n;++j)
			{
				if (!flag[j])
				{
					if (cc == 2)
					{
						++cc;
						break;
					}

					if (cc == 0)
						f = j;

					if (cc == 1)
						s = j;

					dfs(j, flag, graph, rPath);
					++cc;
				}
			}

			if (cc == 2)
			{
				res = Math.max(res, bfs(graph, f, rPath) * bfs(graph, s, rPath));
			}

		}

		System.out.println(res);

		r.close(); 	
	}

	private static void dfs(int v, boolean []flag, List<List<Integer>> graph, Pair removedPath)
	{
		flag[v] = true;

		for (int u:graph.get(v))
		{
			if (!flag[u] && !((Math.max(u, v) == Math.max(removedPath.f, removedPath.s) && Math.min(u, v) == Math.min(removedPath.f, removedPath.s))))
			{
				dfs(u, flag, graph, removedPath);
			}
		}

	}

	private static int bfs(List<List<Integer>> graph, int v, Pair removedPath)
	{
		Queue<Integer> queue = new LinkedList<>();

		queue.add(v);

		boolean flag[] = new boolean[graph.size()];

		while (!queue.isEmpty())
		{
			v = queue.poll();

			flag[v] = true;

			for (int u:graph.get(v))
				if (!flag[u] && !((Math.max(v, u) == Math.max(removedPath.f, removedPath.s) && Math.min(u, v) == Math.min(removedPath.f, removedPath.s))))
				{
					queue.add(u);
				}
		}
		
		Queue<Pair> level = new LinkedList<>();

		boolean []isV = new boolean[graph.size()];

		Pair p = new Pair(v, 0);
		level.add(p);

		while (!level.isEmpty())
		{
			p = level.poll();
			isV[p.f] = true;
			v = p.f;
			
			
			for (int u:graph.get(v))
				if (!isV[u] && !((Math.max(v, u) == Math.max(removedPath.f, removedPath.s) && Math.min(u, v) == Math.min(removedPath.f, removedPath.s))))
				{
					level.add(new Pair(u, p.s + 1));
				}
		}

		
		return p.s;
	}

} 


class Pair implements Comparable<Pair>
{ 	
	int f,s; 	
	public Pair() 	
	{} 
	public Pair(int f, int s) 	
	{ 	
		this.f = f; 	
		this.s = s; 	
	} 

	@Override 	
	public String toString() 
	{ 		
		return f + " " + s; 	
	} 	

	@Override 	
	public int compareTo(Pair o) 	
	{ 		
		if (f == o.f) 			
			return s - o.s; 		
		return f - o.f; 	
	} 
}

class Reader
{ 	
	private BufferedReader reader; 
	private String line[]; 	

	public Reader() 	
	{ 		
		reader = new BufferedReader(new InputStreamReader(System.in)); 	
	} 	

	public String[] getLine() 	
	{ 		
		return line; 	
	} 	

	public void readLine() 	throws IOException 
	{ 		
		line = reader.readLine().split(" "); 	
	} 	

	public List<Integer> getIntegersList()
	{
		List<Integer> res = new ArrayList<>();
		for (String str:line)
			res.add(Integer.parseInt(str));
		return res;

	}

	public int readInt(int pos)throws IOException 	
	{ 		
		return Integer.parseInt(line[pos]); 	
	} 	

	public double readDouble(int pos)throws IOException 	
	{ 		
		return Double.parseDouble(line[pos]); 	
	} 	

	public long readLong(int pos)throws IOException 
	{ 		
		return Long.parseLong(line[pos]); 
	} 	

	public String readString(int pos)throws IOException 	
	{ 		
		return line[pos]; 	
	} 	

	public void close()throws IOException 
	{ 		
		reader.close(); 	
	}

}

class Vertix implements Comparable<Vertix>
{
	int to,w;

	public Vertix(int to, int w)
	{
		this.to = to;
		this.w = w;
	}

	@Override
	public int compareTo(Vertix p1)
	{
		return w - p1.w;
	}

}

class Dijkstra
{
	boolean isDirected;
	int n;
	List<List<Vertix>> adjList;
	int distance[];
	int parent[];
	boolean visited[];

	Dijkstra(int n, boolean isDirected)
	{
		this.isDirected = isDirected;
		this.n = n;
		adjList = new ArrayList<>();
		distance = new int[n + 1];
		parent = new int[n + 1];
		visited = new boolean[n + 1];

		for (int i=0;i <= n;++i)
		{
			adjList.add(new ArrayList<Vertix>());
			distance[i] = Main.OO;
			parent[i] = -1;

		}

	}

	void addEdge(int fr, int to, int w)
	{
		adjList.get(fr).add(new Vertix(to, w));

		if (!isDirected)
			adjList.get(to).add(new Vertix(fr, w));

	}

	Stack<Integer> getShortestPath(int src, int dis)
	{
		PriorityQueue<Vertix> queue = new PriorityQueue<>();

		distance[src] = 0;
		queue.add(new Vertix(src, 0));

		while (!queue.isEmpty())
		{
			Vertix v = queue.poll();
			int to = v.to;

			if (visited[to])
				continue;

			if (to == dis)
			{

				Stack<Integer> res = new Stack<>();

				res.add(dis);

				for (int c=parent[dis];c != src;c = parent[c])
					res.add(c);

				res.add(src);

				return res;
			}

			visited[to] = true;

			for (Vertix vv:adjList.get(to))
			{
				if (!visited[vv.to] && distance[vv.to] > distance[to] + vv.w)
				{
					distance[vv.to] = distance[to] + vv.w;
					parent[vv.to] = to;
					queue.add(new Vertix(vv.to, distance[vv.to]));
				}
			}
		}
		return null;

	}

}



