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

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

n = A("n")
e = B("e")
k = A("k")
j = B("j")
l = A("l")
g = A("g")
a = B("a")
c = B("c")

n.w = g
e.s = a
e.r = j
k.w = g
j.s = c
j.r = a
l.w = g
g.w = k
a.s = c
a.r = j
c.s = a
c.r = a
assert n.w.w.w.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

n = A("n")
e = B("e")
k = A("k")
j = B("j")
l = A("l")
g = A("g")
a = B("a")
c = B("c")

n.w = g
e.s = a
e.r = j
k.w = g
j.s = c
j.r = a
l.w = g
g.w = k
a.s = c
a.r = j
c.s = a
c.r = a
assert n.w.w.w.w.w.w.w.w.txt == "k"