main=interact$unlines.s(!).lines a!b|(x,y)<-span(<'J')$zipWith max a b=x++s max y s=scanr1