#include <vector>
#include <numeric>
#include <iostream>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
vector<pair<int, int>> moves = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
int tt;
cin >> tt;
for (int tc = 1; tc <= tt; tc++) {
cout << "Case " << tc << ":";
int n, q;
cin >> n >> q;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
vector<vector<int>> e(n);
for (int i = 0; i < n - 1; i++) {
int u, v;
cin >> u >> v;
u--;
v--;
e[u].push_back(v);
e[v].push_back(u);
}
vector<int> b(n);
for (int i = 0; i < q; i++) {
int x;
cin >> x;
b[x - 1] ^= 1;
}
vector<int> que(1, 0), par(n, -1);
for (int i = 0; i < (int) que.size(); i++) {
int v = que[i];
a[v] ^= b[v];
for (int u : e[v]) {
if (u != par[v]) {
par[u] = v;
b[u] ^= b[v];
que.push_back(u);
}
}
}
for (int i = 0; i < n; i++) {
cout << ' ' << a[i];
}
cout << '\n';
}
return 0;
}