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

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

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

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

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

m = A("m")
h = B("h")
g = C("g")
i = D("i")
f = E("f")

m.z = h
m.r = h
m.t = h
m.x = f
h.p = m
h.x = f
g.t = i
g.w = i
g.y = m
i.t = g
i.s = g
i.p = h
i.q = m
f.u = m
f.r = h
assert m.x.r.p.z.x.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.r: B = None
        self.t: B = None
        self.x: E = None
        self.txt = txt

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

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

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

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

m = A("m")
h = B("h")
g = C("g")
i = D("i")
f = E("f")

m.z = h
m.r = h
m.t = h
m.x = f
h.p = m
h.x = f
g.t = i
g.w = i
g.y = m
i.t = g
i.s = g
i.p = h
i.q = m
f.u = m
f.r = h
assert m.x.r.p.z.x.txt == "f"