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

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

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

m = A("m")
b = B("b")
l = C("l")
h = B("h")
k = A("k")
a = A("a")

m.p = h
m.y = b
b.p = l
b.w = l
l.o = b
h.p = l
h.w = l
k.p = b
k.y = b
a.p = b
a.y = h
assert m.p.w.o.p.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.y: B = None
        self.txt = txt

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

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

m = A("m")
b = B("b")
l = C("l")
h = B("h")
k = A("k")
a = A("a")

m.p = h
m.y = b
b.p = l
b.w = l
l.o = b
h.p = l
h.w = l
k.p = b
k.y = b
a.p = b
a.y = h
assert m.p.w.o.p.o.w.txt == "l"