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

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

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

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

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

n.z = m
e.x = h
e.s = h
e.y = h
e.q = m
h.u = c
h.t = e
h.w = m
m.t = h
m.w = e
m.u = e
c.t = h
c.w = e
c.u = e
assert h.t.y.u.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.txt = txt

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

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

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

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

n.z = m
e.x = h
e.s = h
e.y = h
e.q = m
h.u = c
h.t = e
h.w = m
m.t = h
m.w = e
m.u = e
c.t = h
c.w = e
c.u = e
assert h.t.y.u.w.q.txt == "m"