#include<bits/stdc++.h>
using namespace std;
void dfs(int node,int t,int parent,vector<int>&tgl,vector<vector<int>>&tree,vector<int>&a)
{
//if(node==parent) return;
t += tgl[node];
if(t%2) a[node] ^=1;
for(auto e:tree[node])
{
if(e==parent) continue;
dfs(e,t,node,tgl,tree,a);
}
}
void solve(int tc)
{
int n,q; cin>>n>>q;
vector<vector<int>> tree(n+1);
vector<int>a(n+1);
for(int i=1;i<=n;i++) cin>>a[i];
int u,v;
for(int i=1;i<n;i++)
{
cin>>u>>v;
tree[u].push_back(v);
tree[v].push_back(u);
}
vector<int>tgl(n+1);
while(q--)
{
cin>>u;
tgl[u]++;
}
dfs(1,0,0,tgl,tree,a);
cout<<"Case "<<tc<<": ";
for(int i=1;i<=n;i++) cout<<a[i]<<" ";
cout<<endl;
}
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int t; cin>>t;
for(int i=1;i<=t;i++)
{
solve(i);
}}