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

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.q: E = None
        self.z: D = None
        self.r: D = None
        self.y: E = None
        self.txt = txt

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

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

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

a = A("a")
b = B("b")
h = C("h")
m = D("m")
i = E("i")
k = E("k")

a.w = i
b.s = a
b.q = i
b.y = i
b.z = m
b.r = m
h.q = b
h.u = b
h.v = b
h.p = m
m.z = a
m.q = h
m.v = h
m.r = h
m.p = k
i.w = b
i.u = b
i.z = h
k.w = b
k.u = b
k.z = h
assert m.z.w.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.q: E = None
        self.z: D = None
        self.r: D = None
        self.y: E = None
        self.txt = txt

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

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

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

a = A("a")
b = B("b")
h = C("h")
m = D("m")
i = E("i")
k = E("k")

a.w = i
b.s = a
b.q = i
b.y = i
b.z = m
b.r = m
h.q = b
h.u = b
h.v = b
h.p = m
m.z = a
m.q = h
m.v = h
m.r = h
m.p = k
i.w = b
i.u = b
i.z = h
k.w = b
k.u = b
k.z = h
assert m.z.w.u.q.txt == "i"