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

j = A("j")
c = B("c")
a = C("a")
n = B("n")
b = B("b")

j.p = a
j.u = c
c.o = a
a.w = n
n.o = a
b.o = a
assert j.p.w.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.u: 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.w: B = None
        self.txt = txt

j = A("j")
c = B("c")
a = C("a")
n = B("n")
b = B("b")

j.p = a
j.u = c
c.o = a
a.w = n
n.o = a
b.o = a
assert j.p.w.o.w.txt == "n"