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

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

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

b = A("b")
d = B("d")
l = C("l")
e = B("e")
m = C("m")

b.w = l
d.t = b
l.w = d
e.t = b
m.w = d
assert b.w.w.t.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

b = A("b")
d = B("d")
l = C("l")
e = B("e")
m = C("m")

b.w = l
d.t = b
l.w = d
e.t = b
m.w = d
assert b.w.w.t.txt == "b"