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

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

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

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

d = A("d")
n = B("n")
e = C("e")
i = D("i")
m = C("m")
a = D("a")

d.z = n
n.s = a
n.w = m
n.p = i
e.t = i
e.w = n
e.z = a
i.s = n
i.o = a
m.t = i
m.z = i
m.w = n
a.s = n
a.o = i
assert a.o.s.s.o.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

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

d = A("d")
n = B("n")
e = C("e")
i = D("i")
m = C("m")
a = D("a")

d.z = n
n.s = a
n.w = m
n.p = i
e.t = i
e.w = n
e.z = a
i.s = n
i.o = a
m.t = i
m.z = i
m.w = n
a.s = n
a.o = i
assert a.o.s.s.o.txt == "i"