Gambling Guide

On an undirected graph, find the minimum expected number of random tickets (with rejection allowed) needed to travel from city 1 to city n.

Hard8GraphProbabilityGreedyMathNo attempts yetTime limit3sMemory limit512 MB

Problem

A railroad network in a nearby country has nn cities numbered 1 to nn and mm two-way tracks, each of which joins two different cities. Tickets are sold only by the automated machines installed in every city. Hackers tampered with those machines, so every one of them now works like this: when a single coin is inserted into the machine in city aa, the machine prints one one-way ticket from aa to a neighbouring city, chosen uniformly at random among all cities joined to aa by a track. Destinations of different tickets bought in the same city are independent.

A computer science student has to travel from city 1, where she lives, to city nn, where a regional programming contest has already started. She knows how the machines work, though she cannot predict the random choices, and she has a map of the railroad network. After buying a ticket she reads the destination printed on it, and she can either use the ticket at once and travel to that city, or throw the ticket away and buy a new one in the city she is standing in. She can keep buying tickets forever. The trip ends the moment she reaches city nn.

After some calculation she found a travel strategy with these two properties:

  • The probability that the trip eventually ends is 11.
  • The expected number of coins spent on the trip is as small as possible.

Find the expected number of coins she will spend.

Input

The first line contains two integers nn and mm (1n,m3000001 \le n, m \le 300000), the number of cities and the number of railroad tracks.

Each of the next mm lines contains two different integers aa and bb (1a,bn1 \le a, b \le n), describing a track that joins city aa and city bb. Each pair of cities is joined by at most one track. City nn is reachable from city 1.

Output

Print the expected number of coins, rounded to exactly 1010 digits after the decimal point, on one line.

Hint

The figure shows the railroad network of the second example.