def f(A, B): return ((A and B) == ((not B) <= (not A))) ^ A print("A B f") for A in (0, 1): for B in (0, 1): print(A, B, f(A, B))