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

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

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

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

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

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

j.z = a
j.o = a
i.z = j
i.s = a
a.z = j
a.s = i
assert a.z.o.z.txt == "j"