gCube (Small)

Compute the geometric mean of each queried subarray and print it with nine digits after the decimal point.

Medium4MathNo attempts yetTime limit5sMemory limit512 MB

Problem

A DD-dimensional cube has DD dimensions of equal length. DD is any positive integer, so a 1-dimensional cube is a line segment, a 2-dimensional cube is a square, and a 4-dimensional cube is a hypercube. A DD-dimensional cuboid also has DD dimensions, but their lengths may differ.

You are given an NN-dimensional cuboid. Its dimensions are numbered 0,1,2,,N10, 1, 2, \ldots, N-1 in order, and dimension ii has length aia_i. Answer MM queries of the following form.

  1. Take the consecutive dimensions from the LiL_i-th one to the RiR_i-th one, inclusive.
  2. Build a DD-dimensional cuboid from those dimensions, where D=RiLi+1D = R_i - L_i + 1. For example, if Li=3L_i = 3 and Ri=6R_i = 6, the new cuboid uses dimensions 3, 4, 5, and 6.
  3. Reshape that cuboid into a DD-dimensional cube with exactly the same volume, and report the edge length of the cube.

Every query of a test case uses the same original NN-dimensional cuboid.

Input

The first line has the number of test cases TT. The TT test cases follow.

Each test case begins with a line holding two integers NN and MM, the number of dimensions and the number of queries. The next line has NN positive integers a0,a1,,aN1a_0, a_1, \ldots, a_{N-1}, the lengths of the dimensions in order. Each of the next MM lines has two integers LiL_i and RiR_i, the range of dimensions used by the ii-th query.

Output

For each test case, print one line "Case #x:", where x is the number of the test case starting from 1. Then print MM lines, where the ii-th line has the edge length for the ii-th query.

The edge length for a query is (j=LiRiaj)1/D\left(\prod_{j=L_i}^{R_i} a_j\right)^{1/D} with D=RiLi+1D = R_i - L_i + 1. Print it with exactly 9 digits after the decimal point, rounding the exact value half up at the ninth decimal place. The root is usually irrational and the product reaches 109010^{90}, so compute it precisely enough that the ninth decimal digit is correct. Always print at least one digit before the decimal point and never print a plus sign.

Constraints

  • 1T1001 \le T \le 100
  • 1N101 \le N \le 10
  • 1M101 \le M \le 10
  • 1ai1091 \le a_i \le 10^9
  • 0LiRi<N0 \le L_i \le R_i < N