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

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

class C:
    def __init__(self, txt: str):
        self.w: E = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

m = A("m")
n = B("n")
f = C("f")
i = D("i")
d = E("d")
h = A("h")
b = B("b")
e = C("e")

m.s = i
m.z = n
m.p = h
n.s = b
f.w = d
i.s = f
d.s = m
h.s = i
h.z = n
h.p = m
b.s = n
e.w = d
assert f.w.s.z.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.z: B = None
        self.p: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: E = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

m = A("m")
n = B("n")
f = C("f")
i = D("i")
d = E("d")
h = A("h")
b = B("b")
e = C("e")

m.s = i
m.z = n
m.p = h
n.s = b
f.w = d
i.s = f
d.s = m
h.s = i
h.z = n
h.p = m
b.s = n
e.w = d
assert f.w.s.z.s.s.txt == "n"