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

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

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

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

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

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

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

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

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

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

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

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

n.x = e
m.y = d
m.u = e
e.o = d
e.s = m
e.p = m
d.u = e
a.q = e
a.w = e
a.p = m
a.u = m
assert m.y.u.s.txt == "m"