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

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

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

l = A("l")
c = B("c")
a = C("a")
h = A("h")
m = A("m")
e = C("e")
k = B("k")

l.z = a
c.v = k
a.q = e
h.z = e
m.z = a
e.q = a
k.v = c
assert a.q.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

l = A("l")
c = B("c")
a = C("a")
h = A("h")
m = A("m")
e = C("e")
k = B("k")

l.z = a
c.v = k
a.q = e
h.z = e
m.z = a
e.q = a
k.v = c
assert a.q.q.q.q.q.q.txt == "a"