class A:
    def __init__(self, txt: str):
        self.o: B = 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.w: A = None
        self.txt = txt

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

i.o = h
h.o = e
n.w = a
e.o = k
m.o = h
d.w = i
k.o = e
a.o = h
assert a.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = 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.w: A = None
        self.txt = txt

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

i.o = h
h.o = e
n.w = a
e.o = k
m.o = h
d.w = i
k.o = e
a.o = h
assert a.o.o.o.o.o.txt == "k"