($N,$M)=glob<>; @a=(0,glob<>); / /,${$`}{$a[$']}=${$'+0}{$a[$`]}=0for<>; print grep({ $a=$a[$_]; (1$a,keys%$_)|(1