#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
void solve(int cs) {
int n, q;
cin >> n >> q;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
vector<vector<int>> g(n);
for (int i = 0; i < n - 1; i++) {
int u, v;
cin >> u >> v, --u, --v;
g[u].push_back(v);
g[v].push_back(u);
}
int timer = 0;
vector<int> in(n, 0), out(n, 0);
auto dfs = [&](auto &&self, int node, int par) -> void {
in[node] = ++timer;
for (auto &nodes : g[node]) {
if (nodes != par) {
self(self, nodes, node);
}
}
out[node] = timer;
};
dfs(dfs, 0, -1);
vector<int> bit(2 * n + 1, 0);
auto update = [&](int idx, int val) -> void {
for (; idx < 2 * n; idx += idx & -idx) bit[idx] ^= val;
};
auto query = [&](int idx) -> int {
int S = 0;
for (;idx; idx -= idx & -idx) S ^= bit[idx];
return S;
};
while (q--) {
int v;
cin >> v, --v;
update(in[v], 1);
update(out[v] + 1, 1);
}
for (int i = 0; i < n; i++) {
a[i] ^= (query(in[i]) % 2);
}
cout << "Case " << cs << ": ";
for (int i = 0; i < n; i++) {
cout << a[i] << " \n"[i == n - 1];
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int tc = 1;
cin >> tc;
for (int cs = 1; cs <= tc; cs++) {
solve(cs);
}
return 0;
}