For this Question: You have infinite supply of coins, of given denominations. Can you figure out the minimum number of coins required so that coins sum- up to a certain required value. We'll use dynamic programmic to solve this question.

You are given an amount denoted by value. You are also given an array of coins. The array contains the denominations of the given coins. You need to find the minimum number of coins to make the change for value using the coins of the given denominations. Also, keep in mind that you have infinite supply of the coins.
If making the change is not possible then print "Not Possible" without quotes.The first line of input contains one integer T - the number of testcases. Then T testcases follow. 
Each testcase contains three lines of input. The first line contains value for which you need to make the change. The second line contains the Size of the array. The third line contains the denominations of the coins.

Constraints:
1 <= T <= 100
1 <= value <= 1000
1 <= numberOfCoins <= 1000
1 <= denominationOfCoins <= 1000For each testcase, in a new line, print the minimum number of coins required.
If making the change is not possible then print "Not Possible" without quotes.Input:
2
10
4
2 5 3 6
5
3
3 6 3

Output:
2
Not Possible

Explanation:
Testcase1: 
There are five ways to make 10 using [2, 5, 3, 6].
{2, 2, 2, 2, 2}
{2, 2, 3, 3}
{2, 2, 6}
{2, 3, 5}
{5, 5}
Minimum number of coins is required when we use two 5 coins
Thus answer is 2
Testcase2: 
There are no ways to make 5 using [3, 6, 3]
Thus answer is Not Possible., I have written this Solution Code: import java.io.*;
import java.util.*;



class Main {
    public static void main (String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int testCases = Integer.parseInt(br.readLine());

        while(testCases-- > 0){
            int value = Integer.parseInt(br.readLine());

            int numOfCoins = Integer.parseInt(br.readLine());

            int[] coinsArr = new int[numOfCoins];
            String str = br.readLine();
            String[] s1 = str.split(" ");

            for(int i = 0 ; i < numOfCoins; i++){
                coinsArr[i] = Integer.parseInt(s1[i]);

            }
            if(minCoin(coinsArr, coinsArr.length,value) == -1){
                System.out.println("Not Possible");
            }else{
                System.out.println(minCoin(coinsArr,coinsArr.length, value));
            }
        }
    }
    public static int minCoin(int[] coins, int m, int v){
        int dp[] = new int[v + 1];
        dp[0] = 0;
        for(int i = 1; i <= v; i++){
            dp[i] = Integer.MAX_VALUE;
        }

        for(int i = 0; i <= v; i++){
            for(int j = 0; j < m; j++){
                if(coins[j] <= i){
                    int subres = dp[i - coins[j]];
                    if(subres != Integer.MAX_VALUE && subres + 1 < dp[i])
                        dp[i] = subres + 1;
                }
            }
        }

        if(dp[v] == Integer.MAX_VALUE){
            return -1;
        }
        return dp[v];

    }
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?