Given a value **V**. You have to make change for V cents, given that you have infinite supply of each of C{ C1, C2, .. , Cm} valued coins. Find the minimum number of coins to make the change.

**Input:**

The first line of input contains an integer T denoting the number of test cases. The first line of each test case is V and N, V is the value of cents and N is the number of coins. The second line of each test case contains N input C[i], value of available coins.

**Output:**

Print the minimum number of coins to make the change, if not possible print "-1".

**Constraints:**

1 ≤ T ≤ 100

1 ≤ V ≤ 10^{6}

1 ≤ N ≤ 10^{6}

1 ≤ C[i] ≤ 10^{6}

**Example:**

**Input**:

1

7 2

2 1

**Output:**

4

**Explanation :
Testcase 1: **We can use coin with value 2 three times, and coin with value 1 one times to change a total of 7.

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.

the_coder95 | 465 |

thanuvinu94 | 388 |

adityasuman2025 | 305 |

Senbonzakura_Kageyoshi | 297 |

PrakharBansal1 | 274 |

the_coder95 | 1691 |

RishabhTanwar1 | 1110 |

thanuvinu94 | 1064 |

samay_kam_hai | 724 |

themanhasnoname | 620 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4897 |

Quandray | 4547 |

Login to report an issue on this page.