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

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

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

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

h.w = f
f.w = l
f.x = e
f.o = i
m.x = d
e.w = f
a.w = l
a.x = h
a.o = f
d.x = m
l.w = f
i.w = l
i.x = e
i.o = a
c.x = d
k.w = h
k.x = e
k.o = f
assert i.o.w.w.x.w.x.w.x.w.x.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

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

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

h.w = f
f.w = l
f.x = e
f.o = i
m.x = d
e.w = f
a.w = l
a.x = h
a.o = f
d.x = m
l.w = f
i.w = l
i.x = e
i.o = a
c.x = d
k.w = h
k.x = e
k.o = f
assert i.o.w.w.x.w.x.w.x.w.x.txt == "e"