Join two kingdoms

No attempts yetTime limit1sMemory limit128 MB

Problem

The kingdoms of Nlogonia and Quadradonia fought a long and terrible war. Nobody remembers why it started, so historians call it the Almost Completely Meaningless (ACM) war. When the ACM war ended, the two kingdoms decided to strengthen their bonds and avoid more bloodshed, so they asked the International Consortium for the Prevention of Conflicts (ICPC) for advice. The ICPC recommended building exactly one new road between a city of Nlogonia and a city of Quadradonia, so that the two kingdoms can trade and exchange culture.

Nlogonia has NN cities and Quadradonia has QQ cities. The road system of a kingdom is a set of bidirectional roads, each joining two different cities of that kingdom, and from any city of a kingdom to any other city of the same kingdom there is exactly one path, that is, one sequence of consecutive roads. The size of such a road system is the largest number of roads you must take to travel between two of its cities.

The ICPC did not say which two cities the new road should join, so the citizens worry that the combined road system becomes too large. To rule out a second ACM war you have to show them otherwise. Every road that could be built between the two kingdoms is equally likely to be the one that gets built. Compute the expected size of the resulting road system.

Input

The first line contains two integers NN and QQ, the number of cities in each of the two kingdoms (1N,Q4×1041 \le N, Q \le 4 \times 10^4). Cities of Nlogonia carry distinct integers from 11 to NN, and cities of Quadradonia carry distinct integers from 11 to QQ.

Each of the next N1N - 1 lines describes one road of Nlogonia with two distinct integers AA and BB, meaning that the road joins city AA and city BB (1A,BN1 \le A, B \le N).

Each of the following Q1Q - 1 lines describes one road of Quadradonia in the same format, where the distinct integers CC and DD mean that the road joins city CC and city DD (1C,DQ1 \le C, D \le Q).

In each kingdom there is exactly one path between every pair of cities.

Output

Print one line with the expected size of the combined road system, given that every possible road joining the two kingdoms is equally likely.

Print exactly three digits after the decimal point and round the digits below that to the nearest value, rounding a value that falls exactly halfway upward. Write all three decimal digits even when the expected value is an integer.