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

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

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

d = A("d")
c = B("c")
i = C("i")

d.z = c
c.u = i
i.w = c
i.s = d
assert c.u.w.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

d = A("d")
c = B("c")
i = C("i")

d.z = c
c.u = i
i.w = c
i.s = d
assert c.u.w.u.txt == "i"