A root is programmed to move forward F meters and backwards again, say B meters, in a straight line. The Robot covers 3 meters in T units of time. On robot’s path there is a ditch at a distance FD from initial position in forward direction as well as a ditch at a distance BD from initial position in backward direction. This forward and backward movement is performed repeatedly by the Robot.
Your task is to calculate amount of time taken , before the Robot fails in either ditch, if at all it fails in a ditch.
Input Format:
First line contain total number of test cases, denoted by N
Nex N line, contains a tuple containing % values delimited by space
F B T FD BD, where
1. F denotes forward displacement in meters
1. B denotes backward displacement in meters
1. T denotes time taken to cover 1 meter
1. FD denotes robots starting position and the ditch in forward direction
1. BD denotes robots starting position and the ditch in backward direction



Answer is attached as attachment. :)