This Christmas Santa gave Masha a magic picture and a pencil. The picture consists of n points connected by m segments (they might cross in any way, that doesn't matter). No two segments connect the same pair of points, and no segment connects the point to itself. Masha wants to color some segments in order paint a hedgehog. In Mashas mind every hedgehog consists of a tail and some spines. She wants to paint the tail that satisfies the following conditions:   Only segments already presented on the picture can be painted;  The tail should be continuous, i.e. consists of some sequence of points, such that every two neighbouring points are connected by a colored segment;  The numbers of points from the beginning of the tail to the end should strictly increase. 

Masha defines the length of the tail as the number of points in it. Also, she wants to paint some spines. To do so, Masha will paint all the segments, such that one of their ends is the endpoint of the tail. Masha defines the beauty of a hedgehog as the length of the tail multiplied by the number of spines. Masha wants to color the most beautiful hedgehog. Help her calculate what result she may hope to get.

Note that according to Masha's definition of a hedgehog, one segment may simultaneously serve as a spine and a part of the tail (she is a little girl after all). Take a look at the picture for further clarifications.


-----Input-----

First line of the input contains two integers n and m(2 ≤ n ≤ 100 000, 1 ≤ m ≤ 200 000) — the number of points and the number segments on the picture respectively. 

Then follow m lines, each containing two integers u_{i} and v_{i} (1 ≤ u_{i}, v_{i} ≤ n, u_{i} ≠ v_{i}) — the numbers of points connected by corresponding segment. It's guaranteed that no two segments connect the same pair of points.


-----Output-----

Print the maximum possible value of the hedgehog's beauty.


-----Examples-----
Input
8 6
4 5
3 5
2 5
1 2
2 8
6 7

Output
9

Input
4 6
1 2
1 3
1 4
2 3
2 4
3 4

Output
12



-----Note-----

The picture below corresponds to the first sample. Segments that form the hedgehog are painted red. The tail consists of a sequence of points with numbers 1, 2 and 5. The following segments are spines: (2, 5), (3, 5) and (4, 5). Therefore, the beauty of the hedgehog is equal to 3·3 = 9.

[Image]

Difficulty: interview

Starter code:

Solutions:
n, m = list(map(int, input().split()))
p = [0] * n
e = []
for i in range(m):
    q, w = list(map(int, input().split()))
    p[w - 1] += 1
    p[q - 1] += 1
    e.append([min(q, w), max(q, w)])
dp = [1] * n
e.sort()
for i in range(m):
    dp[e[i][1] - 1] = max(dp[e[i][1] - 1], dp[e[i][0] - 1] + 1)
ans = 0
for i in range(n):
    ans = max(ans, dp[i] * p[i])
print(ans)


n, m = list(map(int, input().split()))

edges = []
max_lens = []
for i in range(n+1):
    edges.append(set())
    max_lens.append(1)
    
for i in range(m):
    u, v = list(map(int, input().split()))
    edges[u].add(v)
    edges[v].add(u)


maximum = 0
for i in range(1, n+1):

    for j in edges[i]:
        if j < i:
            max_lens[i] = max(max_lens[i], max_lens[j] + 1)


    maximum = max(len(edges[i]) * max_lens[i], maximum)

print(maximum)
        
        
    
    

    





n, m = [int(x) for x in input().split()]

values = [1] * n
nodes = [list() for _ in range(n)]
spikes = [0] * n

for _ in range(m):
    n1, n2 = [int(x) for x in input().split()]
    if n1 > n2:
        n1, n2 = n2, n1
    nodes[n1-1].append(n2-1)
    spikes[n1-1] += 1
    spikes[n2-1] += 1

for i in range(0, n):
    for node in nodes[i]:
        values[node] = max(values[node], values[i] + 1)

m = max(list(range(n)), key=lambda i: spikes[i] * values[i])
print(spikes[m] * values[m])


n, m = list(map(int, input().split()))

G = [list() for i in range(n + 1)]
colored = [False] * (n + 1)
hhog_tail = [1] * (n + 1)
spine_count = [0] * (n + 1)

def find_best_hhog_tail(z):
	if colored[z]: return
	colored[z] = True
	for y in G[z]: 
		if not colored[y]:
			find_best_hhog_tail(y)
		hhog_tail[z] = max(hhog_tail[z], 1 + hhog_tail[y])

for i in range(m):
	u, v = list(map(int, input().split()))
	G[u].append(v) if u > v else G[v].append(u)
	spine_count[u] += 1
	spine_count[v] += 1

for i in range(1, n+ 1):
	find_best_hhog_tail(i)

print(max([spine_count[i] * hhog_tail[i] for i in range(1, n+1)]))


import sys


def dfs(v):
    nonlocal g, links, used, tail, val
    used[v] = True

    maxv = 1
    for u in g[v]:
        if not used[u]:
            # maxv = max(maxv, dfs(u) + 1)    -  было used вместо not used в условии
            dfs(u)
        maxv = max(maxv, tail[u] + 1)
    val[v] = links[v] * maxv
    tail[v] = maxv
    # return maxv


# fin = open("cfr338b.in", "r")
fin = sys.stdin

n, m = map(int, fin.readline().split())

g = [[] for i in range(n)]
links = [0] * n

for i in range(m):
    u, v = map(int, fin.readline().split())
    u, v = (u - 1, v - 1) if u <= v else (v - 1, u - 1)
    # g[u].append(v)
    g[v].append(u)
    links[v] += 1
    links[u] += 1

used = [False] * n
val, tail = [0] * n, [0] * n
maxv = 0

for i in range(n):
    if not used[i]:
        dfs(i)
    maxv = max(maxv, val[i])

print(maxv)

import sys

l=0
ady = [[]]
ady2 = [[]]
for line in sys.stdin:
	if l==0:
		n,m = line.split()
		n = int(n)
		m = int(m)
		ady = [[] for i in range(n)]
		ady2 = [[] for i in range(n)]
	else:
		a,b = list(map(int,line.split())) 
		a = int(a)-1
		b = int(b)-1
		ady2[a].append(b)
		ady2[b].append(a)
		if a>b: ady[a].append(b)
		else: ady[b].append(a)
	l+=1

c=[0]*n

def colamaslarga(a):
	if (len(ady[a])==0):
		c[a]=1
		return 1
	elif c[a]!=0:
		return c[a]
	else:
		res=max([colamaslarga(ad) for ad in ady[a]])+1
		c[a]=res
		return res

mx = 0
for i in range(n):
	cl = colamaslarga(i)
	res = cl*len(ady2[i])
	if res>mx: mx=res

print (mx)


import sys
if False:
	inp = open('B.txt', 'r')
else:
	inp = sys.stdin
data = [[] for i in range(100009)]
spines = [0 for i in range(100009)]
dp = [1 for i in range(100009)]
n, m = list(map(int, inp.readline().split()))
for i in range(m):
	a, b = list(map(int, inp.readline().split()))
	if a < b:
		data[b].append(a)
	else:
		data[a].append(b)
	spines[a] += 1
	spines[b] += 1
ans = 0
dp[1] = 1
ans = spines[1]
for i in range(2, n+1):
	ret = 0
	for item in data[i]:
		ret = max(ret, dp[item])
	dp[i] = ret + 1
	ans = max(ans, (ret+1)*spines[i])
print(ans)



def read(): return list(map(int, input().split()))
n, m = read()
lst = [[] for _ in range(n + 1)]
for _ in range(m):
  u, v = read()
  lst[u].append(v)
  lst[v].append(u)
d = [1] * (n + 1)
ans = 0
for v in range(1, n + 1):
  ans = max(ans, d[v] * len(lst[v]))
  for u in lst[v]:
    if u > v:
      d[u] = max(d[u], d[v] + 1)
print(ans)

n, m = [int(x) for x in input().split()]
E = {i:[] for i in range(1,n+1)}
for i in range(m):
    u, v = [int(x) for x in input().split()]
    E[v].append(u)
    E[u].append(v)
tail = {i:0 for i in range(1,n+1)}
tail[1] = 1
for u in range(2,n+1):
    tail[u] = max((tail[v] for v in E[u]), default = 0) + 1
print(max(tail[u]*len(E[u]) for u in range(1,n+1)))


n, m = tuple(map(int, input().split()))

g = [set() for i in range(n + 1)]
for i in range(m):
    a = tuple(map(int, input().split()))
    g[a[1]].add(a[0])
    g[a[0]].add(a[1])
    
res = [0] * (n + 1)
for i in range(1, n+1):
    maxi = 1
    for elem in g[i]:
        if elem > i: continue
        if res[elem] + 1 > maxi: maxi = res[elem] + 1
    res[i] = maxi
    
m = [0] * (n + 1)
for i in range(1, n+1):
    m[i] = res[i] * len(g[i])
    
print(max(m))
        
    


n, m = list(map(int, input().split()))

neibs_count = [0 for _ in range(n + 1)]
max_len = [0 for _ in range(n + 1)]

prevs = [[] for _ in range(n + 1)]

for _ in range(m):
    a, b = list(map(int, input().split()))
    prevs[max(a, b)].append(min(a, b))
    neibs_count[a] += 1
    neibs_count[b] += 1

max_ans = 0

for i in range(1, n + 1):
    max_prev_len = 0
    for prev in prevs[i]:
        max_prev_len = max(max_prev_len, max_len[prev])
    max_len[i] = max_prev_len + 1
    max_ans = max(max_ans, max_len[i] * neibs_count[i])

print(max_ans)


def main():
    n, m = [int(t) for t in input().split()]

    edge_count = [0 for _ in range(n)]
    tail_length = [0 for _ in range(n)]

    adj_list = [set() for _ in range(n)]

    for _ in range(m):
        u, v = [int(t) - 1 for t in input().split()]
        edge_count[u] += 1
        edge_count[v] += 1
        adj_list[u].add(v)
        adj_list[v].add(u)

    tail_length[0] = 1
    beauty = tail_length[0] * edge_count[0]

    for u in range(1, n):
        candidate_tail_lengths = [tail_length[v] + 1 for v in adj_list[u] if v < u]
        if len(candidate_tail_lengths) != 0:
            tail_length[u] = max(candidate_tail_lengths)
        else:
            tail_length[u] = 1
        beauty = max(beauty, tail_length[u] * edge_count[u])

    print(beauty)


def __starting_point():
    main()

__starting_point()

def main():
    n, m = [int(t) for t in input().split()]

    tail_length = [0 for _ in range(n)]

    adj_list = [set() for _ in range(n)]

    for _ in range(m):
        u, v = [int(t) - 1 for t in input().split()]
        adj_list[u].add(v)
        adj_list[v].add(u)

    tail_length[0] = 1
    beauty = tail_length[0] * len(adj_list[0])

    for u in range(1, n):
        candidate_tail_lengths = [tail_length[v] + 1 for v in adj_list[u] if v < u]
        if len(candidate_tail_lengths) != 0:
            tail_length[u] = max(candidate_tail_lengths)
        else:
            tail_length[u] = 1
        beauty = max(beauty, tail_length[u] * len(adj_list[u]))

    print(beauty)


def __starting_point():
    main()

__starting_point()

n,m =list(map(int, input().split()))
#b=[]
d=[0]*n
f=[[] for i in range(n)]
#for i in range(n):
#	f+=[]
#print(f)
#print(d)
for i in range(m):
	#s=input().split()
	a=list(map(int, input().split()))
	d[a[0]-1]+=1
	d[a[1]-1]+=1
	a.sort()
	#a.reverse
	f[a[1]-1]+=[a[0]-1]

#print(f[4])
k=[1]*n
res = 0
for i in range(n):
	for j in f[i]:
		k[i]=max(k[i], k[j]+1)
	res = max(res, k[i]*d[i])	
	
#	print(f)
	
print(res)
#b.sort
#print(b)# your code goes here# your code goes here


n, m = list(map(int, input().split()))
children = [ [] for u in range(n + 1) ]
degree = [ 0 for u in range(n + 1) ]
for i in range(m):
    u, v = list(map(int, input().split()))
    if u > v:
        u, v = v, u
    children[u].append(v)
    degree[u] += 1
    degree[v] += 1

depth = [ 0 for u in range(n + 1) ]
best = degree[1]
for u in range(1, n + 1):
    for v in children[u]:
        depth[v] = max(depth[v], depth[u] + 1)
        best = max(best, (depth[v] + 1) * degree[v])
print(best)


class Node:
    def __init__(self, i):
        self.i = i
        self.adj = []

def draw_hedgehog(n, nodes):
    tail_length = [1] * n
    best_beauty = len(nodes[0].adj)

    for i in range(1, n):
        max_so_far = tail_length[i]
        best_length = tail_length[i]
        spines = len(nodes[i].adj)
        for j in nodes[i].adj:
            if j < i:
                beauty = (tail_length[j] + 1) * spines
                if beauty > max_so_far:
                    max_so_far = beauty
                    best_length = tail_length[j] + 1
        tail_length[i] = best_length
        if max_so_far > best_beauty:
            best_beauty = max_so_far

    return best_beauty

def __starting_point():
    n, m = input().split()
    n, m = int(n), int(m)
    nodes = [Node(i) for i in range(n)]
    for k in range(m):
        u, v = input().split()
        u, v = int(u) - 1, int(v) - 1
        nodes[u].adj.append(v)
        nodes[v].adj.append(u)

    result = draw_hedgehog(n, nodes)
    print(result)

__starting_point()

n, m = list(map(int, input().split()))
graph = [list() for _ in range(n+1)]
count = [0 for _ in range(n+1)]
dp = [0 for _ in range(n+1)]
for _ in range(m):
    u, v = list(map(int, input().split()))
    if v < u:
        u, v = v, u
    graph[v].append(u)
    count[v] += 1
    count[u] += 1
for i in range(1, n+1):
    best = 1
    for j in graph[i]:
        best = max(best, dp[j] + 1)
    dp[i] = best
result = 1
for i in range(1, n+1):
    if dp[i] * count[i] > result:
        result = dp[i] * count[i]
print(result)


n, m = map(int, input().split())
graph = [[] for _ in range(n)]
for i in range(m):
	u, v = map(int, input().split())
	graph[u - 1].append(v - 1)
	graph[v - 1].append(u - 1)



dp = [1 for _ in range(n)]

for i in range(n):
	for v in graph[i]:
		if v < i:
			dp[i] = max(dp[i], dp[v] + 1)

print(max([dp[i] * len(graph[i]) for i in range(n)]))

def main():
    n, m = list(map(int, input().split()))
    n += 1
    children = [0] * n
    degree = [0] * n
    for _ in range(m):
        u, v = list(map(int, input().split()))
        if u > v:
            u, v = v, u
        l = children[u]
        if l:
            l.append(v)
        else:
            children[u] = [v]
        degree[u] += 1
        degree[v] += 1
    depth = [1] * n
    for a, c in zip(depth, children):
        if a and c:
            a += 1
            for v in c:
                if depth[v] < a:
                    depth[v] = a
    print(max(a * b for a, b in zip(depth, degree)))


def __starting_point():
    main()

__starting_point()

def main():
    n, m = list(map(int, input().split()))
    n += 1
    children = [[] for _ in range(n)]
    degree, depth = [0] * n, [1] * n
    for _ in range(m):
        u, v = list(map(int, input().split()))
        if u < v:
            children[u].append(v)
        else:
            children[v].append(u)
        degree[u] += 1
        degree[v] += 1
    for a, c in zip(depth, children):
        for v in c:
            if depth[v] <= a:
                depth[v] = a + 1
    print(max(a * b for a, b in zip(depth, degree)))


def __starting_point():
    main()

__starting_point()

n,m=list(map(int,input().split()))
gro=[[] * n for i in range(n)]
grno=[[] * n for i in range(n)]
ln=[1]*n
for i in range(m):
    x,y=list(map(int,input().split()))
    if x<y:
        gro[x-1].append(y-1)
    else:
        gro[y-1].append(x-1)
    grno[x-1].append(y-1)
    grno[y-1].append(x-1)
for i in range(n):
    for j in gro[i]:
        if ln[j]<=ln[i]+1:
            ln[j]=ln[i]+1
#for i in range(n):
#    print(gro[i])
#print("+___+")
#for i in range(n):
#    print(grno[i])
#print("+___+")
#print(ln)
mx=0
for i in range(n):
    if ln[i]*len(grno[i])>mx:
        mx=ln[i]*len(grno[i])
print(mx)



n,m = [int(i) for i in input().split()]
seg = {i:[] for i in range(1,n+1)}
for j in range(m):
    a,b = [int(i) for i in input().split()]
    seg[a].append(b)
    seg[b].append(a)
tail = [0]*(n+1)
tail[1] = 1
for i in range(2,n+1):
    temp = [tail[j] for j in seg[i]]+[0]
    tail[i] = max(temp)+1
temp = [len(seg[i])*tail[i] for i in range(1,n+1)]
print(max(temp))

#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2016 missingdays <missingdays@missingdays>
#
# Distributed under terms of the MIT license.

"""

"""

def read_list():
    return [int(i) for i in input().split()]
def new_list(n):
    return [0 for i in range(n)]
def new_list_list(n):
    return [[] for i in range(n)]

dp = new_list(100001)
g = new_list_list(100001)

n, m = read_list()

for i in range(m):
    v, u = read_list()

    g[v].append(u)
    g[u].append(v)

answ = 0

for v in range(1, n+1):
    dp[v] = 1

    for u in g[v]:
        if u < v:
            dp[v] = max(dp[v], dp[u]+1)

    answ = max(answ, dp[v]*len(g[v]))

print(answ)


import sys

# sys.stdin = open("ivo.in")

n, m = sys.stdin.readline().split()
n = int(n)
m = int(m)

neighbours = []
ne = []
smaller = []
for i in range(n):
    neighbours.append(0)
    smaller.append(1)
    ne.append([])


for i in range(m):
    f,t = sys.stdin.readline().split()
    f = int(f) - 1
    t = int(t) - 1
    neighbours[f] += 1
    neighbours[t] += 1
    if f < t:
        ne[f].append(t)
    else:
        ne[t].append(f)


for i in range(n):
    for sysed in ne[i]:
        smaller[sysed] = max([smaller[sysed], smaller[i] + 1])

ans = 0
for i in range(n):
    ans = max([ans, smaller[i] * neighbours[i]])

print(ans)