Bracelets (Bangles)
Competitor spies have infiltrated the spare parts warehouse of "Magic & Stupidity," a company known for manufacturing magical bracelets. Each bracelet is composed of four distinct parts, with each part featuring locks at both ends. These locks are identified by numbers, and adjacent parts must have matching lock numbers to connect in a circular fashion.
There are N different lock types (numbered from 1 to N) and M types of parts, each defined by a pair of lock numbers (the order of the numbers does not matter). Your task is to write a program that calculates the number of different sets of four parts that can be used to assemble bracelets for "Magic & Stupidity."
Input Data
The program will read from the first line the integers N (the number of lock types) and M (the number of part types), where 4 ≤ N ≤ 300. The following M lines will each contain a pair of lock numbers, representing the parameters of the parts. All pairs are unique.
Output Data
The program should output the total number of possible bracelet variations.