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

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

c = A("c")
a = B("a")
l = B("l")
m = A("m")
f = A("f")
e = A("e")
k = A("k")

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

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

c = A("c")
a = B("a")
l = B("l")
m = A("m")
f = A("f")
e = A("e")
k = A("k")

c.p = l
c.z = e
a.w = l
a.p = l
l.w = a
l.p = a
m.p = l
m.z = c
f.p = a
f.z = m
e.p = l
e.z = k
k.p = a
k.z = c
assert e.p.w.w.w.p.p.w.txt == "l"