a=System.in.readLines() 9.times{l=a[it] s=t='' 9.times{i->s+=' '+'^V'[a[it-1][i]<(c=l[i])?0:1] t+=i?d ':t t+=d=c}println it?s+'\n'+t-' ':t}