/**********************************************************************
 * 
 * First observe that the first generated point (for k=0) is always
 * part of an optimal quadriliteral. Why? Imagine any optimal quadriliteral
 * with loudspeakers on points (a,b,c,d) where a is the smallest index and
 * not zero. Since the distance between any two successively generated is
 * the same, we can "rotate" the quadriliteral to (a-1,b-1,c-1,d-1) and
 * have an equivalent solution. Now we can simply continue this until
 * we reach (0,?,?,?).
 * 
 * Ok, so we'll fix one loudspeaker at the first generated point (k=0)
 * and search for places to put the other three loudspeakers. Let's
 * call the other three places A, B, C in clockwise order, so our
 * loudspeakers will stand on (0,A,B,C).
 * 
 * We can now split the problem in half. We can try all suitable places
 * for loudspeaker B and for each possibility, choose A and C separately
 * so that the areas of both the triangle (0,A,B) and the triangle (0,B,C)
 * are maximized. The area of the quadriliteral is the sum of those two
 * independent triangles and we keep track of the maximum quadriliteral
 * area.
 * 
 * A nice way to generate the suitable points and have them sorted clockwise
 * around Pia's circle is to first only generate the indices, then sort
 * those, then translate them to (x,y) coordinates. Also, be careful with
 * integer overflow! If you compute the indices as suits[k] = g*k%n then
 * g*k will easily exceed an "int" with large values of g and k. Either
 * use 64 bit integers or compute the new index by adding g (modulo n)
 * to the previous one.
 * 
 * I always forget how to compute the area of a polygon, but I always
 * remember problem 109 at Valladolid and look up the formula there
 * (of course in a real contest I can't do that, so I should have the
 * formula with me in printed form):   http://acm.uva.es/p/v1/109.html
 * 
 **********************************************************************/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;

double x[1000], y[1000];

double foo ( int P, int Q ) {
  return y[P] * x[Q]  -  y[Q] * x[P];
}

double area ( int A, int B ) {
  return (foo( 0, A ) + foo( A, B ) + foo( B, 0 )) / 2;
}

int main () {
  int SC;
  cin >> SC;
  for( int S=1; S<=SC; S++ ){
    cout << "Scenario #" << S << ":" << endl;
    
    //--- Read the testcase parameters.
    int d, n, c, g;
    cin >> d >> n >> c >> g;
    
    //--- Generate the points.
    int suits[1000] = {};
    for( int k=1; k<c; k++ )
      suits[k] = (suits[k-1] + g) % n;
    sort( suits, suits+c );
    for( int i=0; i<c; i++ ){
      double angle = 4 * acos(0) / n * suits[i];
      x[i] = sin( angle ) * d / 2;
      y[i] = cos( angle ) * d / 2;
    }
    
    //--- Dance...
    double best = 0;
    for( int B=1; B<c; B++ ){
      double first = 0;
      for( int A=1; A<B; A++ )
	first = first >= area( A, B ) ? first : area( A, B );
      for( int C=B+1; C<c; C++ )
	best = best > first + area( B, C ) ? best : first + area( B, C );
    }
    
    //--- Answer.
    printf( "%.6f\n\n", best );
  }
}
