from itertools import permutations, product

def implication(a, b):
    return not a or b

def f1(x, y, z, w):
    return int(implication(w, y) == implication(z, x))

def f2(x, y, z, w):
    return int(implication(w, y) and (not x) == z)

# строки фрагмента: 4 столбца, F1, F2 ('?' - пусто)
rows = [
    (0, '?', 0, 0, 0, 1),
    (0, 0, 0, '?', 0, '?'),
    (0, 1, 1, '?', '?', 0),
]

for p in permutations('xyzw'):          # p[i] - переменная в (i+1)-м столбце
    ok = True
    for row in rows:
        found = False
        for x, y, z, w in product((0, 1), repeat=4):
            d = {'x': x, 'y': y, 'z': z, 'w': w}
            vals = [d[c] for c in p] + [f1(x, y, z, w), f2(x, y, z, w)]
            good = True
            for r, v in zip(row, vals):
                if r != '?' and r != v:
                    good = False
            if good:
                found = True
        if not found:
            ok = False
    if ok:
        print(''.join(p))