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.
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 *a*<sub class="lower-index">*i*</sub>, *b*<sub class="lower-index">*i*</sub> (1 ≤ *a*<sub class="lower-index">*i*</sub>, *b*<sub class="lower-index">*i*</sub> ≤ *n*).
4
1 2
2 3
3 4
1
7
1 2
1 3
1 4
1 5
1 6
1 7
0
6
1 2
2 3
2 4
5 4
6 4
4
2
2 1
0
3
3 1
1 2
0
3
1 3
2 1
0
4
4 2
2 3
2 1
0
4
2 3
1 3
2 4
1
4
3 2
3 4
1 4
1
5
1 5
5 2
4 2
3 1
2
5
2 4
2 5
1 5
2 3
2
5
1 2
5 1
3 2
3 4
2
5
5 3
3 1
4 1
4 2
2
6
1 2
2 5
4 5
4 6
3 2
4
7
1 6
4 6
5 6
6 7
2 6
3 7
2
8
7 2
7 1
6 7
4 1
7 3
6 8
2 5
4
8
8 6
1 8
7 8
3 1
2 6
5 3
8 4
6
9
8 4
7 8
6 4
8 3
1 4
3 9
5 7
2 5
10
9
4 7
5 4
2 7
5 6
3 7
7 1
9 2
8 3
8
10
7 6
6 8
10 7
5 10
5 3
2 8
4 5
1 7
4 9
12
10
10 7
7 5
10 8
6 5
7 2
9 7
1 10
3 5
4 10
6
15
15 1
15 10
11 1
1 13
10 12
1 8
15 9
14 13
10 2
7 10
5 15
8 4
11 3
6 15
12
15
10 12
12 4
15 12
15 6
5 15
10 1
8 15
13 12
14 6
8 3
11 5
12 7
15 9
2 7
16
15
13 14
10 14
5 10
10 6
9 10
10 7
15 6
8 7
2 6
1 10
3 1
3 11
4 3
14 12
10
30
2 4
14 2
2 3
23 14
30 2
6 14
13 4
24 30
17 30
25 2
26 23
28 3
6 8
23 29
18 25
10 2
25 7
9 26
6 27
13 12
22 3
1 28
11 10
25 20
30 19
16 14
22 5
21 30
15 18
30
50
7 34
5 34
5 11
11 23
42 5
41 11
12 41
41 49
1 49
12 6
7 15
17 42
20 6
17 46
20 19
46 22
46 40
44 40
43 46
22 8
17 29
44 18
31 18
46 9
7 16
32 11
13 41
20 36
34 25
46 28
39 34
30 42
11 47
45 15
37 17
4 23
35 17
17 48
2 17
34 24
1 10
21 5
2 3
50 16
33 5
20 14
26 19
16 27
38 43
88
5
1 2
2 3
3 4
4 5
2
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)