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

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

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

h = A("h")
n = B("n")
a = C("a")
c = C("c")
b = C("b")
e = B("e")
l = B("l")

h.x = c
n.x = c
a.q = l
c.q = n
b.q = e
e.x = c
l.x = a
assert b.q.x.q.x.q.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

h = A("h")
n = B("n")
a = C("a")
c = C("c")
b = C("b")
e = B("e")
l = B("l")

h.x = c
n.x = c
a.q = l
c.q = n
b.q = e
e.x = c
l.x = a
assert b.q.x.q.x.q.x.q.txt == "n"