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

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

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

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

m = A("m")
h = B("h")
e = C("e")
n = D("n")
l = D("l")
d = B("d")

m.q = e
m.z = e
h.u = e
e.s = m
n.z = h
n.u = m
l.z = h
l.u = m
d.u = e
assert m.z.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.z: C = None
        self.txt = txt

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

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

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

m = A("m")
h = B("h")
e = C("e")
n = D("n")
l = D("l")
d = B("d")

m.q = e
m.z = e
h.u = e
e.s = m
n.z = h
n.u = m
l.z = h
l.u = m
d.u = e
assert m.z.s.q.txt == "e"