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

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

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

a = A("a")
m = B("m")
e = C("e")
d = A("d")
j = A("j")
l = B("l")
i = C("i")
f = C("f")

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

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

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

a = A("a")
m = B("m")
e = C("e")
d = A("d")
j = A("j")
l = B("l")
i = C("i")
f = C("f")

a.s = j
a.q = e
a.o = e
m.r = l
e.s = a
d.s = j
d.q = i
d.o = e
j.s = a
j.q = i
j.o = i
l.r = m
i.s = j
f.s = j
assert i.s.s.o.txt == "e"