import Control.Monad
import Data.List
f n s=if length s<n then f (s++" ") n else s 
g x m s=
main=do
 [n,m]<-map read.words<$>getLine
 an<-replicateM n getLine
 br<-replicateM m getLine
 let bn=map(f n)br
 let ap=[unlines(map (g x m) an)|x<-[0..n-m]]