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

a = A("a")
e = B("e")
l = C("l")
i = C("i")
h = B("h")
c = B("c")
d = A("d")
m = B("m")

a.p = d
a.t = l
a.y = l
e.o = l
l.w = c
l.q = i
i.w = c
i.q = l
h.o = i
c.o = l
d.p = a
d.t = l
d.y = i
m.o = l
assert h.o.q.q.w.o.q.w.o.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.t: C = None
        self.y: C = 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.q: C = None
        self.txt = txt

a = A("a")
e = B("e")
l = C("l")
i = C("i")
h = B("h")
c = B("c")
d = A("d")
m = B("m")

a.p = d
a.t = l
a.y = l
e.o = l
l.w = c
l.q = i
i.w = c
i.q = l
h.o = i
c.o = l
d.p = a
d.t = l
d.y = i
m.o = l
assert h.o.q.q.w.o.q.w.o.txt == "l"