#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#define MAXN 10001
using namespace std;
int N, M;
vector<int> G[MAXN];
int Time = 0; // neznaeh che "time" e klucova duma . . .
int disc[MAXN], parent[MAXN], low[MAXN], has[MAXN];
bool visited[MAXN];
void read()
{
memset(low,0,sizeof(low));
memset(disc,0,sizeof(disc));
memset(parent,0,sizeof(parent));
memset(has,0,sizeof(has));
memset(visited,0,sizeof(visited));
Time = 0;
scanf("%d %d", &N, &M);
for(int i=1;i<=N;i++) {
G[i].clear();
}
for(int i = 0; i < M; i++)
{
int u, v;
scanf("%d %d", &u, &v);
u++;
v++;
G[u].push_back(v);
G[v].push_back(u);
}
}
void DFS_Trajan(int u)
{
visited[u] = true;
++Time;
disc[u] = Time;
low[u] = Time;
int sz = G[u].size();
for(int i = 0; i < sz; i++)
{
int v = G[u][i];
if(!visited[v])
{
parent[v] = u;
DFS_Trajan(v);
}
if(v != parent[u])
low[u] = min(low[u], low[v]);
//low[u] = min(low[u], disc[v]);
}
}
void solve()
{
DFS_Trajan(1);
int cnt = 0;
for(int u = 1; u <= N; u++)
{
int sz = G[u].size();
for(int i = 0; i < sz; i++)
{
int v = G[u][i];
//printf("{%d %d}, {%d %d}\n", v, low[v], u, low[u]);
if(low[v] != low[u]) // ako sa v razlichni componenti
{
//printf("{%d %d}, {%d %d}\n", v, low[v], u, low[u]);
if(has[low[u]] != 0) // nqma smisyl da uvelichavame "cnt"
{
if(has[low[u]] == 1)
{
has[low[u]] = 2;
cnt--;
}
continue; // zashtoto shte namerim drugo rebro ot "v" -> "w" , kydeto "w"
} // ni e naslednik na v
has[low[u]] = 1;
cnt++;
}
}
}
//printf("%d\n", cnt);
int ans = cnt / 2;
ans += (cnt % 2); // Shtot se opravq pri kontra primera . . .
printf("%d\n", ans);
}
int main()
{
int i,t;
scanf("%d", &t);
for(i=1;i<=t;i++) {
read();
printf("Case %d: ", i);
solve();
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbH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AgIGludCBzeiA9IEdbdV0uc2l6ZSgpOwogCiAgICBmb3IoaW50IGkgPSAwOyBpIDwgc3o7IGkrKykKICAgIHsKICAgICAgICBpbnQgdiA9IEdbdV1baV07CiAKICAgICAgICBpZighdmlzaXRlZFt2XSkKICAgICAgICB7CiAgICAgICAgICAgIHBhcmVudFt2XSA9IHU7CiAgICAgICAgICAgIERGU19UcmFqYW4odik7CiAgICAgICAgfQogCiAgICAgICAgaWYodiAhPSBwYXJlbnRbdV0pCiAgICAgICAgICAgIGxvd1t1XSA9IG1pbihsb3dbdV0sIGxvd1t2XSk7CiAgICAgICAgICAgIC8vbG93W3VdID0gbWluKGxvd1t1XSwgZGlzY1t2XSk7CiAgICB9Cn0KIAp2b2lkIHNvbHZlKCkKewogICAgREZTX1RyYWphbigxKTsKIAogICAgaW50IGNudCA9IDA7CiAKICAgIGZvcihpbnQgdSA9IDE7IHUgPD0gTjsgdSsrKQogICAgewogICAgICAgIGludCBzeiA9IEdbdV0uc2l6ZSgpOwogCiAgICAgICAgZm9yKGludCBpID0gMDsgaSA8IHN6OyBpKyspCiAgICAgICAgewogICAgICAgICAgICBpbnQgdiA9IEdbdV1baV07CiAKICAgICAgICAgICAgLy9wcmludGYoInslZCAlZH0sIHslZCAlZH1cbiIsIHYsIGxvd1t2XSwgdSwgbG93W3VdKTsKIAogICAgICAgICAgICBpZihsb3dbdl0gIT0gbG93W3VdKSAgICAgLy8gYWtvIHNhIHYgcmF6bGljaG5pIGNvbXBvbmVudGkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgLy9wcmludGYoInslZCAlZH0sIHslZCAlZH1cbiIsIHYsIGxvd1t2XSwgdSwgbG93W3VdKTsKIAogICAgICAgICAgICAgICAgaWYoaGFzW2xvd1t1XV0gIT0gMCkgIC8vIG5xbWEgc21pc3lsIGRhIHV2ZWxpY2hhdmFtZSAiY250IgogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIGlmKGhhc1tsb3dbdV1dID09IDEpCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBoYXNbbG93W3VdXSA9IDI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNudC0tOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsgICAgICAgIC8vIHphc2h0b3RvIHNodGUgbmFtZXJpbSBkcnVnbyByZWJybyBvdCAidiIgLT4gInciICwga3lkZXRvICJ3IgogICAgICAgICAgICAgICAgfSAgICAgICAgICAgICAgICAgICAgLy8gbmkgZSBuYXNsZWRuaWsgbmEgdgogCiAgICAgICAgICAgICAgICBoYXNbbG93W3VdXSA9IDE7CiAgICAgICAgICAgICAgICBjbnQrKzsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KIAogICAgLy9wcmludGYoIiVkXG4iLCBjbnQpOwogCiAgICBpbnQgYW5zID0gY250IC8gMjsKICAgIGFucyArPSAoY250ICUgMik7ICAgICAgIC8vIFNodG90IHNlIG9wcmF2cSBwcmkga29udHJhIHByaW1lcmEgLiAuIC4KIAogICAgcHJpbnRmKCIlZFxuIiwgYW5zKTsKfQogCmludCBtYWluKCkKewogICAgaW50IGksdDsKIAogICAgc2NhbmYoIiVkIiwgJnQpOwogCiAgICBmb3IoaT0xO2k8PXQ7aSsrKSB7CiAgICAgICAgcmVhZCgpOwogICAgICAgIHByaW50ZigiQ2FzZSAlZDogIiwgaSk7CiAgICAgICAgc29sdmUoKTsKICAgIH0KIAogICAgcmV0dXJuIDA7Cn0=