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

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

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

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

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

n = A("n")
d = B("d")
c = C("c")
k = D("k")
l = E("l")

n.z = k
n.v = k
d.s = n
d.q = n
d.v = n
d.o = c
d.x = c
c.p = k
k.x = d
k.z = n
k.o = n
k.r = l
k.s = l
l.y = d
l.z = d
assert l.z.v.z.o.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.v: D = None
        self.txt = txt

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

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

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

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

n = A("n")
d = B("d")
c = C("c")
k = D("k")
l = E("l")

n.z = k
n.v = k
d.s = n
d.q = n
d.v = n
d.o = c
d.x = c
c.p = k
k.x = d
k.z = n
k.o = n
k.r = l
k.s = l
l.y = d
l.z = d
assert l.z.v.z.o.z.txt == "k"