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

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

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

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

i.o = n
i.q = a
h.t = k
k.w = e
k.q = h
m.t = k
c.w = h
c.q = m
l.w = m
l.q = m
a.w = m
a.q = e
n.o = i
n.q = d
e.t = l
d.w = m
d.q = e
assert k.w.t.w.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.q: C = None
        self.txt = txt

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

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

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

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