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

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

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

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

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

n = A("n")
a = B("a")
m = C("m")
i = D("i")
e = E("e")
b = A("b")

n.u = e
a.o = m
a.w = m
a.q = b
a.x = i
a.v = n
m.z = e
i.s = a
i.y = a
i.z = m
i.q = e
e.p = i
e.q = a
e.s = m
b.u = e
assert b.u.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.u: E = None
        self.txt = txt

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

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

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

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

n = A("n")
a = B("a")
m = C("m")
i = D("i")
e = E("e")
b = A("b")

n.u = e
a.o = m
a.w = m
a.q = b
a.x = i
a.v = n
m.z = e
i.s = a
i.y = a
i.z = m
i.q = e
e.p = i
e.q = a
e.s = m
b.u = e
assert b.u.q.x.txt == "i"