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

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

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

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

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

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

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

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

j.y = a
j.w = a
a.s = j
i.y = n
i.z = a
i.w = m
n.y = a
n.w = a
k.y = j
k.z = a
k.w = a
m.s = n
assert a.s.w.s.w.s.w.txt == "a"