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

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

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

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

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

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

a.z = c
i.o = a
i.t = c
c.o = a
c.t = i
assert c.o.z.o.txt == "a"