class SCC(): def __init__(self,n): self.n=n self.e=[[] for i in range(self.n)] self.re=[[] for i in range(self.n)] return def add_edge(self,s,t): self.e[s]+=[t] self.re[t]+=[s] return def scc(self): v=[0]*self.n g=[0]*self.n o=[] for i in range(self.n): if v[i]==0: q=[i] while len(q)>0: s=q[-1] v[s]=1 while g[s]0: g.add_clause(i,fi^1,j,fj^1) print(["NO","YES"][g.satisfiable()])