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

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

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

class D:
    def __init__(self, txt: str):
        self.o: E = None
        self.v: A = None
        self.q: E = None
        self.y: A = None
        self.z: A = None
        self.txt = txt

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

m = A("m")
j = B("j")
b = C("b")
e = D("e")
h = E("h")

m.z = e
m.r = h
j.q = m
b.z = h
b.w = e
e.o = h
e.q = h
e.v = m
e.y = m
e.z = m
h.y = b
assert b.w.q.y.w.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.r: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.o: E = None
        self.v: A = None
        self.q: E = None
        self.y: A = None
        self.z: A = None
        self.txt = txt

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

m = A("m")
j = B("j")
b = C("b")
e = D("e")
h = E("h")

m.z = e
m.r = h
j.q = m
b.z = h
b.w = e
e.o = h
e.q = h
e.v = m
e.y = m
e.z = m
h.y = b
assert b.w.q.y.w.txt == "e"