Ishaan lives in a multi-story building. Everyday he has to get to the ground floor from the Nth floor. He has three options to come down, the lift, the stairs or the escalator. He has different speeds for the lift, the stairs and the escalator which are V1 m/s, V2 m/s and V3 m/s respectively.

Assuming each floor has a height of 1m and the stairs and the escalator are inclined at an angle of 45 degrees.

Find out which is the fastest way for Ishaan to reach the ground floor.

If any of the methods consume same time, give preference to lift, then stairs and then escalator.

**Input :**

First line of input contains a single integer T denoting the number of test cases.

The only line of each test case contains 4 space-separated integers N, V1, V2 and V3.

**Output : **

For each test case, print "1" if lift is fastest, "2" if stairs are fastest and "3" if escalator is fastest in a new line (without quotes "").

**Constraints : **

1 <= T <= 200

1 <= N <= 1000

1 <= V1,V2,V3 <= 1000

**Example : **

**Input :**

3

5 1 2 3

5 3 2 1

6 2 3 1

**Output :**

3

1

2

**Explanation :**

The distance for stairs and escalator is **sqrt(2)*N** because they are inclined at a 45 degree angle.

Case 1 :

Time taken by lift : N/V1 = 5

Time taken by stairs : (N*sqrt(2))/V2 = 3.535

Time taken by escalator : (N*sqrt(2))/V3 = 2.356

Case 2 :

Time taken by lift : N/V1 = 1.666

Time taken by stairs : (N*sqrt(2))/V2 = 3.535

Time taken by escalator : (N*sqrt(2))/V3 = 7.07

Case 3 :

Time taken by lift : N/V1 = 3

Time taken by stairs : (N*sqrt(2))/V2 = 2.828

Time taken by escalator : (N*sqrt(2))/V3 = 8.484

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

geetyadav | 82 |

hari32147 | 76 |

AdityaRaj9 | 75 |

yashrana1 | 74 |

giavytrinh98 | 64 |

abducodes | 839 |

harshtyagi36 | 417 |

vamsikrishna55 | 323 |

sandipbhaumik | 321 |

Akhil varma | 314 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4567 |

Login to report an issue on this page.