class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.x: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

f = A("f")
n = B("n")
j = B("j")
e = A("e")

f.z = n
f.x = e
n.y = j
j.y = n
e.z = j
e.x = f
assert n.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.x: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

f = A("f")
n = B("n")
j = B("j")
e = A("e")

f.z = n
f.x = e
n.y = j
j.y = n
e.z = j
e.x = f
assert n.y.y.y.y.txt == "n"