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

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

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

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

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

c = A("c")
g = B("g")
d = C("d")
m = D("m")
a = E("a")

c.x = a
g.u = a
g.r = a
d.w = c
m.x = c
m.z = c
m.y = d
m.s = a
m.u = g
a.z = m
a.o = m
a.y = d
a.t = c
assert m.z.x.t.x.z.txt == "
class A:
    def __init__(self, txt: str):
        self.x: E = None
        self.txt = txt

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

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

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

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

c = A("c")
g = B("g")
d = C("d")
m = D("m")
a = E("a")

c.x = a
g.u = a
g.r = a
d.w = c
m.x = c
m.z = c
m.y = d
m.s = a
m.u = g
a.z = m
a.o = m
a.y = d
a.t = c
assert m.z.x.t.x.z.txt == "m"