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

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

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

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

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

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

d.u = m
i.u = m
i.y = n
i.w = n
i.z = e
c.y = d
c.w = d
e.v = c
e.p = m
n.x = m
n.y = c
n.u = d
m.u = i
m.y = n
m.w = n
m.z = e
assert n.u.u.z.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

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

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

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

d.u = m
i.u = m
i.y = n
i.w = n
i.z = e
c.y = d
c.w = d
e.v = c
e.p = m
n.x = m
n.y = c
n.u = d
m.u = i
m.y = n
m.w = n
m.z = e
assert n.u.u.z.txt == "e"