#include <iostream>
#include <stdio.h>
#include <queue>
#include <string>
#include <memory.h>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;
const int oo = (int)1e9;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
using namespace std;
vector<int> B, A, best, take;
bool on[1001];
int mx = -1;
int n, k;
void calc(int i) {
if (i == (int)B.size()) {
int c = 0;
for (int j = 1; j <= n; ++j)
c += on[j];
if (c > mx)
best = take, mx = c;
return;
}
int x = B[i];
for (int j = x; j <= n; j += x)
on[j] = !on[j];
take.push_back(B[i]);
calc(i + 1);
take.pop_back();
for (int j = x; j <= n; j += x)
on[j] = !on[j];
calc(i + 1);
}
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
#endif
int t, T = 0;
scanf("%d", &t);
while (t--) {
A.clear();
B.clear();
best.clear();
take.clear();
memset(on, 0, sizeof(on));
mx = -1;
scanf("%d%d", &n, &k);
for (int i = 0; i < k; ++i) {
int a;
scanf("%d", &a);
if (a*a <= n)
B.push_back(a);
else A.push_back(a);
}
calc(0);
for (int i = 0; i < (int)best.size(); ++i) {
int x = best[i];
for (int j = x; j <= n; j += x)
on[j] = !on[j];
}
best.clear();
for (int i = 0; i < (int)A.size(); ++i) {
int x = A[i], o = 0;
for (int j = x; j <= n; j += x)
o += on[j] ? -1 : 1;
if (o>0)
best.push_back(x);
}
for (int i = 0; i < (int)best.size(); ++i) {
int x = best[i];
for (int j = x; j <= n; j += x)
on[j] = !on[j];
}
int res = 0;
for (int i = 1; i <= n; ++i)
res += on[i];
printf("Case #%d: %d\n", ++T, res);
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RkaW8uaD4KI2luY2x1ZGUgPHF1ZXVlPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8bWVtb3J5Lmg+CiNpbmNsdWRlIDxiaXRzZXQ+CiNpbmNsdWRlIDx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