g=[[1,2,3],[2,3],[3,4,5],[4],[5,1,4]]
children v g = tail (head (filter (\n->head n ==v) g))
extend w g =map (\v->v:w) (children (head w) g)
extendall w g = concat (map (\v->extend v g) w)
allways k g
|k==1 =map (\c->[head c]) g
|otherwise =extendall (allways (k-1) g) g