PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#DSU0000078. Nhóm bạn bè mạnh nhất (Strongest Friendship Group)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Nhóm bạn bè mạnh nhất (Strongest Friendship Group)

Strongest Friendship Group

Source: USACO

Version: Phuoc Hung OJ Extended

Problem Statement

There are NN cows and MM undirected friendship pairs. A non-empty group is valid if its members are connected using only friendship edges within that group.

Its strength equals the number of group members multiplied by the minimum number of friends that any member has within the group. Friendships to cows outside the group do not count. Find the maximum strength over all valid groups.

Friendships are undirected, and no unordered pair appears more than once. A group need not contain every cow, but every two members must be connected by a chain of friendships entirely inside the group.

The degree of a cow within the group counts only friends that are also group members. The cow's total number of friends on the farm is irrelevant to the group's strength. A group consisting of a single cow has strength 00.

Input

The first line contains N,MN,M. Each of the next MM lines contains one friendship pair ui,viu_i,v_i.

Output

Print one integer: the largest strength of a valid friendship group.

Subtasks

  • Subtask 1 (20 points): 2≤N≤162\le N\le 16; 1≤M≤1001\le M\le 100; 1≤ui,vi≤N1\le u_i,v_i\le N, ui≠viu_i\ne v_i; each friendship is specified at most once.
  • Subtask 2 (30 points): 2≤N≤10002\le N\le 1000; 1≤M≤40001\le M\le 4000; 1≤ui,vi≤N1\le u_i,v_i\le N, ui≠viu_i\ne v_i; each friendship is specified at most once.
  • Subtask 3 (50 points): 2≤N≤1000002\le N\le 100000; 1≤M≤2000001\le M\le 200000; 1≤ui,vi≤N1\le u_i,v_i\le N, ui≠viu_i\ne v_i; each friendship is specified at most once.

Examples

Input

8 10
1 2
1 3
1 4
2 3
2 4
3 4
1 5
2 6
3 7
4 8

Output

12

Explanation

Cows 1,2,3,41,2,3,4 form a connected group in which every member has exactly three friends inside the group. Its strength is 4⋅3=124\cdot3=12. Adding the other cows cannot yield a stronger friendship group, so the optimum is 1212.