func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     vector<int> a(n);     for (int i = 0; i < int(n); i++) {       cin >> a[i];     }     vector<vector<int>> g(n);     for (int i = 0; i < int(n - 1); i++) {       int p;       cin >> p;       p--;       g[p].push_back(i + 1);     }     vector<int> color(n);     function<void(int)> dfs = [&](int u) {       for (const auto& v : g[u]) {         color[v] = color[u] ^ 1;         dfs(v);       }     };     dfs(0);     int WHITE = 0;     for (int i = 0; i < int(n); i++) {       if (g[i].empty()) {         WHITE = color[i];       }     }     int nim_sum = 0;     map<int, int> freq;     for (int i = 0; i < int(n); i++) {       if (color[i] == WHITE) {         nim_sum ^= a[i];         ++freq[a[i]];       }     }     long long ans = 0;     if (nim_sum == 0) {       int cnt = 0;       for (int i = 0; i < int(n); i++) {         if (color[i] != WHITE) {           cnt++;         }       }       ans = (long long)cnt * (cnt - 1) / 2 +             (long long)(n - cnt) * (n - cnt - 1) / 2;     }     for (int i = 0; i < int(n); i++) {       if (color[i] != WHITE) {         ans += freq[nim_sum ^ a[i]];       }     }     cout << ans << endl;   }   