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

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

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

k = A("k")
e = B("e")
i = C("i")
j = C("j")
h = C("h")
l = B("l")
m = A("m")
b = A("b")
n = B("n")
a = B("a")

k.w = m
e.s = j
e.p = a
e.q = h
i.p = n
j.p = e
h.p = l
l.s = j
l.p = a
l.q = h
m.w = b
b.w = k
n.s = j
n.p = e
n.q = h
a.s = i
a.p = e
a.q = h
assert m.w.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

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

k = A("k")
e = B("e")
i = C("i")
j = C("j")
h = C("h")
l = B("l")
m = A("m")
b = A("b")
n = B("n")
a = B("a")

k.w = m
e.s = j
e.p = a
e.q = h
i.p = n
j.p = e
h.p = l
l.s = j
l.p = a
l.q = h
m.w = b
b.w = k
n.s = j
n.p = e
n.q = h
a.s = i
a.p = e
a.q = h
assert m.w.w.w.w.w.w.txt == "m"