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

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

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

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

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

a = A("a")
b = B("b")
e = C("e")
j = D("j")
c = E("c")
n = E("n")

a.w = j
a.s = e
b.x = c
b.w = e
b.z = e
b.y = e
b.s = a
e.s = a
e.y = a
e.o = b
j.w = e
j.p = b
c.z = a
c.q = b
c.w = n
c.x = n
n.z = a
n.q = b
n.w = c
n.x = c
assert e.o.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.s: C = None
        self.txt = txt

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

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

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

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

a = A("a")
b = B("b")
e = C("e")
j = D("j")
c = E("c")
n = E("n")

a.w = j
a.s = e
b.x = c
b.w = e
b.z = e
b.y = e
b.s = a
e.s = a
e.y = a
e.o = b
j.w = e
j.p = b
c.z = a
c.q = b
c.w = n
c.x = n
n.z = a
n.q = b
n.w = c
n.x = c
assert e.o.s.w.txt == "j"