class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.s: C = None
        self.r: A = None
        self.y: A = None
        self.txt = txt

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

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

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

m = A("m")
f = B("f")
e = C("e")
d = D("d")
n = A("n")
h = B("h")
j = B("j")
l = C("l")

m.z = d
m.s = l
m.r = n
m.y = n
f.y = d
f.v = d
f.r = d
f.s = m
e.y = f
d.z = n
n.z = d
n.s = e
n.r = m
n.y = m
h.y = d
h.v = d
h.r = d
h.s = m
j.y = d
j.v = d
j.r = d
j.s = m
l.y = j
assert d.z.s.y.s.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.s: C = None
        self.r: A = None
        self.y: A = None
        self.txt = txt

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

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

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

m = A("m")
f = B("f")
e = C("e")
d = D("d")
n = A("n")
h = B("h")
j = B("j")
l = C("l")

m.z = d
m.s = l
m.r = n
m.y = n
f.y = d
f.v = d
f.r = d
f.s = m
e.y = f
d.z = n
n.z = d
n.s = e
n.r = m
n.y = m
h.y = d
h.v = d
h.r = d
h.s = m
j.y = d
j.v = d
j.r = d
j.s = m
l.y = j
assert d.z.s.y.s.z.z.txt == "n"