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

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

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

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

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

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

a.w = m
a.p = n
n.r = m
n.t = m
b.w = n
b.p = n
e.w = n
e.p = m
l.w = n
l.p = n
m.r = n
m.t = n
assert m.r.t.r.r.t.t.txt == "m"