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

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

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

k = A("k")
h = B("h")
d = C("d")

k.t = h
h.s = k
d.y = h
assert h.s.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

k = A("k")
h = B("h")
d = C("d")

k.t = h
h.s = k
d.y = h
assert h.s.t.s.txt == "k"