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

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

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

class D:
    def __init__(self, txt: str):
        self.w: A = None
        self.x: C = None
        self.txt = txt

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

m.z = d
d.p = l
d.u = e
h.y = l
h.u = l
h.w = d
h.o = m
l.w = m
l.x = h
e.z = d
assert h.w.u.z.u.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.w: A = None
        self.x: C = None
        self.txt = txt

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

m.z = d
d.p = l
d.u = e
h.y = l
h.u = l
h.w = d
h.o = m
l.w = m
l.x = h
e.z = d
assert h.w.u.z.u.z.txt == "d"