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

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

j = A("j")
l = B("l")
c = A("c")

j.z = l
l.w = c
c.z = l
assert c.z.w.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

j = A("j")
l = B("l")
c = A("c")

j.z = l
l.w = c
c.z = l
assert c.z.w.z.txt == "l"