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

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.z: C = None
        self.u: D = 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.r: A = None
        self.txt = txt

n = A("n")
m = B("m")
f = C("f")
l = D("l")
a = A("a")
k = C("k")

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

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.z: C = None
        self.u: D = 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.r: A = None
        self.txt = txt

n = A("n")
m = B("m")
f = C("f")
l = D("l")
a = A("a")
k = C("k")

n.w = m
n.u = l
n.v = a
m.s = n
m.z = f
m.u = l
f.q = a
l.r = a
a.w = m
a.u = l
a.v = n
k.q = a
assert f.q.v.v.w.txt == "m"