#!/usr/bin/env python3
def UnitProp(S):
Q = [ c for c in S if len(c)==1 ]
while len(Q)>0:
z = Q.pop()[0]; T = []
for C in S:
C = [j for j in C if j!=-z]
if len(C)==0: return False
if len(C)==1: Q.append(C)
if not z in C: T.append(C)
if len(T)==0: return True
S = T
return S
if __name__ == "__main__":
assert UnitProp([ [1], [-1,2] ,[-1,3,4] ]) == [ [3,4] ]