class A:
    def __init__(self, txt: str):
        self.q: 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.v: C = None
        self.y: C = None
        self.txt = txt

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

h.q = e
k.v = a
c.v = e
c.y = e
e.v = c
e.y = c
m.q = e
a.v = k
assert k.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.q: 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.v: C = None
        self.y: C = None
        self.txt = txt

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

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