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

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

a = A("a")
c = B("c")
e = A("e")

a.z = e
a.o = c
c.x = a
e.z = a
e.o = c
assert a.z.o.x.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.o: B = None
        self.txt = txt

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

a = A("a")
c = B("c")
e = A("e")

a.z = e
a.o = c
c.x = a
e.z = a
e.o = c
assert a.z.o.x.txt == "a"