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

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

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

h = A("h")
f = B("f")
n = C("n")
k = B("k")
e = B("e")
i = C("i")
a = C("a")

h.s = a
f.q = k
n.x = i
k.q = f
e.q = f
i.x = n
a.x = n
assert i.x.x.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

h = A("h")
f = B("f")
n = C("n")
k = B("k")
e = B("e")
i = C("i")
a = C("a")

h.s = a
f.q = k
n.x = i
k.q = f
e.q = f
i.x = n
a.x = n
assert i.x.x.x.x.x.x.x.txt == "n"