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

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

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

k = A("k")
m = B("m")
g = C("g")
e = A("e")
a = C("a")
j = C("j")
l = B("l")
f = C("f")
c = C("c")
d = B("d")

k.w = a
m.q = e
m.s = f
g.s = l
e.w = f
a.s = m
j.s = d
l.q = k
l.s = g
f.s = m
c.s = l
d.q = e
d.s = a
assert m.q.w.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

k = A("k")
m = B("m")
g = C("g")
e = A("e")
a = C("a")
j = C("j")
l = B("l")
f = C("f")
c = C("c")
d = B("d")

k.w = a
m.q = e
m.s = f
g.s = l
e.w = f
a.s = m
j.s = d
l.q = k
l.s = g
f.s = m
c.s = l
d.q = e
d.s = a
assert m.q.w.s.s.s.txt == "m"