See Emily Play

You are taking care of Emily this afternoon. To keep her entertained, you’ve designed a game for her involving some math. The rule for the game is such — Emily is initially given a big number N. In each step she is supposed to:

  1. IfN is0,stopandcallitaday
  2. If N is divisible by 2, divide N by 2. 3. Otherwise, subtract 1 from N. For example, starting with 14, she gets 7, 6, 3, 2, 1, 0 Now, you see, Emily is just a kid and hasn’t grown strong notions of rules yet. So, as you have given the rules to her, Emily tries, but misunderstands. In her mind, she rewrites the rules :
  3. IfN is0,stopandcallitaday
  4. If N is divisible by 2, divide N by 2.
  5. Randomly and unbiasedly choose to do any of these two : • subtract 1 from N • add1withN For each division Emily takes d seconds, For each subtraction she takes s seconds, for each addition she takes a seconds. Now that you know how she is bending the rules, you start to wonder how many seconds you have to see Emily play. Input First line of input will contain the number of test cases, T ≤ 100000. Then T test cases follow. For each case there will be a single line containing four integers separated by space: Ndsa where , • 1≤N ≤1000000 • 1≤d,s,a≤10 Output For each case output a single line containing one real number, the expected number of seconds: T. Show exactly 3 digits after decimal point, properly rounded.

2/2 Sample Input 6 1111 2111 3111 4111 5111 1000000 1 1 1 Sample Output 3.000 4.000 5.500 5.000 6.750 29.367