func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = 2e5 + 10;   int Ans[MAXN * 2], L, R, n;   struct XY {     int sz = 0, totid = 0, Ret, ll, rr;     int las[MAXN * 10], top[MAXN], en[MAXN], pos[MAXN], siz[MAXN], dep[MAXN],         fa[MAXN], deleted[MAXN * 3];     struct Edge {       int to, pre;     } e[MAXN * 35];     void add(int a, int b) {       e[++sz].to = b;       e[sz].pre = las[a];       las[a] = sz;     }     void dfs1(int u, int father, int depth) {       dep[u] = depth;       fa[u] = father;       siz[u] = 1;       for (int i = las[u]; i; i = e[i].pre) {         dfs1(e[i].to, u, depth + 1);         siz[u] += siz[e[i].to];       }     }     void dfs2(int u, int tp) {       pos[u] = ++totid;       top[u] = tp;       int v = 0, maxisz = 0;       for (int i = las[u]; i; i = e[i].pre)         if (siz[e[i].to] > maxisz) v = e[i].to, maxisz = siz[e[i].to];       if (v) dfs2(v, tp);       for (int i = las[u]; i; i = e[i].pre)         if (e[i].to != v) dfs2(e[i].to, e[i].to);     }     void link(int rt, int l, int r) {       if (ll <= l && r <= rr) {         add(rt, Ret);         return;       }       int mid = (l + r) >> 1;       if (ll <= mid) link(rt << 1, l, mid);       if (rr > mid) link(rt << 1 | 1, mid + 1, r);     }     void insert(int x, int y, int id) {       while (top[x] != top[y]) {         if (dep[top[x]] < dep[top[y]]) swap(x, y);         ll = pos[top[x]];         rr = pos[x];         Ret = id;         link(1, 1, n);         x = fa[top[x]];       }       if (dep[x] < dep[y]) swap(x, y);       ll = pos[y] + 1;       rr = pos[x];       Ret = id;       if (ll <= rr) link(1, 1, n);     }     void query(int rt, int l, int r) {       for (int i = las[rt]; i; i = e[i].pre)         if (!deleted[e[i].to]) Ans[++R] = e[i].to, deleted[e[i].to] = 1;       las[rt] = 0;       int mid = (l + r) >> 1;       if (l == r) return;       if (ll <= mid)         query(rt << 1, l, mid);       else         query(rt << 1 | 1, mid + 1, r);     }     void doit(int t) {       ll = pos[t + 1];       query(1, 1, n);     }     void work(int l, int r) {       sort(Ans + l, Ans + r + 1);       for (int i = l; i <= r; ++i) printf( %d  , Ans[i]);       puts(  );       for (int i = l; i <= r; ++i) doit(Ans[i]);       L = r;     }     void read() {       for (int i = 2; i <= n; ++i) scanf( %d , &fa[i]), add(fa[i], i);       dfs1(1, -1, 1);       dfs2(1, 1);       for (int i = 0; i <= n + 9; ++i) las[i] = 0;       sz = 0;     }   } Tree[2];   int main() {     scanf( %d , &n);     Tree[0].read();     Tree[1].read();     for (int i = 2; i <= n; ++i) Tree[1].insert(Tree[0].fa[i], i, i - 1);     for (int i = 2; i <= n; ++i) Tree[0].insert(Tree[1].fa[i], i, i - 1);     scanf( %d , &Ans[++R]);     Tree[1].deleted[Ans[R]] = 1;     while (L < R) {       if (L < R) puts( Blue ), Tree[0].work(L + 1, R);       if (L < R) puts( Red ), Tree[1].work(L + 1, R);     }     return 0;   }   