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

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

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

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

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

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

n.s = j
n.u = b
g.w = h
g.r = b
b.w = g
b.r = h
h.w = g
h.r = g
a.s = j
a.u = b
j.s = n
j.u = b
k.s = j
k.u = g
d.s = j
d.u = g
l.s = a
l.u = b
assert n.u.w.r.w.r.r.r.r.r.txt == "h"