class A:
    def __init__(self, txt: str):
        self.z: 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.v: A = None
        self.t: D = None
        self.q: A = None
        self.txt = txt

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

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

i = A("i")
m = B("m")
k = C("k")
e = D("e")
c = E("c")

i.z = k
m.z = e
k.y = e
k.t = e
k.v = i
k.q = i
e.u = i
e.z = m
c.x = k
c.z = m
assert k.y.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: 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.v: A = None
        self.t: D = None
        self.q: A = None
        self.txt = txt

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

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

i = A("i")
m = B("m")
k = C("k")
e = D("e")
c = E("c")

i.z = k
m.z = e
k.y = e
k.t = e
k.v = i
k.q = i
e.u = i
e.z = m
c.x = k
c.z = m
assert k.y.z.z.txt == "e"