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.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class D {
	static String[] dictionary;
	static char[] encryptToClear;
	static String[] sentence;

	static ArrayList<String> allPossible(String s) {
		ArrayList<String> res = new ArrayList<>();
		for (int i = 0; i < dictionary.length; i++) {
			if (dictionary[i].length() != s.length())
				continue;
			String s2 = dictionary[i];
			boolean correct = true;
			for (int j = 0; j < s2.length(); j++) {
				if (s.charAt(j) == '?')
					continue;
				if (s.charAt(j) != s2.charAt(j)) {
					correct = false;
					break;
				}

			}
			if (correct)
				res.add(s2);
		}
		return res;
	}

	static boolean Decrypted(int i) {
		if (i >= sentence.length)
			return true;
		String s = "";
		String s2 = sentence[i];
		for (int j = 0; j < s2.length(); j++) {
			if (encryptToClear[s2.charAt(j) - 'a'] == '0')
				s += "?";
			else
				s += encryptToClear[s2.charAt(j) - 'a'];
		}
		ArrayList<String> res = allPossible(s);
		for (int j = 0; j < res.size(); j++) {
			for (int k = 0; k < s2.length(); k++) {
				if (s.charAt(k) == '?')
					encryptToClear[s2.charAt(k) - 'a'] = res.get(j).charAt(k);
			}
			if (Decrypted(i + 1))
				return true;
			for (int k = 0; k < s.length(); k++) {
				if (s.charAt(k) == '?')
					encryptToClear[s2.charAt(k) - 'a'] = '0';
			}

		}
		return false;
	}

	static class pair implements Comparable<pair> {
		int u;
		int cost;

		public pair(int uu, int c) {
			u = uu;
			cost = c;
		}

		@Override
		public int compareTo(pair o) {
			// TODO Auto-generated method stub
			return cost - o.cost;
		}
	}

	static ArrayList<Integer>[] tree;
	static int n;

	static int[] mark;

	public static void main(String[] args) throws IOException {
		// BufferedReader br = new BufferedReader(new FileReader("name.in"));
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;
		PrintWriter out = new PrintWriter(System.out);
		n = Integer.parseInt(br.readLine());
		tree = new ArrayList[n];
		for (int i = 0; i < tree.length; i++) {
			tree[i] = new ArrayList<>();
		}
		pair[] p = new pair[n - 1];
		for (int i = 0; i < n - 1; i++) {
			st = new StringTokenizer(br.readLine());
			int u = Integer.parseInt(st.nextToken()) - 1;
			int v = Integer.parseInt(st.nextToken()) - 1;
			tree[u].add(v);
			tree[v].add(u);
			p[i] = new pair(u, v);
		}
		int max=0;
		for (int i = 0; i < p.length; i++) {
			pair t = p[i];
			vis = new boolean[n];
			tree[t.u].remove((Object) t.cost);
			tree[t.cost].remove((Object) t.u);
			int id1 = -1;
			int id2 = -1;
			for (int j = 0; j < n; j++) {
				if (!vis[j]) {
					dfs(j);
					if (id1 == -1)
						id1 = j;
					else
						id2 = j;
				}
			}
			int d1=diamiter(id1);
			int d2=diamiter(id2);
//			System.out.println(d1+" "+d2);
			max=Math.max(max, d1*d2);
			tree[t.u].add(t.cost);
			tree[t.cost].add(t.u);

		}
		out.println(max);
		out.flush();
		out.close();

	}

	static boolean vis[];

	static void dfs(int u) {
		vis[u] = true;
		for (int v : tree[u]) {
			if (!vis[v]) {
				dfs(v);
			}
		}
	}

	static int diamiter(int u) {
		int f = far(u);
		int f2 = far(f);
		return dist(f, -1, f2);
	}

	static int far(int u) {
		vis = new boolean[n];
		Queue<Integer> q = new LinkedList<Integer>();
		q.add(u);
		vis[u] = true;
		int ans = -1;
		while (!q.isEmpty()) {
			int cur = q.poll();
			ans = cur;
			for (int v : tree[cur]) {
				if (!vis[v]) {
					vis[v] = true;
					q.add(v);
				}
			}
		}
		return ans;
	}

	static int dist(int u, int pa, int e) {
		if (u == e)
			return 0;
		int min = 1000000000;
		for (int v : tree[u]) {
			if (v != pa) {
				min = Math.min(min, 1 + dist(v, u, e));
			}
		}
		return min;
	}

}