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

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

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

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

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

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

c.o = i
a.q = c
a.y = c
i.q = c
i.y = c
assert i.y.o.q.txt == "c"