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

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

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

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

a = A("a")
f = B("f")
m = C("m")
j = D("j")
n = C("n")
k = A("k")
i = B("i")
d = A("d")

a.z = k
a.u = k
a.q = i
a.v = i
f.u = d
f.w = i
f.v = n
m.w = a
m.p = a
m.z = f
j.t = i
j.o = a
j.v = f
j.x = n
n.w = k
n.p = k
n.z = i
k.z = a
k.q = f
k.v = f
k.u = d
i.u = a
i.w = f
i.v = m
d.z = a
d.q = f
d.v = f
d.u = k
assert n.z.v.w.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.q: B = None
        self.v: B = None
        self.u: A = None
        self.txt = txt

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

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

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

a = A("a")
f = B("f")
m = C("m")
j = D("j")
n = C("n")
k = A("k")
i = B("i")
d = A("d")

a.z = k
a.u = k
a.q = i
a.v = i
f.u = d
f.w = i
f.v = n
m.w = a
m.p = a
m.z = f
j.t = i
j.o = a
j.v = f
j.x = n
n.w = k
n.p = k
n.z = i
k.z = a
k.q = f
k.v = f
k.u = d
i.u = a
i.w = f
i.v = m
d.z = a
d.q = f
d.v = f
d.u = k
assert n.z.v.w.txt == "a"