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

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

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

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

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

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

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

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

d.z = c
c.s = a
a.s = c
assert d.z.s.s.txt == "c"