main=interact$k.span(>[]).map(map read.words).lines k(a,_:b)=unlines[do e<-c;f<-d;r$take 5$r$" "++show(e*f)|c<-a,d<-b] r=reverse