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

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

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

l = A("l")
j = B("j")
m = C("m")
h = C("h")
a = A("a")
c = A("c")
i = C("i")

l.x = j
j.s = h
m.z = h
m.w = i
h.z = m
h.w = m
a.x = j
c.x = j
i.z = m
i.w = m
assert j.s.w.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

l = A("l")
j = B("j")
m = C("m")
h = C("h")
a = A("a")
c = A("c")
i = C("i")

l.x = j
j.s = h
m.z = h
m.w = i
h.z = m
h.w = m
a.x = j
c.x = j
i.z = m
i.w = m
assert j.s.w.w.w.w.w.w.txt == "i"