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

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

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

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

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

a = A("a")
d = B("d")
i = C("i")
k = D("k")
e = E("e")

a.v = k
a.w = e
d.x = i
d.w = i
d.z = a
d.s = a
d.u = k
i.o = e
i.s = d
k.z = d
e.v = a
assert e.v.v.z.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.w: E = None
        self.txt = txt

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

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

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

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

a = A("a")
d = B("d")
i = C("i")
k = D("k")
e = E("e")

a.v = k
a.w = e
d.x = i
d.w = i
d.z = a
d.s = a
d.u = k
i.o = e
i.s = d
k.z = d
e.v = a
assert e.v.v.z.txt == "d"