import sys
import copy
input = sys.stdin.readline
sys.setrecursionlimit(100000)
import heapq
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))

def solve():
    return

def hakai(cur_tubusi, rooms, revrooms, ex, n):
    if len(rooms[cur_tubusi]) == 0:
        return 1000000
    elif len(rooms[cur_tubusi]) == 1:
        return 1000000
    else:
        ccost = -1
        for cand_tubusi in rooms[cur_tubusi]:
            tmp = ex[cand_tubusi]
            if tmp > ccost:
                ccost = tmp
                tubusi_index = cand_tubusi
        # print(cur_tubusi, tubusi_index)
        # rooms[cur_tubusi].remove(tubusi_index)
        revrooms[tubusi_index].remove(cur_tubusi)

        ex2 = [0 for i in range(n)]
        npaths2 = [0 for i in range(n)]

        # print(rooms)
        # print(revrooms)

        for i in range(n):
            roomnum = n - i - 1
            # print(roomnum)
            pcost = ex2[roomnum] + 1
            for par in revrooms[roomnum]:
                ex2[par] = (ex2[par] * npaths2[par] + pcost) / (npaths2[par] + 1)
                npaths2[par] += 1
                # print(roomnum, par, ex)
        # print(ex2)

        revrooms[tubusi_index].append(cur_tubusi)
        return ex2[0]


def main():
    n,m = getList()
    rooms = [[] for i in range(n + 1)]
    revrooms = [[] for i in range(n + 1)]
    npaths = [0 for i in range(n)]
    for i in range(m):
        a, b = getList()
        revrooms[b-1].append(a-1)
        rooms[a-1].append(b-1)
    ex = [0 for i in range(n)]

    # print(rooms)
    # print(revrooms)

    for i in range(n):
        roomnum = n - i - 1
        # print(roomnum)
        pcost = ex[roomnum] + 1
        for par in revrooms[roomnum]:
            ex[par] = (ex[par] * npaths[par] + pcost) / (npaths[par] + 1)
            npaths[par] += 1
            # print(roomnum, par, ex)
    # print(ex)
    # tubusi = True
    # cur_tubusi = 0
    # while(tubusi):
    #     if len(rooms[cur_tubusi]) == 0:
    #         break
    #     elif len(rooms[cur_tubusi]) == 1:
    #         cur_tubusi = rooms[cur_tubusi][0]
    #     else:
    #         ccost = -1
    #         for cand_tubusi in rooms[cur_tubusi]:
    #             tmp = ex[cand_tubusi]
    #             if tmp > ccost:
    #                 ccost = tmp
    #                 tubusi_index = cand_tubusi
    #         print(cur_tubusi, tubusi_index)
    #         rooms[cur_tubusi].remove(tubusi_index)
    #         revrooms[tubusi_index].remove(cur_tubusi)
    #         tubusi = False

    # print(rooms)
    # print(revrooms)

    # ==========================================
    #
    #
    #
    # ex2 = [0 for i in range(n)]
    # npaths2 = [0 for i in range(n)]
    #
    # # print(rooms)
    # # print(revrooms)
    #
    # for i in range(n):
    #     roomnum = n - i - 1
    #     print(roomnum)
    #     pcost = ex2[roomnum] + 1
    #     for par in revrooms[roomnum]:
    #         ex2[par] = (ex2[par] * npaths2[par] + pcost) / (npaths2[par] + 1)
    #         npaths2[par] += 1
    #         # print(roomnum, par, ex)
    # print(ex2)

    ans = ex[0]
    for i in range(n):
        tsekai = hakai(i, rooms, revrooms, ex, n)
        if tsekai < ans:
            ans = tsekai

        # print(rooms, revrooms)

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 67804