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

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

e = A("e")
d = B("d")
m = A("m")
j = A("j")
n = B("n")
f = A("f")
h = A("h")
k = A("k")
a = A("a")
l = A("l")

e.w = m
e.s = d
d.r = n
m.w = l
m.s = n
j.w = h
j.s = n
n.r = d
f.w = k
f.s = n
h.w = j
h.s = d
k.w = m
k.s = n
a.w = k
a.s = n
l.w = a
l.s = d
assert m.w.s.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.s: B = None
        self.txt = txt

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

e = A("e")
d = B("d")
m = A("m")
j = A("j")
n = B("n")
f = A("f")
h = A("h")
k = A("k")
a = A("a")
l = A("l")

e.w = m
e.s = d
d.r = n
m.w = l
m.s = n
j.w = h
j.s = n
n.r = d
f.w = k
f.s = n
h.w = j
h.s = d
k.w = m
k.s = n
a.w = k
a.s = n
l.w = a
l.s = d
assert m.w.s.r.r.r.r.txt == "d"