1 #include<iostream>
2 #include<cstdio>
3 #include<cstring>
4 #include<string>
5 #include<cmath>
6 #include<cstdlib>
7 #include<queue>
8 #include<stack>
9 #include<map>
10 #include<vector>
11 #include<algorithm>
12 using namespace std;
13 typedef long long LL;
14 bool flag[10000];
15 int dp[205][205];
16 int ask[1000];
17 int main(void)
18 {
19 int T;
20 scanf("%d",&T);
21 while(T--)
22 {
23 int n,m;
24 memset(flag,0,sizeof(flag));
25 scanf("%d %d",&n,&m);
26 int i,j;
27 memset(dp,-1,sizeof(dp));
28 for(i = 2; i < 205; i++)
29 {
30 for(j = 0; j < 205; j++)
31 {
32 dp[i][j] = -1;
33 }
34 }
35 for(i = 0; i < m; i++)
36 {
37 scanf("%d",&ask[i]);
38 }
39 dp[1][0] = 1;
40 for(i = 2; i <= n; i++)
41 for(j = 0; j <= i; j++)
42 if(dp[i-1][j]!=-1)
43 for(int s = 0; s < m; s++)
44 dp[i][(j+ask[s])%i] = 1;
45 int sum = 0;
46 int ac[1000];
47 for(i = 0; i < n; i++)
48 {
49 if(dp[n][i]==1)
50 {
51 ac[sum++] = i+1;
52 }
53 }
54 printf("%d\n",sum);
55 printf("%d",ac[0]);
56 for(i = 1; i < sum; i++)
57 printf(" %d",ac[i]);
58 printf("\n");
59 }
60 return 0;
61 }