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

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

b = A("b")
n = B("n")
k = A("k")
e = B("e")
i = A("i")
h = B("h")
a = A("a")

b.s = n
b.p = e
n.w = h
n.s = e
k.s = n
k.p = n
e.w = n
e.s = h
i.s = e
i.p = h
h.w = e
h.s = e
a.s = h
a.p = h
assert b.s.s.w.w.w.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.p: B = None
        self.txt = txt

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

b = A("b")
n = B("n")
k = A("k")
e = B("e")
i = A("i")
h = B("h")
a = A("a")

b.s = n
b.p = e
n.w = h
n.s = e
k.s = n
k.p = n
e.w = n
e.s = h
i.s = e
i.p = h
h.w = e
h.s = e
a.s = h
a.p = h
assert b.s.s.w.w.w.s.txt == "h"