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

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

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

class D:
    def __init__(self, txt: str):
        self.w: C = None
        self.t: E = None
        self.txt = txt

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

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

m.p = d
c.x = g
c.q = g
c.u = e
c.v = m
c.z = d
e.z = c
e.q = d
e.u = g
g.w = e
g.t = d
d.u = g
d.p = c
assert m.p.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.w: C = None
        self.t: E = None
        self.txt = txt

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

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

m.p = d
c.x = g
c.q = g
c.u = e
c.v = m
c.z = d
e.z = c
e.q = d
e.u = g
g.w = e
g.t = d
d.u = g
d.p = c
assert m.p.p.u.txt == "e"