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

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

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

d = A("d")
i = B("i")
l = C("l")
j = C("j")
g = C("g")

d.t = i
i.y = l
l.z = d
l.s = d
j.z = d
j.s = d
g.z = d
g.s = d
assert g.s.t.y.s.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

d = A("d")
i = B("i")
l = C("l")
j = C("j")
g = C("g")

d.t = i
i.y = l
l.z = d
l.s = d
j.z = d
j.s = d
g.z = d
g.s = d
assert g.s.t.y.s.txt == "d"