FAMWEALT - Family members

Consider a family in the form of a binary tree consisting of male and female nodes. All the left nodes will be male nodes and all the right nodes will be female nodes.

Root node will be female node. The root female initially has a wealth w which she passes on down the tree. The rules are as follows:

  1. all the males in the family pass half of their wealth to each of their children.
  2. all the female nodes pass only half of their wealth to both their children collectively, but the male child suddenly converts it to twice the wealth received.

The members are numbered from 1 to n in the row-wise order. i.e., root will be 1, the two children will be 2 and 3 and so on.

Given wealth W of xth node, you need to find the wealth of yth node.

Input

First line consists of t, the number of test cases (1 ≤ t ≤ 20).

Each of t lines consists of three integer values x, y and W (1 ≤ x, y ≤ 106 and 1 ≤ W ≤ 1000).

Output

For each input test case, print the wealth of yth node in a single line (rounded off to six decimal digits.)

Example

Input:
2
11 3 1
4 6 4

Output:
4.000000
2.000000

Added by:Pandian
Date:2013-12-19
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All

hide comments
2013-12-25 17:30:12 Deepak gupta
Enjoyed solving it :)
2013-12-24 18:41:58 anurag garg
very very tricky question....

Last edit: 2013-12-24 18:51:58
2013-12-23 17:02:52 Pandian
@Ashwini : If parent is female is wealth w, both children receive only w/4 of wealth, but male child automatically doubles what it receives(only when parent is female).
2013-12-23 05:56:17 Ashwini
@ Pandian: can you explain how much wealth both children receives respec if parent is female node with w wealth
2013-12-23 04:12:59 Pandian
Thank you !
2013-12-22 22:05:24 Upendra Ghintala
really nice problem dude.. enjoyed solving it..
2013-12-22 20:27:55 Pandian
Sorry. There was an error with the input data. It is now corrected and the solutions are rejudged.
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.