Servers
The corporation has N servers, each identified by a unique natural number from 1 to N. These servers are housed in a rack with N shelves, also numbered from 1 to N. Due to equipment upgrades, the servers need to be rearranged. The challenge is that certain pairs of servers must be connected by cables, and the length of each cable is determined by the difference in the shelf numbers where the connected servers are placed. Your task is to arrange the servers to minimize the total cable length required.
Determine the minimum total cable length needed for this arrangement and provide one possible configuration that achieves this.
Input
The first line contains a natural number N (2 ≤ N ≤ 20). The second line contains the number of server pairs M that need to be directly connected.
The following M lines each contain a pair of distinct natural numbers, representing the servers that need to be connected. Each pair is listed only once.
Output
The first line should display the minimum possible total cable length. The second line should show a permutation of the numbers 1, 2, …, N, indicating the optimal server arrangement: the number in the j-th position represents the server to be placed on the j-th shelf.