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

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

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

k = A("k")
n = B("n")
i = C("i")
l = C("l")

k.x = l
n.s = i
n.o = k
i.q = n
i.u = n
i.y = n
l.q = n
l.u = n
l.y = n
assert l.q.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

k = A("k")
n = B("n")
i = C("i")
l = C("l")

k.x = l
n.s = i
n.o = k
i.q = n
i.u = n
i.y = n
l.q = n
l.u = n
l.y = n
assert l.q.s.q.txt == "n"