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

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

e = A("e")
a = B("a")
c = A("c")
b = B("b")
k = A("k")
d = A("d")
j = B("j")
m = B("m")
i = B("i")

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

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

e = A("e")
a = B("a")
c = A("c")
b = B("b")
k = A("k")
d = A("d")
j = B("j")
m = B("m")
i = B("i")

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