import Text.Printf main=interact$f.span(>[]).map(map read.words).lines f(a,_:x)=unlines[printf"%5d"=<<[c*z::Int|c<-b,z<-y]|b<-a,y<-x]