class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.y: A = None
        self.s: B = None
        self.p: D = None
        self.txt = txt

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

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

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

n = A("n")
c = B("c")
m = C("m")
b = D("b")
j = C("j")
d = A("d")
f = B("f")

n.w = b
n.p = b
n.y = d
n.s = c
c.u = m
c.z = m
c.v = d
c.s = b
m.z = c
b.v = j
j.z = f
d.w = b
d.p = b
d.y = n
d.s = c
f.u = j
f.z = j
f.v = n
f.s = b
assert b.v.z.z.z.s.v.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.y: A = None
        self.s: B = None
        self.p: D = None
        self.txt = txt

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

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

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

n = A("n")
c = B("c")
m = C("m")
b = D("b")
j = C("j")
d = A("d")
f = B("f")

n.w = b
n.p = b
n.y = d
n.s = c
c.u = m
c.z = m
c.v = d
c.s = b
m.z = c
b.v = j
j.z = f
d.w = b
d.p = b
d.y = n
d.s = c
f.u = j
f.z = j
f.v = n
f.s = b
assert b.v.z.z.z.s.v.z.txt == "f"