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

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

c = A("c")
d = B("d")
l = A("l")
k = B("k")
j = A("j")
m = A("m")
g = B("g")
b = A("b")

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

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

c = A("c")
d = B("d")
l = A("l")
k = B("k")
j = A("j")
m = A("m")
g = B("g")
b = A("b")

c.r = j
c.w = g
d.s = k
d.v = b
l.r = b
l.w = k
k.s = g
k.v = c
j.r = b
j.w = g
m.r = c
m.w = k
g.s = k
g.v = c
b.r = j
b.w = d
assert g.v.w.s.v.r.r.r.r.txt == "b"