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

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

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

n = A("n")
c = B("c")
i = C("i")
m = A("m")
h = C("h")
l = B("l")

n.s = i
c.o = l
i.p = h
i.w = h
i.y = c
m.s = h
h.p = i
h.w = i
h.y = l
l.o = c
assert m.s.y.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

n = A("n")
c = B("c")
i = C("i")
m = A("m")
h = C("h")
l = B("l")

n.s = i
c.o = l
i.p = h
i.w = h
i.y = c
m.s = h
h.p = i
h.w = i
h.y = l
l.o = c
assert m.s.y.o.o.txt == "l"