class A:
    def __init__(self, txt: str):
        self.s: C = 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.w: C = None
        self.txt = txt

l = A("l")
a = B("a")
b = C("b")
m = C("m")

l.s = m
a.o = l
b.w = m
m.w = b
assert a.o.s.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = 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.w: C = None
        self.txt = txt

l = A("l")
a = B("a")
b = C("b")
m = C("m")

l.s = m
a.o = l
b.w = m
m.w = b
assert a.o.s.w.w.txt == "m"