Under construction

Still being built. Things may change

Interconnect

Time limit1sMemory limit128 MB

Summary
Given an initial graph on up to 30 towns, compute the exact expected number of random-edge additions needed until the graph becomes fully connected, as a reduced fraction.
Level

Hard8 of 10

Topics
Union-find, Math, Probability, Dynamic programming
Solved
No attempts yet

Problem

In the Kingdom of Lipshire there are nn towns. Some of the old roads have fallen into such disrepair that they can no longer be used, so the kingdom has decided to rebuild its road network.

The new road network must interconnect every town: there must be a path between any two towns.

The road administration can build exactly one road per year, but the builders are completely out of control. No matter what orders they are given, each year they choose two distinct towns aa and bb uniformly at random among all (n2)\binom{n}{2} unordered pairs and build a road between them — even if those towns are already directly or indirectly connected. Every pair is equally likely. A traveler can enter or leave each road only at its two endpoint towns, and every road is bidirectional.

Given the towns that are still joined by the good roads that remain, determine the expected number of years until the whole road network becomes interconnected.

Input

The first line contains two integers nn and mm (2≤n≤302 \le n \le 30, 0≤m≤10000 \le m \le 1000) — the number of towns and the number of good roads that still remain. Towns are numbered from 11 to nn.

Each of the next mm lines contains two integers uiu_i and viv_i (1≤ui,vi≤n1 \le u_i, v_i \le n, ui≠viu_i \ne v_i) describing a remaining road between towns uiu_i and viv_i. There may be several roads between the same pair of towns, but no road connects a town to itself.

Output

The expected number of years is always a rational number. Output it as an exact reduced fraction in the form p/q, where q≥1q \ge 1, gcd⁡(p,q)=1\gcd(p, q) = 1, and the fraction equals the expected number of years. If the road network is already interconnected, the expected value is 00 and must be printed as 0/1.

For example, an expected value of 32\tfrac{3}{2} is printed as 3/2, and an expected value of 11 is printed as 1/1.

Examples4

  1. Example 1

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

    Input
    2 1
    1 2
    
    Expected output
    0/1
    
  3. Example 3

    Input
    2 0
    
    Expected output
    1/1
    
  4. Example 4

    Input
    3 0
    
    Expected output
    5/2