#include <bits/stdc++.h>
#define pb push_back
using namespace std;
int n,m,a[100005],b[100005],dp[100005];
vector <int> g[100005];
void dfs(int v, int u){
dp[v] += dp[u];
if(dp[v] & 1){
a[v] = 1 - a[v];
}
for(auto i : g[v]){
if(i == u) continue;
dfs(i,v);
}
}
int main(){
int tt;
cin >> tt;
int ind = 0;
while(tt--){
cin >> n >> m;
for(int i = 1; i <= n; i++){
cin >> a[i];
}
for(int i = 1; i < n; i++){
int x,y;
cin >> x >> y;
g[x].pb(y);
g[y].pb(x);
}
for(int i = 1; i <= m; i++){
cin >> b[i];
dp[b[i]]++;
}
dfs(1,0);
cout << "Case " << ++ind << ": ";
for(int i = 1; i <= n; i++){
cout << a[i] << ' ';
g[i].clear();
dp[i] = 0;
}
}
return 0;
}