g x=[t|t<-[0..32],all(\i->x!!(t+i)>'0')[0,5,12,17]] f x|[i]<-g x=([1..i]>>"0")++'1':([i..48]>>"0") main=interact$f