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

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

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

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

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

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

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

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

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