def dfs(S): if S==(1<