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

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

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

i = A("i")
m = B("m")
j = C("j")
e = A("e")
b = A("b")

i.x = b
i.w = m
m.o = j
j.s = m
e.x = b
e.w = m
b.x = e
b.w = m
assert b.w.o.s.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.w: B = None
        self.txt = txt

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

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

i = A("i")
m = B("m")
j = C("j")
e = A("e")
b = A("b")

i.x = b
i.w = m
m.o = j
j.s = m
e.x = b
e.w = m
b.x = e
b.w = m
assert b.w.o.s.txt == "m"