#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int M=107,maxn=100010;
int read(){
int ans=0,f=1,c=getchar();
while(c<‘0‘||c>‘9‘){if(c==‘-‘) f=-1; c=getchar();}
while(c>=‘0‘&&c<=‘9‘){ans=ans*10+(c-‘0‘); c=getchar();}
return ans*f;
}
int T,n,m,k,now,ans,cnt;
int h[M],v[M];
int f[2][maxn],map[M][M];
void clear(){
ans=0; cnt=1;
memset(map,0,sizeof(map));
memset(f,0,sizeof(f));
memset(v,0,sizeof(v));
}
int main()
{
T=read();
while(T--){
int x,y;
n=read(); m=read(); k=read();
clear();
for(int i=1;i<=m;i++) x=read(),y=read(),map[x][y]=map[y][x]=1;
for(int i=1;i<=k;i++) h[i]=read(),v[h[i]]=1;
int s=(1<<k)-1;
for(int i=1;i<=n;i++)if(!v[i]){
now=(++cnt)&1;
memset(f[now],0,sizeof(f[now]));
for(int j=0;j<=s;j++) f[now][j]=f[now^1][j];
for(int j=0;j<=s;j++){
for(int k1=1;k1<=k;k1++) if(!(j&(1<<(k1-1)))&&map[i][h[k1]]){
for(int k2=k1+1;k2<=k;k2++) if(!(j&(1<<(k2-1)))&&map[i][h[k2]]){
int nows=j^(1<<(k1-1))^(1<<(k2-1));
f[now][nows]=max(f[now][nows],f[now^1][j]+1);
}
}
}
}
for(int i=0;i<=s;i++) ans=max(ans,f[now][i]);
printf("%d\n",ans);
}
return 0;
}