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.

hardikJain5 | 258 |

CodeBuddy | 250 |

bhatabhi554 | 232 |

Akkki111 | 197 |

clone | 174 |

KshatriyaYash | 1932 |

nikhil_sojan | 1374 |

lonecoder | 1236 |

SumitSingh27 | 1127 |

mazumderrohit8 | 1124 |

blackshadows | 5327 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4591 |

Quandray | 4444 |

Login to report an issue on this page.