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

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

a = A("a")
e = B("e")
b = A("b")
i = B("i")

a.z = b
e.t = i
b.z = a
i.t = e
assert a.z.z.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.t: B = None
        self.txt = txt

a = A("a")
e = B("e")
b = A("b")
i = B("i")

a.z = b
e.t = i
b.z = a
i.t = e
assert a.z.z.z.z.txt == "a"