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
N=int(input())

E=[[] for i in range(N)]

for i in range(N-1):
    a,b=map(int,input().split())
    a-=1
    b-=1
    E[a].append(b)
    E[b].append(a)

# 木のHL分解+LCA

ROOT=0
N+=1 # ROOTの親の点を一つ余計に見るため、総ノード数を一つ増やしておく

QUE=[ROOT] 
Parent=[-1]*(N+1)
Parent[ROOT]=N # ROOTの親を定めておく.
TOP_SORT=[] # トポロジカルソート

while QUE: # トポロジカルソートと同時に親を見つける
    x=QUE.pop()
    TOP_SORT.append(x)
    for to in E[x]:
        if Parent[to]==-1:
            Parent[to]=x
            QUE.append(to)

Children=[1]*(N+1)

for x in TOP_SORT[::-1]: #（自分を含む）子ノードの数を調べる
    Children[Parent[x]]+=Children[x]

USE=[0]*N
Group=[i for i in range(N)]

for x in TOP_SORT: # HL分解によるグループ分け
    USE[x]=1
    MAX_children=0
    select_node=0

    for to in E[x]:
        if USE[to]==0 and Children[to]>MAX_children:
            select_node=to
            MAX_children=Children[to]

    for to in E[x]:
        if USE[to]==0 and to==select_node:
            Group[to]=Group[x]

def LCA(a,b): # HL分解を利用してLCAを求める
    while Group[a]!=Group[b]:
        if Children[Parent[Group[a]]]<Children[Parent[Group[b]]]:
            a=Parent[Group[a]]
        else:
            b=Parent[Group[b]]

    if Children[a]>Children[b]:
        return a
    else:
        return b

def allpoint(x,y):
    l=LCA(x,y)
    ANS=[l]

    while x!=l:
        ANS.append(x)
        x=Parent[x]

    while y!=l:
        ANS.append(y)
        y=Parent[y]

    return set(ANS)

ANS=0
for i in range(N-1):
    for j in range(i+1,N-1):
        X=allpoint(i,j)

        other=set(range(N-1))-X

        for k in other:
            for l in other:
                Y=allpoint(k,l)

                if X & Y ==set():
                    ANS=max(ANS,(len(X)-1)*(len(Y)-1))

print(ANS)
