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

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

e = A("e")
i = B("i")
n = B("n")

e.z = i
e.w = n
i.v = e
n.v = e
assert n.v.z.v.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.w: B = None
        self.txt = txt

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

e = A("e")
i = B("i")
n = B("n")

e.z = i
e.w = n
i.v = e
n.v = e
assert n.v.z.v.txt == "e"