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

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

l = A("l")
k = B("k")
c = A("c")
b = B("b")
m = A("m")
g = A("g")
j = A("j")
e = B("e")
h = A("h")
a = A("a")

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

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

l = A("l")
k = B("k")
c = A("c")
b = B("b")
m = A("m")
g = A("g")
j = A("j")
e = B("e")
h = A("h")
a = A("a")

l.w = h
l.r = j
k.u = e
c.w = j
c.r = j
b.u = k
m.w = j
m.r = c
g.w = l
g.r = j
j.w = g
j.r = g
e.u = k
h.w = l
h.r = m
a.w = g
a.r = g
assert e.u.u.u.txt == "k"