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

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

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

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

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

n = A("n")
d = B("d")
i = C("i")
h = D("h")
e = E("e")
c = C("c")
l = E("l")

n.y = e
n.z = e
n.s = i
d.p = l
d.o = c
d.q = i
i.w = d
i.y = d
i.z = c
h.s = d
h.x = n
h.p = n
e.q = n
e.u = h
c.w = d
c.y = d
c.z = i
l.q = n
l.u = h
assert h.x.y.q.z.txt == "
class A:
    def __init__(self, txt: str):
        self.y: E = None
        self.s: C = None
        self.z: E = None
        self.txt = txt

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

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

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

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

n = A("n")
d = B("d")
i = C("i")
h = D("h")
e = E("e")
c = C("c")
l = E("l")

n.y = e
n.z = e
n.s = i
d.p = l
d.o = c
d.q = i
i.w = d
i.y = d
i.z = c
h.s = d
h.x = n
h.p = n
e.q = n
e.u = h
c.w = d
c.y = d
c.z = i
l.q = n
l.u = h
assert h.x.y.q.z.txt == "e"