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

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

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

c = A("c")
e = B("e")
j = C("j")
b = C("b")

c.w = e
c.o = e
e.u = c
e.w = c
j.u = b
j.y = c
b.u = j
b.y = c
assert e.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.o: B = None
        self.txt = txt

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

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

c = A("c")
e = B("e")
j = C("j")
b = C("b")

c.w = e
c.o = e
e.u = c
e.w = c
j.u = b
j.y = c
b.u = j
b.y = c
assert e.w.w.w.txt == "c"