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

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

class C:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

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

a.w = e
a.u = e
d.v = a
d.z = a
d.u = a
d.o = k
d.y = k
k.r = d
j.q = a
e.p = a
e.x = a
e.y = k
assert j.q.u.p.w.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: E = None
        self.u: E = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

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

a.w = e
a.u = e
d.v = a
d.z = a
d.u = a
d.o = k
d.y = k
k.r = d
j.q = a
e.p = a
e.x = a
e.y = k
assert j.q.u.p.w.p.txt == "a"