> File Name: 5765.cpp
> Author: jiangyuzhu
> Mail: 834138558@qq.com
> Created Time: 2016/10/1 10:24:37
************************************************************************/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
typedef pair<int, int>p;
const int maxn = 21, maxm = 5e2 + 5, maxx = 1234567;
p edge[maxn];
bool ok[maxx];
int con[maxx];
int cnt[maxx];
inline int lowbit(int a){return a & (-a);}
bool get(int NOW)
{
int AVAIL = lowbit(NOW);
int VISITED = 0;
while(VISITED != AVAIL){
int NOTYET = AVAIL ^ VISITED;
int u = lowbit(NOTYET);
VISITED |= u;
AVAIL |= con[u] & NOW;
}
return VISITED == NOW;
}
int main (void)
{
int T;scanf("%d", &T);
for(int tt = 1; tt <= T; ++tt){
int n, m;scanf("%d%d", &n, &m);
int u, v;
memset(con, 0, sizeof(con));
memset(ok, false, sizeof(ok));
memset(cnt, 0, sizeof(cnt));
for(int i = 0; i < m; ++i){
scanf("%d%d", &u, &v);
edge[i] = p(u, v);
con[1 << u] |= 1 << v;
con[1 << v] |= 1 << u;
}
int tot = 0;
int mask = (1 << n) - 1;
for(int i = 1; i <= mask; ++i) ok[i] = get(i);
for(int i = 1; i <= mask; ++i){
if((i & 1) && ok[i] && ok[mask ^ i]){
tot++;
cnt[i]++;
cnt[mask ^ i]++;
}
}
for(int i = 0; i < n; ++i){
for(int j = 1; j <= mask; ++j){
if((j >> i) & 1) cnt[j] += cnt[j ^ (1 << i)];
}
}
printf("Case #%d: ", tt);
for(int i = 0; i < m; ++i){
u = edge[i].first, v = edge[i].second;
printf("%d%c", tot - cnt[mask ^ (1 << u) ^ (1 << v)], i == m - 1?'\n':' ');
}
}
return 0;
}