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

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

class C:
    def __init__(self, txt: str):
        self.w: A = None
        self.o: A = None
        self.r: D = None
        self.txt = txt

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

d = A("d")
a = B("a")
n = C("n")
i = D("i")
l = C("l")
h = A("h")
k = B("k")
m = D("m")

d.y = h
d.z = h
d.x = i
d.s = l
a.w = n
a.o = n
a.r = h
a.z = m
n.w = d
n.o = h
n.r = i
i.s = a
l.w = h
l.o = h
l.r = m
h.y = d
h.z = d
h.x = m
h.s = l
k.w = n
k.r = h
k.o = l
k.z = m
m.s = a
assert l.w.x.s.z.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.x: D = None
        self.s: C = None
        self.z: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: A = None
        self.o: A = None
        self.r: D = None
        self.txt = txt

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

d = A("d")
a = B("a")
n = C("n")
i = D("i")
l = C("l")
h = A("h")
k = B("k")
m = D("m")

d.y = h
d.z = h
d.x = i
d.s = l
a.w = n
a.o = n
a.r = h
a.z = m
n.w = d
n.o = h
n.r = i
i.s = a
l.w = h
l.o = h
l.r = m
h.y = d
h.z = d
h.x = m
h.s = l
k.w = n
k.r = h
k.o = l
k.z = m
m.s = a
assert l.w.x.s.z.txt == "m"