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

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

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

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

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

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

i.o = e
i.u = b
b.q = e
b.u = a
e.q = b
e.u = a
a.o = e
a.u = e
assert i.o.q.u.txt == "a"