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

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

h = A("h")
l = B("l")
i = A("i")
c = B("c")
e = B("e")
k = B("k")
n = A("n")
f = A("f")
b = A("b")
j = B("j")

h.o = n
h.t = f
l.w = b
i.o = h
i.t = h
c.w = b
e.w = f
k.w = n
n.o = f
n.t = f
f.o = h
f.t = h
b.o = f
b.t = h
j.w = n
assert j.w.o.o.t.o.t.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.t: A = None
        self.txt = txt

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

h = A("h")
l = B("l")
i = A("i")
c = B("c")
e = B("e")
k = B("k")
n = A("n")
f = A("f")
b = A("b")
j = B("j")

h.o = n
h.t = f
l.w = b
i.o = h
i.t = h
c.w = b
e.w = f
k.w = n
n.o = f
n.t = f
f.o = h
f.t = h
b.o = f
b.t = h
j.w = n
assert j.w.o.o.t.o.t.o.txt == "h"