CJam, 130 bytes (safe)
q'p/{'s/{{"cjaei"#}%{)},{`}%S*}%']*}%'[*~]Y8#,:Y;0a\{{__a#{\{_T=}{1$E}w\;}{"T(:T; _T=co T)
:T)0e] _T=)Y=T\t _T=(Y=T\t"S/=~}?}/}:E~;
This is split across two lines for clarity; the newline is not included.
This is semi-golfed, which makes it that much harder to understand.
There are an infinite number of solutions here. If anybody wants to try and find one, I wish them good luck...
Solution:
aipeepceeaiaeeeaeeeccsiiiiaesnccccjccccijcjjccejccccjaajaaaijcjeeejaajaijcccccej