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

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

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

class D:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

e.z = c
e.q = c
e.o = d
e.v = i
h.z = n
h.p = n
n.w = c
c.r = n
d.u = i
d.r = e
d.z = n
i.z = n
i.p = n
assert h.p.w.r.w.r.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.o: E = None
        self.v: B = None
        self.q: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

e.z = c
e.q = c
e.o = d
e.v = i
h.z = n
h.p = n
n.w = c
c.r = n
d.u = i
d.r = e
d.z = n
i.z = n
i.p = n
assert h.p.w.r.w.r.txt == "n"