#include using namespace std; #define next nnnnnnn const int sz = 400400; typedef long long ll; int N, Q; int node[sz], next[sz], to[sz], dep[sz], e; ll X[sz], dp[19][sz], D; void ins(int x, int y) {e++; next[e] = node[x]; node[x] = e; to[e] = y;} void dfs(int x, int p){ for (int j = node[x]; j; j = next[j]) if (to[j] != p) dep[to[j]] = dep[x] + 1, dfs(to[j], x); dp[0][dep[x]] ^= X[x]; } int main(){ int i, j, a, b, c, tn = 1, _ = 0; cin.sync_with_stdio(0); cin >> N >> Q; for (i = 1; i < N; i++) {cin >> a >> b; ins(a, b); ins(b, a);} for (i = 0; i < N; i++) cin >> X[i]; dfs(0, -1); for (; tn <= N; tn <<= 1, _++); for (i = 0; i < _; i++) for (j = 0; j < tn; j++) { dp[i + 1][j] = dp[i][j ^ (1 << i)]; if (~(j >> i) & 1) dp[i + 1][j] ^= dp[i][j]; } while (Q--) {cin >> D; cout << dp[_][(D - 1) & (tn - 1)] << endl;} return 0; }