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

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

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

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

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

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

c.z = m
m.y = l
l.y = m
assert m.y.y.y.txt == "l"