z=0 _=' '*79 for L in eval('_+raw_input()+_,'*7)*180:t=L[z/7:];print t[:50]+' # *'[t[50]>_::2][z%7==3]+t[51:80]+z%7/6*'\n';z+=1