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

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

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

f = A("f")
e = B("e")
m = C("m")
h = B("h")
d = C("d")
l = A("l")
i = A("i")

f.w = l
f.o = e
e.w = m
e.u = m
e.p = l
m.s = h
h.w = d
h.p = i
h.u = m
d.s = h
l.w = i
l.o = e
i.w = l
i.o = e
assert e.u.s.w.s.u.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.o: B = None
        self.txt = txt

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

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

f = A("f")
e = B("e")
m = C("m")
h = B("h")
d = C("d")
l = A("l")
i = A("i")

f.w = l
f.o = e
e.w = m
e.u = m
e.p = l
m.s = h
h.w = d
h.p = i
h.u = m
d.s = h
l.w = i
l.o = e
i.w = l
i.o = e
assert e.u.s.w.s.u.txt == "m"