#include <bits/stdc++.h>   using namespace std;   inline int read() {     int res = 0, f = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) f = -f;       ch = getchar();     }     while (isdigit(ch)) {       res = res * 10 + ch -  0 ;       ch = getchar();     }     return res * f;   }   namespace qiqi {   const int N = 3005;   int n, m, ecnt, head[N], a[N], siz[N];   pair<long long, long long> f[N][N], g[N];   struct Edge {     int v, nxt;   } e[N << 1];   inline void add(int u, int v) {     e[++ecnt] = (Edge){v, head[u]};     head[u] = ecnt;   }   void dfs(int u, int fa) {     f[u][siz[u] = 1] = make_pair(0, a[u]);     for (int k = head[u], v = e[k].v; k; v = e[k = e[k].nxt].v)       if (v != fa) {         dfs(v, u);         for (int i = (1); i <= (siz[u] + siz[v]); ++i) g[i] = make_pair(-1, 0);         for (int i = (siz[u]); i >= (1); --i)           for (int j = (siz[v]); j >= (1); --j) {             g[i + j] = max(g[i + j], make_pair(f[u][i].first + f[v][j].first +                                                    (f[v][j].second > 0),                                                f[u][i].second));             g[i + j - 1] =                 max(g[i + j - 1], make_pair(f[u][i].first + f[v][j].first,                                             f[u][i].second + f[v][j].second));           }         siz[u] += siz[v];         for (int i = (1); i <= (siz[u]); ++i) f[u][i] = g[i];       }   }   void main() {     memset(head, ecnt = 0, sizeof(head));     n = read();     m = read();     for (int i = (1); i <= (n); ++i) a[i] = read();     for (int i = (1); i <= (n); ++i) a[i] = read() - a[i];     int u, v;     for (int i = (2); i <= (n); ++i) {       u = read();       v = read();       add(u, v);       add(v, u);     }     dfs(1, 0);     printf( %lld n , f[1][m].first + (f[1][m].second > 0));   }   }  // namespace qiqi   int main() {     int T = read();     while (T--) qiqi::main();     return 0;   }   