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

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

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

i = A("i")
g = B("g")
l = C("l")
b = B("b")

i.q = l
g.u = i
l.w = i
l.o = b
b.u = i
assert l.w.q.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

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

i = A("i")
g = B("g")
l = C("l")
b = B("b")

i.q = l
g.u = i
l.w = i
l.o = b
b.u = i
assert l.w.q.w.q.txt == "l"