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
def bfs(s):
    dist = [10000] * 205
    dist[s] = 0
    q = [s]
    while q:
        t = q.pop()
        for i in g2[t]:
            if dist[i] == 10000:
                dist[i] = dist[t] + 1
                q = [i] + q
                
    m = -1
    for i in dist:
        if i != 10000:
            m = max(m, i)
    return m
 
def bfs2(s):
    k = []
    dist = [10000] * 205
    dist[s] = 0
    q = [s]
    while q:
        t = q.pop()
        k.append(t)
        for i in g2[t]:
            if dist[i] == 10000:
                dist[i] = dist[t] + 1
                q = [i] + q
                
    return k
 
from copy import deepcopy
# En esta lista vamos a guardar las conexiones entre
#  las ciudades, es decir, las aristas del grafo
e = [] 
# Esta va a ser la lista de adyacencia de nuestro 
# grafo
g = [[] for _ in range(205)]
# Aqui guardamod la cantidad de ciudades, es decir,
#  la cantidad de vertices 
x = int(input())
for i in range(x-1):
    a, b = map(int, input().split())
    # Annadimos los valores a nuestra lista de 
    # adyacencia
    g[a].append(b)
    g[b].append(a)
    # Annadimos las aristas a nuestra lista
    e.append([a,b])
 
# En ans guardamos la respuesta
ans = 0
for i in e:
    #Creamos una copia de nuestra lista de adyacencia 
    g2 = deepcopy(g)
    # En cada iteracion removemos una arista, o sea, 
    # la eliminamos de la copia que hicimos de la 
    # lista de adyacencia
    g2[i[0]].remove(i[1])
    g2[i[1]].remove(i[0])
    # Buscamos todas las ciudades que tenemos en una
    #  componente conexa
    a1 = bfs2(i[0])
    # Buscamos todas las ciudades que tenemos en la 
    # otra componente conexa
    a2 = bfs2(i[1])
    
    m1 = 0
    m2 = 0
    # Hallamos el diametro de la primera componente 
    # conexa
    for e in a1:
        m1 = max(m1, bfs(e))
 
    # Hallamos el diametro de la segunda componente
    #  conexa
    for e in a2:
        m2 = max(m2, bfs(e))
 
    # Actualizamos nuestro beneficio
    ans = max(ans, m1*m2)

 # Pintamos la respuesta
print(ans)