import java.util.*; import java.io.*; public class Main{ long mod = (int)1e9+9; FastReader in;PrintWriter out; public static void main(String[] args) throws Exception{ new Main().run(); } void run() throws Exception{ in = new FastReader(); out = new PrintWriter(System.out); for(int i = 1, T = ni(); i<= T; i++)solve(i); out.flush(); out.close(); } void solve(int TC) throws Exception{ int n = ni(), p = ni(); int[] max = new int[p+1]; for(int i = 1; i<= p; i++)max[i] = ni(); long[][] dp = new long[n+1][p+1];// DP table, dp[i][j] denotes number of ways to get sum i as sum of first j partitions. dp[0][0] = 1;//Base case. for(int i = 1; i<= p; i++) for(int sum = 0; sum <=n; sum++) for(int k = 0; k<= max[i] && sum+k<= n; k++) //updating dp table if ith partition is chosen as k. dp[sum+k][i] = (dp[sum+k][i]+dp[sum][i-1])%mod; pn(dp[n][p]); } long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);} int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);} int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));} void p(Object o){out.print(o);} void pn(Object o){out.println(o);} void pni(Object o){out.println(o);out.flush();} String n(){return in.next();} String nln(){return in.nextLine();} int ni(){return Integer.parseInt(in.next());} long nl(){return Long.parseLong(in.next());} double nd(){return Double.parseDouble(in.next());} class FastReader{ BufferedReader br; StringTokenizer st; public FastReader(){ br = new BufferedReader(new InputStreamReader(System.in)); } public FastReader(String s) throws Exception{ br = new BufferedReader(new FileReader(s)); } String next(){ while (st == null || !st.hasMoreElements()){ try{ st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } } return st.nextToken(); } String nextLine(){ String str = ""; try{ str = br.readLine(); }catch (IOException e){ e.printStackTrace(); } return str; } } }