#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1000000000
ll mat[105][105];
int main()
{
ll i,j,n,m,t,k,a,b,c;
scanf("%lld",&t);
for(ll cz=0;cz<t;cz++){
scanf("%lld%lld",&n,&m);
for(i=0;i<n;i++){
for(j=0;j<n;j++){
mat[i][j]=inf;
if(i==j) mat[i][j]=0;
}
}
for(i=0;i<m;i++){
scanf("%lld%lld",&a,&b);
mat[a][b]=1;
mat[b][a]=1;
}
scanf("%lld%lld",&a,&b);
for(k=0;k<n;k++){
for(i=0;i<n;i++){
for(j=0;j<n;j++){
if(mat[i][j]>mat[i][k]+mat[k][j]){
mat[i][j]=mat[i][k]+mat[k][j];
}
}
}
}
ll ans=0;
for(i=0;i<n;i++){
ans=max(ans,mat[a][i]+mat[i][b]);
}
printf("Case %lld: %lld\n",cz+1,ans);
}
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgaW5mIDEwMDAwMDAwMDAKbGwgbWF0WzEwNV1bMTA1XTsKCgppbnQgbWFpbigpCnsKICAgIGxsIGksaixuLG0sdCxrLGEsYixjOwoKICAgIHNjYW5mKCIlbGxkIiwmdCk7CgogICAgZm9yKGxsIGN6PTA7Y3o8dDtjeisrKXsKICAgICAgICBzY2FuZigiJWxsZCVsbGQiLCZuLCZtKTsKCiAgICAgICAgZm9yKGk9MDtpPG47aSsrKXsKICAgICAgICAgICAgZm9yKGo9MDtqPG47aisrKXsKICAgICAgICAgICAgICAgIG1hdFtpXVtqXT1pbmY7CgogICAgICAgICAgICAgICAgaWYoaT09aikgbWF0W2ldW2pdPTA7CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIGZvcihpPTA7aTxtO2krKyl7CiAgICAgICAgICAgIHNjYW5mKCIlbGxkJWxsZCIsJmEsJmIpOwogICAgICAgICAgICBtYXRbYV1bYl09MTsKICAgICAgICAgICAgbWF0W2JdW2FdPTE7CiAgICAgICAgfQogICAgICAgICAgICBzY2FuZigiJWxsZCVsbGQiLCZhLCZiKTsKICAgICAgICBmb3Ioaz0wO2s8bjtrKyspewogICAgICAgICAgICBmb3IoaT0wO2k8bjtpKyspewogICAgICAgICAgICAgICAgZm9yKGo9MDtqPG47aisrKXsKICAgICAgICAgICAgICAgICAgICBpZihtYXRbaV1bal0+bWF0W2ldW2tdK21hdFtrXVtqXSl7CiAgICAgICAgICAgICAgICAgICAgICAgIG1hdFtpXVtqXT1tYXRbaV1ba10rbWF0W2tdW2pdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBsbCBhbnM9MDsKICAgICAgICBmb3IoaT0wO2k8bjtpKyspewogICAgICAgICAgICBhbnM9bWF4KGFucyxtYXRbYV1baV0rbWF0W2ldW2JdKTsKICAgICAgICB9CgogICAgICAgIHByaW50ZigiQ2FzZSAlbGxkOiAlbGxkXG4iLGN6KzEsYW5zKTsKICAgIH0KfQ==