1.
import java.util.Scanner;

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
* Problem: 10056 - What is the Probability ?
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=226&page=show_problem&problem=997
*
* @author Siegfried Ippisch
* @author Martin Lambeck
* @version 1.0
*
* Method : -
* Status : Accepted
* Runtime: 0.632
*/
public class WhatIsTheProbability {

static Scanner in = new Scanner(System.in);

public static void main (String...strings)
{
int cases = in.nextInt();

for (int i = 0; i < cases; i++)
{
testcase();
}

}

static void testcase()
{
int players = in.nextInt();
double p = in.nextDouble();
int winner = in.nextInt() -1;

double rem = 1.0;

double wp = 0.0;



for (int pl = 0; pl < players; pl++)
{
double w = rem * p;

if (pl == winner)
wp = w;

rem -= w;
}

wp = (1.0/(1.0-rem)) * wp;
//wp =
// while (rem >= 0.00001)
// {
// wp += rem * firstwp;
// rem = firstrem * rem;
// }

System.out.printf("%.4f\n", p == 0 ? 0.0 : wp);
}
}