func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 100010, mod = 998244353;   inline int read() {     int x = 0, f = 0;     char ch = getchar();     while (ch <  0  || ch >  9 ) f |= ch ==  - , ch = getchar();     while (ch >=  0  && ch <=  9 ) x = x * 10 + ch -  0 , ch = getchar();     return f ? -x : x;   }   int n, fa[maxn], dep[maxn], last = 1, chg, ans[maxn], al, seq[maxn], sl;   set<int> s[maxn];   int main() {     n = read();     for (int i = (2); i <= (n); i++) {       dep[i] = dep[fa[i] = read() + 1] + 1;       s[fa[i]].insert(i);       if (dep[i] > dep[last]) last = i;     }     chg = last;     while (chg != 1) {       while (chg != 1 && s[fa[chg]].size() == 1) chg = fa[chg];       if (chg != 1) {         int was = fa[chg];         set<int>::iterator hhh = s[was].find(chg);         for (set<int>::iterator it = s[was].begin(); it != s[was].end(); it++) {           int f = *it;           if (f == chg) continue;           s[f].insert(chg);           fa[chg] = f;           ans[++al] = chg - 1;           s[was].erase(hhh);           break;         }       }     }     for (int i = last; i; i = fa[i]) seq[++sl] = i - 1;     for (int i = (n); i >= (1); i--) printf( %d  , seq[i]);     printf(  n%d n , al);     for (int i = (al); i >= (1); i--) printf( %d  , ans[i]);   }   