class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

f = A("f")
d = B("d")
i = C("i")
l = C("l")
b = C("b")
a = C("a")
n = B("n")
m = C("m")

f.t = i
d.o = l
d.y = n
d.s = n
i.w = b
l.w = b
b.w = a
a.w = m
n.o = m
n.y = d
n.s = d
m.w = l
assert d.s.s.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

f = A("f")
d = B("d")
i = C("i")
l = C("l")
b = C("b")
a = C("a")
n = B("n")
m = C("m")

f.t = i
d.o = l
d.y = n
d.s = n
i.w = b
l.w = b
b.w = a
a.w = m
n.o = m
n.y = d
n.s = d
m.w = l
assert d.s.s.s.y.txt == "d"