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

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

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

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

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

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

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