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

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

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

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

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

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

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

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

j.t = d
d.p = j
b.p = d
assert d.p.t.p.txt == "j"