P17944 [NCPC 2022] Enigmatic Enumeration

Description

Your friend Cajsa has a graph with $n$ vertices, and she needs to find a shortest cycle in it. She casually picked a random sequence of vertices, and it happened to form a shortest cycle. "What is the probability of that?" she wondered, and then wrote a program to compute this probability. To do this, Cajsa needs an algorithm to count the number of shortest cycles in the graph. She used a randomized algorithm of her own design, with running time $\mathcal{O}(1)$. However, you suspect that this algorithm is wrong. Surely it should at least look at every vertex of the graph? You think the algorithm just outputs random numbers and happened to guess correctly on some small graphs. To answer your doubts, Cajsa generated a batch of graphs and asks you to check whether her answers are correct. Given an undirected graph with $n$ vertices and $m$ edges, you need to count the number of shortest cycles in the graph. A *cycle* in the graph is a path consisting of **distinct** vertices, with an edge between the first and the last vertices of the path. Two cycles are considered different only if their edge sets differ. Thus, $3,1,2$ and $3,2,1$ are the same cycle, and so are $1,2,3$ and $2,3,1$.

Input Format

The first line contains two integers $n$ and $m$ ($3 \le n \le 3000$, $3 \le m \le 6000$), the number of vertices and the number of edges, respectively. Each of the next $m$ lines contains two integers $u_i$ and $v_i$ ($1 \le u_i,v_i \le n$, $u_i \ne v_i$), meaning that there is an undirected edge between $u_i$ and $v_i$. The graph has no multiple edges or self-loops. It is guaranteed that the graph contains at least one cycle, but the graph is not necessarily connected.

Output Format

Output a single integer, the number of shortest cycles in the graph.

Explanation/Hint

Translated by QwenWork