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

class B:
    def __init__(self, txt: str):
        self.q: C = None
        self.v: D = None
        self.p: E = None
        self.z: E = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.o: D = None
        self.x: D = None
        self.q: A = None
        self.s: D = None
        self.u: C = None
        self.txt = txt

l = A("l")
g = B("g")
m = C("m")
a = D("a")
d = E("d")

l.x = g
l.q = a
g.q = m
g.v = a
g.p = d
g.z = d
m.q = d
m.o = d
a.p = g
a.w = m
a.u = m
a.x = m
a.z = l
d.o = a
d.x = a
d.s = a
d.q = l
d.u = m
assert d.s.x.o.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.q: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: C = None
        self.v: D = None
        self.p: E = None
        self.z: E = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.o: D = None
        self.x: D = None
        self.q: A = None
        self.s: D = None
        self.u: C = None
        self.txt = txt

l = A("l")
g = B("g")
m = C("m")
a = D("a")
d = E("d")

l.x = g
l.q = a
g.q = m
g.v = a
g.p = d
g.z = d
m.q = d
m.o = d
a.p = g
a.w = m
a.u = m
a.x = m
a.z = l
d.o = a
d.x = a
d.s = a
d.q = l
d.u = m
assert d.s.x.o.q.x.txt == "g"