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

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

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

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

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

h = A("h")
d = B("d")
b = C("b")
i = D("i")
m = E("m")
e = E("e")
a = D("a")
n = C("n")

h.q = b
h.x = b
h.y = e
d.w = h
d.z = i
b.u = h
b.z = d
b.o = n
i.w = b
i.o = d
i.r = e
i.v = n
i.q = h
m.z = h
e.z = h
a.w = n
a.o = d
a.r = m
a.v = b
a.q = h
n.u = h
n.z = d
n.o = b
assert b.u.x.o.o.z.w.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.y: E = None
        self.x: C = None
        self.txt = txt

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

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

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

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

h = A("h")
d = B("d")
b = C("b")
i = D("i")
m = E("m")
e = E("e")
a = D("a")
n = C("n")

h.q = b
h.x = b
h.y = e
d.w = h
d.z = i
b.u = h
b.z = d
b.o = n
i.w = b
i.o = d
i.r = e
i.v = n
i.q = h
m.z = h
e.z = h
a.w = n
a.o = d
a.r = m
a.v = b
a.q = h
n.u = h
n.z = d
n.o = b
assert b.u.x.o.o.z.w.y.txt == "e"