Möbius Strip

No attempts yetTime limit1sMemory limit128 MB

Problem

A Möbius strip is a surface with a single side and a single boundary edge. You can build one from a strip of paper: give one of the short ends a half-turn twist, then glue the two short ends together.

Start with a rectangular strip of paper whose two faces are each covered by a square grid of size m×nm \times n with mnm \le n (mm squares across the width, nn squares along the length). Twisting one short end by a half turn and gluing the short ends together joins the two faces into one continuous surface, so the resulting Möbius strip has size m×2nm \times 2n: mm squares across the width and 2n2n squares all the way around the loop. For example, a Möbius strip of size 5×1005 \times 100 has m=5m = 5 and 2n=1002n = 100 (that is, n=50n = 50).

Two squares are adjacent when they share a full side, except along the single boundary edge of the strip. An ant stands on one square and moves only from a square to an adjacent one; it can never step across the boundary edge. The distance between two squares is the least number of moves the ant needs to get from one to the other (equivalently, the number of squares it enters, not counting the square it started on), so two adjacent squares are at distance 11.

The average distance of a Möbius strip of size m×2nm \times 2n is the average of the distances taken over every ordered pair of squares, including each square paired with itself (which contributes distance 00). For example, a Möbius strip of size 1×2n1 \times 2n has average distance n2\frac{n}{2}.

Given the size of a Möbius strip, output its average distance.

Input

The first line contains the number of test cases TT. Each of the following TT lines contains two integers mm and nn (1mn1,000,0001 \le m \le n \le 1{,}000{,}000), describing a Möbius strip of size m×2nm \times 2n.

Output

For each test case, print one line with the average distance of that Möbius strip, rounded to the nearest tenth so that it shows exactly one digit after the decimal point.