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

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

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

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

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

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

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

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

i.w = m
i.s = m
a.v = m
m.w = a
assert a.v.w.v.txt == "m"