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

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

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

g = A("g")
b = B("b")
d = C("d")

g.t = b
b.z = d
d.p = b
assert d.p.z.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

g = A("g")
b = B("b")
d = C("d")

g.t = b
b.z = d
d.p = b
assert d.p.z.p.txt == "b"