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

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

e = A("e")
n = B("n")
h = A("h")
d = A("d")
b = A("b")
i = B("i")

e.z = d
n.q = b
h.z = e
d.z = e
b.z = e
i.q = e
assert i.q.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

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

e = A("e")
n = B("n")
h = A("h")
d = A("d")
b = A("b")
i = B("i")

e.z = d
n.q = b
h.z = e
d.z = e
b.z = e
i.q = e
assert i.q.z.z.txt == "e"