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

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

b = A("b")
d = B("d")
m = B("m")
h = A("h")
k = B("k")
a = B("a")
n = A("n")
j = B("j")
c = A("c")
l = A("l")

b.s = c
b.w = n
d.s = a
d.y = l
m.s = d
m.y = h
h.s = b
h.w = b
k.s = j
k.y = c
a.s = k
a.y = l
n.s = h
n.w = l
j.s = k
j.y = l
c.s = h
c.w = l
l.s = b
l.w = n
assert b.w.s.w.w.w.s.w.w.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.w: A = None
        self.txt = txt

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

b = A("b")
d = B("d")
m = B("m")
h = A("h")
k = B("k")
a = B("a")
n = A("n")
j = B("j")
c = A("c")
l = A("l")

b.s = c
b.w = n
d.s = a
d.y = l
m.s = d
m.y = h
h.s = b
h.w = b
k.s = j
k.y = c
a.s = k
a.y = l
n.s = h
n.w = l
j.s = k
j.y = l
c.s = h
c.w = l
l.s = b
l.w = n
assert b.w.s.w.w.w.s.w.w.s.w.txt == "n"