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

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

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

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

a.w = l
l.w = a
m.u = l
m.v = l
m.s = a
assert a.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

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

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

a.w = l
l.w = a
m.u = l
m.v = l
m.s = a
assert a.w.w.w.txt == "l"