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

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

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

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

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

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

a.q = i
a.o = e
e.x = i
e.s = a
i.q = a
i.o = e
assert i.q.o.x.txt == "i"