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

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

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

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

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

h.p = i
i.w = a
l.s = n
l.w = f
f.y = h
n.s = l
n.w = j
e.w = a
a.w = e
j.y = h
d.y = h
assert h.p.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

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

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

h.p = i
i.w = a
l.s = n
l.w = f
f.y = h
n.s = l
n.w = j
e.w = a
a.w = e
j.y = h
d.y = h
assert h.p.w.w.w.w.txt == "e"