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

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

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

a = A("a")
i = B("i")
n = C("n")
k = C("k")
g = A("g")

a.y = n
a.s = n
a.q = i
i.o = a
n.p = k
k.p = n
g.y = n
g.s = n
g.q = i
assert k.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.q: B = None
        self.s: C = None
        self.txt = txt

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

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

a = A("a")
i = B("i")
n = C("n")
k = C("k")
g = A("g")

a.y = n
a.s = n
a.q = i
i.o = a
n.p = k
k.p = n
g.y = n
g.s = n
g.q = i
assert k.p.p.p.p.p.txt == "n"