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

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

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

i = A("i")
d = B("d")
c = C("c")

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

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

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

i = A("i")
d = B("d")
c = C("c")

i.q = d
d.o = i
d.s = i
c.q = i
c.o = d
assert c.q.q.s.txt == "i"