Associated Course(s):
Interview Preparation

Given an integer **N** denoting the Length of a line segment. you need to cut the line segment in such a way that the cut length of a line segment each time is integer either **x** , **y** or **z**. and after performing all cutting operation the total number of cutted segments must be maximum.

**Input**

First line of input contains of an integer **'T'** denoting number of test cases. First line of each testcase contains **N** . Second line of each testcase contains 3 space separated integers **x** , **y** and **z**.

**Output**

For each test case print in a new line an integer corresponding to the answer .

**Constraints**

1<=t<=70

1<=N,x,y,z<=4000

**Example**

**Input**

2

4

2 1 1

5

5 3 2

**Output**

4

2

In first test case, total length is 4, and cut lengths are 2, 1 and 1. We can make maximum 4 segments each of length 1. In secon test case, we can make two segments of lengths 3 and 2.

Author: hardikgulati96

mohamadhegazy97 | 57 |

ManojBharadhwaj | 49 |

bhatabhi554 | 48 |

adityak12 | 48 |

RaghavJindal | 47 |

blackshadows | 940 |

SunkyuHwang | 794 |

bently_nixon | 701 |

mb1973 | 491 |

Shaurya Khanna | 491 |

akhayrutdinov | 5043 |

Ibrahim Nash | 4967 |

blackshadows | 4640 |

Quandray | 4354 |

sanjay05 | 3668 |

Login to report an issue on this page.