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

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: D = None
        self.v: A = None
        self.txt = txt

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

h.z = m
m.s = e
m.u = n
m.z = g
m.p = g
i.t = m
i.w = c
n.p = g
n.o = g
n.y = i
n.r = c
g.y = n
g.v = d
e.s = m
e.u = n
e.z = g
e.p = g
c.z = m
d.z = m
assert d.z.z.y.y.w.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: D = None
        self.v: A = None
        self.txt = txt

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

h.z = m
m.s = e
m.u = n
m.z = g
m.p = g
i.t = m
i.w = c
n.p = g
n.o = g
n.y = i
n.r = c
g.y = n
g.v = d
e.s = m
e.u = n
e.z = g
e.p = g
c.z = m
d.z = m
assert d.z.z.y.y.w.z.txt == "m"