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

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

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

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

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

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

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

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

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

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

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

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

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