func_code_string: #include <bits/stdc++.h>   using namespace std;   void DFS(long long n, long long p, long long d,            vector<pair<long long, long long>> &D, vector<long long> &Pa,            vector<vector<long long>> &G) {     for (long long nn : G[n]) {       if (nn == p) continue;       D.emplace_back(d + 1, nn);       Pa[nn] = n;       DFS(nn, n, d + 1, D, Pa, G);     }   }   void solve() {     long long n, m;     cin >> n >> m;     vector<long long> P(n), H(n);     for (int i = 0; i < n; i++) cin >> P[i];     for (int i = 0; i < n; i++) cin >> H[i];     vector<vector<long long>> G(n, vector<long long>());     vector<long long> Eg(n, 0), Eb(n, 0);     vector<long long> Pa(n, 0);     vector<pair<long long, long long>> D;     for (int i = 0; i < n - 1; i++) {       long long u, v;       cin >> u >> v;       u--;       v--;       G[u].push_back(v);       G[v].push_back(u);     }     DFS(0, -1, 0, D, Pa, G);     sort(D.begin(), D.end());     reverse(D.begin(), D.end());     D.emplace_back(0, 0);     for (const auto &p : D) {       long long node = p.second;       Eb[node] += P[node];       long long h = H[node];       if ((Eg[node] - Eb[node] > h) ||           (abs(Eg[node] - Eb[node]) % 2 != abs(h) % 2) ||           (Eg[node] + Eb[node] < abs(h))) {         cout <<  NO n ;         return;       }       long long x = h - (Eg[node] - Eb[node]);       long long Ag = Eg[node] + x / 2;       long long Ab = Eb[node] - x / 2;       if (Ab < 0) {         cout <<  NO n ;         return;       }       if (node == 0 && Ag + Ab != m) {         cout <<  NO n ;         return;       }       Eg[Pa[node]] += Ag;       Eb[Pa[node]] += Ab;     }     cout <<  YES n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int t;     cin >> t;     for (int i = 0; i < t; i++) solve();   }   