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

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

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

d = A("d")
a = B("a")
i = C("i")
m = B("m")

d.y = m
d.w = a
a.s = i
a.z = i
a.x = i
i.x = a
i.y = m
m.s = i
m.z = i
m.x = i
assert a.x.x.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.w: B = None
        self.txt = txt

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

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

d = A("d")
a = B("a")
i = C("i")
m = B("m")

d.y = m
d.w = a
a.s = i
a.z = i
a.x = i
i.x = a
i.y = m
m.s = i
m.z = i
m.x = i
assert a.x.x.s.txt == "i"