#pragma GCC optimize("Ofast") #pragma GCC target("avx2") #define rd() ({long _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;}) #define rep(v,e) for(long v=0;v='a'); char*wp=wbuf; rep(y,26){ rep(x,26){ d[y][x]=rd(); *wp++='Y'; *wp++=' '; } wp[-1]='\n'; } for(long i=0,c;c=*s++-'a',c>=0;){ rep(e,26){ if(d[e][c]>i-a[e]){ wbuf[e*52+c*2]='N'; } } a[c]=i++; } write(1,wbuf,26*26*2); _exit(0); }