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

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

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

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

class E:
    def __init__(self, txt: str):
        self.p: D = None
        self.o: B = None
        self.x: B = None
        self.s: C = None
        self.r: B = None
        self.txt = txt

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

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.p: D = None
        self.o: B = None
        self.x: B = None
        self.s: C = None
        self.r: B = None
        self.txt = txt

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

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