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

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

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

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

k = A("k")
b = B("b")
g = C("g")
a = D("a")
j = D("j")
l = D("l")
n = A("n")
c = B("c")
m = D("m")

k.z = j
k.p = m
k.x = b
b.s = a
b.z = c
b.x = g
b.v = k
g.v = m
g.q = n
g.u = c
a.r = n
a.q = k
j.r = n
j.q = n
l.r = n
l.q = k
n.z = l
n.p = j
n.x = b
c.s = m
c.z = b
c.x = g
c.v = k
m.r = k
m.q = k
assert n.x.s.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.p: D = None
        self.x: B = None
        self.txt = txt

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

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

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

k = A("k")
b = B("b")
g = C("g")
a = D("a")
j = D("j")
l = D("l")
n = A("n")
c = B("c")
m = D("m")

k.z = j
k.p = m
k.x = b
b.s = a
b.z = c
b.x = g
b.v = k
g.v = m
g.q = n
g.u = c
a.r = n
a.q = k
j.r = n
j.q = n
l.r = n
l.q = k
n.z = l
n.p = j
n.x = b
c.s = m
c.z = b
c.x = g
c.v = k
m.r = k
m.q = k
assert n.x.s.r.z.txt == "l"