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

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

m = A("m")
j = B("j")
d = A("d")
e = A("e")
l = B("l")
b = A("b")
i = B("i")
k = A("k")

m.z = l
m.p = d
j.w = l
j.q = e
d.z = l
d.p = m
e.z = i
e.p = m
l.w = i
l.q = e
b.z = j
b.p = k
i.w = l
i.q = k
k.z = i
k.p = b
assert j.w.q.z.w.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.p: A = None
        self.txt = txt

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

m = A("m")
j = B("j")
d = A("d")
e = A("e")
l = B("l")
b = A("b")
i = B("i")
k = A("k")

m.z = l
m.p = d
j.w = l
j.q = e
d.z = l
d.p = m
e.z = i
e.p = m
l.w = i
l.q = e
b.z = j
b.p = k
i.w = l
i.q = k
k.z = i
k.p = b
assert j.w.q.z.w.txt == "l"