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

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

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

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

m.q = i
i.z = l
e.r = h
e.w = i
c.z = l
b.z = m
l.q = b
h.z = m
n.z = l
assert c.z.q.z.q.z.q.z.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

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

m.q = i
i.z = l
e.r = h
e.w = i
c.z = l
b.z = m
l.q = b
h.z = m
n.z = l
assert c.z.q.z.q.z.q.z.txt == "m"