#include <cstdio>   #include <iostream>   #include <cstring>   #include <algorithm>   #include <cmath>   #include <bitset>   #include <vector>   #include <unordered_map>   using namespace std;      const int N = 100007, M = 500007, INF = 0x3f3f3f3f;      typedef long long ll;   typedef int itn;      int n, m, t, x;   int fa[N];   int deep[N];   int maxx;   int num[N];//每一层结点个数   int cnt;   int lson[N];//叶子节点   int head[N], ver[M], edge[M], nex[M], tot;   bitset<N> f[2007];//能否凑齐 x，使用 bitset 优化   int val[N];   unordered_map<int, int> vis;   //int vis[N];   bool ok[N];   vector<int> v[N];      void add(int x, itn y)   {    ver[tot] = y;    nex[tot] = head[x];    head[x] = tot ++ ;   }      void dfs1(int x)   {    deep[x] = deep[fa[x]] + 1;//这里根结点 deep[1] = 1 所以不用再 +1 了    num[deep[x]] ++ ;    maxx = max(maxx, deep[x]);//树的直径，实际上也就是最大深度    if (head[x] == -1) //没有子节点，说明是叶子结点     lson[deep[x]] ++ ;//每层的叶子结点个数    for (int i = head[x]; ~i; i = nex[i]) {     int y = ver[i];     dfs1(y);    }   }      void dfs2(itn x, int t)   {    if(x == 0)     return;    for (int i = 0; i < (int)v[x].size(); ++ i) {     if(val[x] > t || f[x - 1][t])      break;     t -= val[x], ok[v[x][i]] = true;    }    dfs2(x - 1, t);   }      void init()   {       memset(head, -1, sizeof head);       tot = 0;   }      void solve()   {       init();    scanf( %d%d , &n, &x);    for (int i = 2; i <= n; ++ i) {     scanf( %d , &fa[i]);     //add(i, fa[i]);     add(fa[i], i);    }    dfs1(1);//预处理每层结点个数    //把抽象的树转化为一个个物品，存到 v 里，离散化一下，种类（结点个数）和个数（层数）    //cout <<  ok  << endl;    //一共cnt种，    for (int i = 1; i <= maxx; ++ i) {     if (vis[num[i]]) {              v[vis[num[i]]].push_back(i);     }     else {               vis[num[i]] = ++ cnt;               val[cnt] = num[i];               v[cnt].push_back(i);//来找最后选了第几层     }    }       f[0][0] = 1;          for (int i = 1; i <= cnt; ++ i) {           f[i] = f[i - 1];     itn Size = v[i].size();     for (int j = 1; j <= Size; j <<= 1) {      Size -= j;      f[i] |= (f[i] << (j * val[i]));     }     if(Size > 0)      f[i] |= f[i] << (Size * val[i]);    }       if(f[cnt][x]) {     printf( %d n , maxx);     dfs2(cnt, x);//还原dp的方案     for (int i = 1; i <= n; ++ i) {      putchar(ok[deep[i]] ?  a  :  b );     }    }    //凑不齐， a  有剩余    else {     int res = INF;     for (int i = x; i >= 0; -- i) {      if(f[cnt][i]) {       res = i;//找到能凑到的最大的数       break;      }     }     dfs2(cnt, res);     int pos = -1;     for (int i = 1; i <= maxx; ++ i)     {      if(!ok[i] && lson[i] >= x - res) {       pos = i;       break;      }     }        printf( %d n , maxx + 1);        for (int i = 1; i <= n; ++ i) {      if(deep[i] == pos && head[i] == -1) {       if(res == x) {        putchar( b );       }       else        putchar( a ), ++ res;      }      else {       putchar(ok[deep[i]] ?  a  :  b );      }     }    }    return ;   }      itn main()   {       solve();    return 0;   }