func_code_string: #include <bits/stdc++.h>      using namespace std;      const int N = 2e5+5;   const long long inf = 0x3f3f3f3f3f3f3f3f;   typedef long long ll;   #define pb push_back      int n, m;   int a[N];   int g[N], v[N<<1], nxt[N<<1], tot, fa[N];   vector<int> c[N];   ll f[N], ans;      inline void add(int x, int y) {    v[++tot] = y, nxt[tot] = g[x], g[x] = tot;   }      void dfs(int x, int ff, int dep) {    fa[x] = ff, c[dep].pb(x), m = max(m, dep);    for (int i = g[x]; i; i = nxt[i]) {     int y = v[i];     if (y == ff) continue;     dfs(y, x, dep + 1);    }   }      inline void solve() {    scanf( %d , &n);    for (int i = 2; i <= n; i++) {     int x;     scanf( %d , &x);     add(i, x), add(x, i);    }    for (int i = 2; i <= n; i++) scanf( %d , &a[i]);    dfs(1, 0, 0);    for (int r = 1; r <= m; r++) {     ll max0 = -inf, min0 = inf, max1 = -inf, max2 = -inf;     for (int i = 0; i < (int)c[r].size(); i++) {      int x = c[r][i];      max0 = max(max0, (ll)a[x]), min0 = min(min0, (ll)a[x]);      max1 = max(max1, f[fa[x]] + a[x]);      max2 = max(max2, f[fa[x]] - a[x]);     }     for (int i = 0; i < (int)c[r].size(); i++) {      int x = c[r][i];      f[x] = max(f[fa[x]] + max(max0 - a[x], a[x] - min0), max(max1 - a[x], max2 + a[x]));      if (r == m) ans = max(ans, f[x]);     }    }    printf( %lld n , ans);   }      inline void init() {    ans = m = tot = 0;    for (int i = 1; i <= n; i++) c[i].clear(), g[i] = 0, f[i] = 0;   }      int main()   {    int T;    scanf( %d , &T);    while (T--) {     init();     solve();    }    return 0;   }