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

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

class C:
    def __init__(self, txt: str):
        self.s: C = None
        self.x: C = None
        self.txt = txt

e = A("e")
i = B("i")
n = C("n")
d = C("d")
a = C("a")
b = A("b")
c = C("c")
j = B("j")
l = A("l")
m = A("m")

e.s = l
e.w = c
i.r = d
n.s = c
n.x = a
d.s = n
d.x = c
a.s = n
a.x = n
b.s = m
b.w = n
c.s = d
c.x = d
j.r = d
l.s = b
l.w = a
m.s = b
m.w = a
assert m.w.x.s.s.x.x.s.s.x.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.w: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.s: C = None
        self.x: C = None
        self.txt = txt

e = A("e")
i = B("i")
n = C("n")
d = C("d")
a = C("a")
b = A("b")
c = C("c")
j = B("j")
l = A("l")
m = A("m")

e.s = l
e.w = c
i.r = d
n.s = c
n.x = a
d.s = n
d.x = c
a.s = n
a.x = n
b.s = m
b.w = n
c.s = d
c.x = d
j.r = d
l.s = b
l.w = a
m.s = b
m.w = a
assert m.w.x.s.s.x.x.s.s.x.txt == "d"