Link with Game Glitch
题号:NC239341
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
Special Judge, 64bit IO Format: %lld

题目描述

Link is developing a game. In this game, players can craft things using various types of resources, and things crafted can also be used to craft other things.

Formally speaking, there are n types of items, numbered from 1 to n, and m recipes in the game. In the i-th recipe, players can use  items of the b_i-th type to craft  items of the d_i-th type, where k can be any positive real number.

One day, he finds that one player owns more than 18,446,744,073,709,551,615 identical items, which causes a server crash. This is obviously impossible without using glitches.

Link soon finds out that there is something wrong with the crafting recipe. Players may get infinite resources by crafting some special things over and over again!

Link doesn't want to adjust the recipes one by one, so he simply added an argument w. Now players can use  items of the b_i-th type to craft  items of the d_i-th type.

Link wonders: What's the maximum w that he can set so that no player can get infinite items by crafting things over and over again?

输入描述:

The first line contains two integers , which are the number of item types and the number of recipes.

Each of the next m lines contains four integers , describing a recipe.

It is guaranteed that players can get infinite items using the recipes above (when ).

输出描述:

Output a real number w, which is the maximum w satisfying the condition.

Your answer is considered correct if its absolute or relative error does not exceed .

Formally, let your answer be a, and the jury's answer be b. Your answer is accepted if and only if .
示例1

输入

复制
3 3
1 1 2 2
1 2 2 1
1 3 1 1

输出

复制
0.5000000000

备注:

In the first example:

When , players can use 1 item of the first type to get 2 items of the second type. Then use 2 items of the second type to get 4 items of the first type. Thus, players got 4 items of the first type from 1 item of the first type. By doing so repeatedly, players can get infinite items of the first type, so  does not satisfy the condition. It can be shown that 0.5 is the maximum possible w.

Note that players can never get infinite items of the third type. But that doesn't matter, you must make sure that players can't get infinite items of any type.