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

class B:
    def __init__(self, txt: str):
        self.z: C = None
        self.y: B = None
        self.p: B = None
        self.txt = txt

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

i = A("i")
m = B("m")
j = C("j")
c = B("c")
b = C("b")
n = C("n")

i.o = c
i.x = n
m.z = b
m.y = c
m.p = c
j.w = b
j.s = c
c.z = n
c.y = m
c.p = m
b.w = n
b.s = m
n.w = b
n.s = c
assert b.s.y.z.w.s.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.x: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: C = None
        self.y: B = None
        self.p: B = None
        self.txt = txt

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

i = A("i")
m = B("m")
j = C("j")
c = B("c")
b = C("b")
n = C("n")

i.o = c
i.x = n
m.z = b
m.y = c
m.p = c
j.w = b
j.s = c
c.z = n
c.y = m
c.p = m
b.w = n
b.s = m
n.w = b
n.s = c
assert b.s.y.z.w.s.txt == "m"