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

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

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

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

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

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

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

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

n.w = i
n.y = i
m.s = i
m.o = d
d.t = m
j.t = i
i.s = m
i.o = j
a.w = i
a.y = m
assert m.s.s.s.txt == "i"