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

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

m = A("m")
j = B("j")
a = B("a")
l = B("l")
n = B("n")
e = A("e")
i = A("i")
b = A("b")

m.z = j
j.w = a
j.r = a
a.w = n
a.r = l
l.w = n
l.r = j
n.w = j
n.r = j
e.z = a
i.z = a
b.z = n
assert i.z.r.w.w.w.r.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

m = A("m")
j = B("j")
a = B("a")
l = B("l")
n = B("n")
e = A("e")
i = A("i")
b = A("b")

m.z = j
j.w = a
j.r = a
a.w = n
a.r = l
l.w = n
l.r = j
n.w = j
n.r = j
e.z = a
i.z = a
b.z = n
assert i.z.r.w.w.w.r.txt == "l"