r=read l[a,b,[c]]=((r a,r b),c) g i=unlines[[maybe '-'id$lookup(x,y)p|x<-e w]|y<-e h]where p=map(l.words)$lines i a x=(minimum x,maximum x) r f=a$map(f.fst)p w=r fst h=r snd e(a,b)=[a..b::Int] main=interact g