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

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

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

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

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

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

l.s = i
l.o = a
a.q = i
a.z = i
i.q = a
i.z = a
assert l.o.q.z.txt == "a"