for(w=readline(i=0);i++<1<<(j=w[-1]);w=w.slice(0,j)+t)for(print(w),t='';j&&(t=String.fromCharCode(w.charCodeAt(--j)^32)+t)