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

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

e = A("e")
i = B("i")
b = A("b")
m = B("m")
a = B("a")
d = A("d")
h = A("h")
l = A("l")

e.s = i
e.o = b
i.w = m
i.t = d
b.s = a
b.o = l
m.w = i
m.t = l
a.w = m
a.t = d
d.s = i
d.o = e
h.s = m
h.o = e
l.s = a
l.o = d
assert l.s.w.t.s.t.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.o: A = None
        self.txt = txt

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

e = A("e")
i = B("i")
b = A("b")
m = B("m")
a = B("a")
d = A("d")
h = A("h")
l = A("l")

e.s = i
e.o = b
i.w = m
i.t = d
b.s = a
b.o = l
m.w = i
m.t = l
a.w = m
a.t = d
d.s = i
d.o = e
h.s = m
h.o = e
l.s = a
l.o = d
assert l.s.w.t.s.t.txt == "d"