Bobo has a network of nodes and
arcs. The
-th arc goes from the
-th node to the
-th node, with cost
.
Bobo also asks questions. The
-th question is specified by two integers
and
, which is to ask the minimum cost to send one unit of flow from the
-th node to the
-th node, when all the edges have capacity
(a fraction).
You can refer the wiki page for further information of Minimum-cost Flow.
The input consists of several test cases terminated by end-of-file.
The first line of each test case contains two integers n and m. The i-th of the following m lines contains three integers,
and
. The next line contains an integer q. The i-th of the last q lines contains two integers
and
.
*
*
*
*
*
*,
* The sum of m does not exceed.
* The sum of q does not exceed.
For each test case, print q fractions (or `NaN`, if it is impossible to send one unit of flow) which denote the answer.