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

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

e = A("e")
l = B("l")
c = A("c")
j = B("j")
a = A("a")
i = A("i")
d = B("d")

e.z = a
e.p = c
l.w = a
l.t = c
c.z = a
c.p = a
j.w = c
j.t = e
a.z = i
a.p = e
i.z = c
i.p = e
d.w = c
d.t = e
assert l.w.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.p: A = None
        self.txt = txt

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

e = A("e")
l = B("l")
c = A("c")
j = B("j")
a = A("a")
i = A("i")
d = B("d")

e.z = a
e.p = c
l.w = a
l.t = c
c.z = a
c.p = a
j.w = c
j.t = e
a.z = i
a.p = e
i.z = c
i.p = e
d.w = c
d.t = e
assert l.w.z.z.txt == "c"