@A=map[split$",<>],1..<>;map{($X,$Y)=split;$X>@$_[0]|$Y<@$_[1]||++$m[++$_[$i]]for@A;++$i}<>;$,=$/;print@m?grep$_[$_]==$#m,1..@_:0