func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 400003, INF = 0x3f3f3f3f;   int n, Q, sz[maxn], fa[maxn], son[maxn], dfn[maxn], cntdfn, rig[maxn],       top[maxn], dep[maxn], z[maxn];   vector<int> g[maxn];   struct T {     int mx, sum;     T operator+(T x) const { return (T){max(x.mx, x.sum + mx), sum + x.sum}; }   } t[maxn];   void init1(int u) {     sz[u] = 1;     int mxsz = -1;     for (int v : g[u]) {       dep[v] = dep[u] + 1;       init1(v);       if (sz[v] > mxsz) mxsz = sz[v], son[u] = v;       sz[u] += sz[v];     }   }   void init2(int u, int tp) {     top[u] = tp;     dfn[u] = ++cntdfn;     if (son[u]) init2(son[u], tp);     for (int v : g[u]) {       if (v == son[u]) continue;       init2(v, v);     }     rig[u] = cntdfn;   }   void solve(int p, int len) { t[p] = (T){-1, -len}, z[p] = 1; }   void pushdown(int p, int l, int r) {     if (z[p]) {       int mid = (l + r) >> 1;       solve(p << 1, mid - l + 1), solve(p << 1 | 1, r - mid);       z[p] = 0;     }   }   void add(int p, int l, int r, int pos, int k) {     if (l == r) {       t[p].sum += k, t[p].mx += k;       return;     }     pushdown(p, l, r);     int mid = (l + r) >> 1;     if (pos <= mid)       add(p << 1, l, mid, pos, k);     else       add(p << 1 | 1, mid + 1, r, pos, k);     t[p] = t[p << 1] + t[p << 1 | 1];   }   void cover(int p, int l, int r, int seg_l, int seg_r) {     if (seg_l <= l && r <= seg_r) {       solve(p, r - l + 1);       return;     }     pushdown(p, l, r);     int mid = (l + r) >> 1;     if (seg_l <= mid) cover(p << 1, l, mid, seg_l, seg_r);     if (seg_r > mid) cover(p << 1 | 1, mid + 1, r, seg_l, seg_r);     t[p] = t[p << 1] + t[p << 1 | 1];   }   T query(int p, int l, int r, int seg_l, int seg_r) {     if (seg_l <= l && r <= seg_r) return t[p];     pushdown(p, l, r);     int mid = (l + r) >> 1;     if (seg_l <= mid && seg_r > mid)       return query(p << 1, l, mid, seg_l, seg_r) +              query(p << 1 | 1, mid + 1, r, seg_l, seg_r);     else if (seg_l <= mid)       return query(p << 1, l, mid, seg_l, seg_r);     else       return query(p << 1 | 1, mid + 1, r, seg_l, seg_r);   }   T query(int x) {     T ret = (T){-INF, 0};     while (x) {       ret = query(1, 1, n, dfn[top[x]], dfn[x]) + ret;       x = fa[top[x]];     }     return ret;   }   int main() {     scanf( %d%d , &n, &Q);     for (int i = 2; i <= n; i++) scanf( %d , fa + i), g[fa[i]].push_back(i);     init1(1), init2(1, 1), cover(1, 1, n, 1, n);     while (Q--) {       int mo, x;       scanf( %d%d , &mo, &x);       if (mo == 1) {         add(1, 1, n, dfn[x], 1);       }       if (mo == 2) {         cover(1, 1, n, dfn[x], rig[x]);         int tmp = max(query(x).mx + 1, 0);         add(1, 1, n, dfn[x], -tmp);       }       if (mo == 3) {         puts(query(x).mx >= 0 ?  black  :  white );       }     }     return 0;   }   