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

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

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

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

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

a = A("a")
e = B("e")
j = C("j")
i = D("i")
h = E("h")

a.w = h
e.o = h
e.z = a
e.v = a
e.s = j
e.w = i
j.w = h
i.y = e
h.s = e
h.v = a
h.z = a
assert j.w.v.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: E = None
        self.txt = txt

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

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

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

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

a = A("a")
e = B("e")
j = C("j")
i = D("i")
h = E("h")

a.w = h
e.o = h
e.z = a
e.v = a
e.s = j
e.w = i
j.w = h
i.y = e
h.s = e
h.v = a
h.z = a
assert j.w.v.w.txt == "h"