#include<bits/stdc++.h> usingnamespacestd; typedeflonglong ll; #define pii pair<int, int> #define mk make_pair constint N = 1 << 18; constint mod = 1e9 + 7; intread() { int x = 0, f = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + c - '0', c = getchar(); return x * f; } constint MAXL = 20; structLinearBase { ll p[MAXL];
voidclear() { memset(p, 0, sizeof(p)); } voidinsert(ll x) { for (int i = MAXL - 1; i >= 0; i--) { if (x & (1ll << i)) { if (!p[i]) { p[i] = x; break; } x ^= p[i]; } } } ll query_max(ll x = 0) { ll res = x; for (int i = MAXL - 1; i >= 0; i--) res = max(res, res ^ p[i]); return res; }
ll query_min() { for (int i = 0; i < MAXL; i++) if (p[i]) return p[i]; return0; } voidrebuild() { for (int i = MAXL - 1; i >= 0; i--) for (int j = i - 1; j >= 0; j--) if ((p[i] >> j) & 1) p[i] ^= p[j]; } voidmergeFrom(const LinearBase &other) { for (int i = 0; i <= MAXL; i++) insert(other.p[i]); } ll query_kth(ll k, int n) { rebuild(); vector<ll> pp; for (int i = 0; i < MAXL; ++i) if (p[i]) pp.push_back(p[i]); if (pp.size() != n) k--; if (k > (1LL << pp.size()) - 1) return-1; ll ans = 0; for (int i = 0; i < pp.size(); ++i) if (k & (1LL << i)) { ans ^= pp[i]; } return ans; } } lb; intqpow(int a, int x, int mo) { int res = 1; while (x) { if (x & 1) res = 1ll * res * a % mo; x >>= 1; a = 1ll * a * a % mo; } return res; } intinc(int x, int y, int mo) { if (y < 0) y += mo; if (x + y >= mo) x -= mo; return x + y; } int Inv2; voidFWT(int *A, int n, int op, int t)//t=1 or t=2 and t=3 xor { for (int i = 2; i <= n; i <<= 1) { for (int j = 0, mid = i >> 1; j < n; j += i) for (int k = 0; k < mid; k++) {
for (int i = 0; i < n; ++i) A[i] = 1ll * A[i] * B[i] % mod; FWT(A, n, -1, t); } vector<pii> g[N]; int dep[N], vis[N]; int a[N], b[N], c[N]; voidwork(int x, int d) { if (x == MAXL) { c[d] = 1; return; } if (lb.p[x]) work(x + 1, d ^ lb.p[x]); work(x + 1, d); } voiddfs(int x, int d) { dep[x] = d; vis[x] = 1; for (pii now : g[x]) { int to = now.first; if (vis[to]) { lb.insert(dep[to] ^ dep[x] ^ now.second); } else { dfs(to, d ^ now.second); } } }
intmain() { int n = read(), m = read(), q = read(); for (int i = 1; i <= m; i++) { int u = read(), v = read(), w = read(); g[u].push_back(mk(v, w)); g[v].push_back(mk(u, w)); } dfs(1, 0); for (int i = 1; i <= n; i++) { a[dep[i]]++; b[dep[i]]++; } work(0, 0); FWTX(a, b, 1 << 18, 3); FWTX(a, c, 1 << 18, 3); while (q--) { int x = read(); printf("%d\n", a[x]); } }