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

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

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

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

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

j.z = d
j.s = h
j.v = n
d.q = k
d.r = f
d.s = h
d.w = m
f.q = j
h.s = k
k.s = h
m.q = j
a.q = j
n.q = k
n.r = f
n.s = h
n.w = m
assert m.q.v.r.q.v.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.s: D = None
        self.v: B = None
        self.txt = txt

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

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

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

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

j.z = d
j.s = h
j.v = n
d.q = k
d.r = f
d.s = h
d.w = m
f.q = j
h.s = k
k.s = h
m.q = j
a.q = j
n.q = k
n.r = f
n.s = h
n.w = m
assert m.q.v.r.q.v.txt == "n"