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

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

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

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

d.t = m
m.o = d
a.o = d
assert m.o.t.o.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

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

d.t = m
m.o = d
a.o = d
assert m.o.t.o.txt == "d"