This page is still under construction.

Parts of this page are still being built. What you see may change.

Yua and the Gomduri Car

Time limit1sMemory limit1024 MB

Summary
Count all walks of length exactly 7 in an undirected graph, where vertices and edges may repeat, modulo 1e9+7.
Level

Medium5 of 10

Topics
Dynamic programming, Matrix, Graph, Math
Solved
No attempts yet

Problem

To celebrate the new year, Yua bought a V.Nets self-driving car. Yua plans to drive the new car to the sea and eat plenty of raw fish (Yua follows the government's quarantine guidelines for disease prevention). While driving on the highway, Yua could not help but be stunned. V.Nets's self-driving system was terrible. Feeling deeply betrayed by V.Nets, Yua resolved to design a self-driving car personally.

The Gomduri car is the self-driving car Yua designed. The Gomduri car always moves from its current vertex to an arbitrary adjacent vertex. Yua believes that if a path from the start to the destination exists and time is unlimited, the Gomduri car can always reach the destination. Yua suddenly became curious: given a graph, how many paths can the Gomduri car travel?

But Yua could not solve this problem. To lower the difficulty, Yua allowed revisiting the same vertex or edge along a path.

Given a graph, write a program that counts the paths of length 7 that the Gomduri car can travel. The Gomduri car may pass through the same vertex or edge multiple times.

Input

The first line gives the number of vertices NN and the number of edges MM.

The following MM lines give the numbers u,vu, v of the two vertices that each edge connects.

The given edges are undirected, and all input is separated by spaces.

Output

On the first line, print the number of paths of length 7 that the Gomduri car can travel. Since the answer can be very large, print it modulo 109+710^9 + 7.

Constraints

  • 2≤N≤100,0002 \le N \le 100,000
  • 1≤M≤min⁡(N×(N−1)/2,100,000)1 \le M \le \min(N \times (N - 1) / 2, 100,000)
  • 1≤u,v≤N1 \le u, v \le N
  • u≠vu \ne v
  • The given graph contains no duplicate edges.

Hint

Since the input is large, using fast input is recommended.

The length of a path is the number of edges that make up the path.

Examples2

  1. Example 1

    Input
    4 3
    3 1
    3 2
    3 4
    
    Expected output
    162
    
  2. Example 2

    Input
    3 1
    2 3
    
    Expected output
    2