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

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

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

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

c.s = a
c.q = j
l.o = i
l.s = e
j.w = a
a.s = c
a.q = f
e.w = a
b.w = c
i.o = l
i.s = b
m.o = l
m.s = b
h.w = a
f.w = a
assert m.o.o.o.s.w.q.w.q.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.q: C = None
        self.txt = txt

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

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

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

c.s = a
c.q = j
l.o = i
l.s = e
j.w = a
a.s = c
a.q = f
e.w = a
b.w = c
i.o = l
i.s = b
m.o = l
m.s = b
h.w = a
f.w = a
assert m.o.o.o.s.w.q.w.q.w.txt == "a"