De Morgan's laws

De Morgan's laws turn an AND into an OR, and an OR into an AND, by flipping every input and the output.

What to build

For three input bits, compute both sides of each law and print them.

Requirements

  • Line 1: the left side (A·B·C)' and then the right side A' + B' + C'.
  • Line 2: the left side (A + B + C)' and then the right side A'·B'·C'.
  • Each line shows the two values separated by a space.

Input

One line with three bits, a, b and c.

Output

Two lines of two bits each.

Constraints

a, b and c are each 0 or 1.

Example

Input:

1 0 1

Output:

1 1
0 0

Why it works

A law is true when both sides agree on every input. With three inputs there are eight cases, so the eight possible inputs are a complete proof: on each line the two numbers are always the same, and the program shows it for the case you give.

Examples

Example 1 · Input
1 0 1
Expected output
1 1
0 0
Example 2 · Input
1 1 1
Expected output
0 0
0 0

Prompts inside input() are ignored when checking, so input("n: ") is fine.

Hints

Hint 1

De Morgan's laws for three variables: (A.B.C)' = A' + B' + C' and (A + B + C)' = A'.B'.C'.

Hint 2

In Python, with bits 0 and 1, `1 - x` is NOT x, `a & b` is AND and `a | b` is OR.

Hint 3

The two numbers on one line must always be equal. That is what the law says.

Solution

Show one correct solution (try it yourself first)
a, b, c = map(int, input().split())
na, nb, nc = 1 - a, 1 - b, 1 - c
print(1 - (a & b & c), na | nb | nc)
print(1 - (a | b | c), na & nb & nc)

▶ Open this solution in the compiler, then press Visualize to watch it run step by step

Lesson: Boolean algebra →