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

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

k = A("k")
l = B("l")
b = B("b")
e = B("e")
g = B("g")
f = A("f")
m = B("m")
a = B("a")
i = A("i")
n = A("n")

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

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

k = A("k")
l = B("l")
b = B("b")
e = B("e")
g = B("g")
f = A("f")
m = B("m")
a = B("a")
i = A("i")
n = A("n")

k.z = b
l.p = b
l.w = i
b.p = l
b.w = i
e.p = g
e.w = n
g.p = e
g.w = i
f.z = b
m.p = b
m.w = i
a.p = e
a.w = f
i.z = l
n.z = g
assert n.z.p.w.z.w.z.w.z.txt == "l"