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

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

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

d = A("d")
e = B("e")
b = C("b")
i = A("i")

d.o = b
e.q = i
e.u = b
b.y = d
b.s = d
b.o = i
i.o = b
assert e.q.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

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

d = A("d")
e = B("e")
b = C("b")
i = A("i")

d.o = b
e.q = i
e.u = b
b.y = d
b.s = d
b.o = i
i.o = b
assert e.q.o.o.txt == "i"