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

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

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

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

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

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

m.s = e
a.x = i
g.u = a
g.y = a
g.z = e
g.w = m
i.w = m
e.s = m
assert a.x.w.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: E = None
        self.txt = txt

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

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

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

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

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

m.s = e
a.x = i
g.u = a
g.y = a
g.z = e
g.w = m
i.w = m
e.s = m
assert a.x.w.s.s.txt == "m"