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

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

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

m = A("m")
l = B("l")
e = C("e")
d = B("d")

m.z = e
l.s = e
l.y = d
e.w = l
d.s = e
d.y = l
assert l.s.w.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

m = A("m")
l = B("l")
e = C("e")
d = B("d")

m.z = e
l.s = e
l.y = d
e.w = l
d.s = e
d.y = l
assert l.s.w.s.w.txt == "l"