class A:
    def __init__(self, txt: str):
        self.o: C = 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.o: A = None
        self.s: A = None
        self.q: A = None
        self.txt = txt

i = A("i")
j = B("j")
g = C("g")
k = B("k")
m = C("m")
a = B("a")
n = C("n")

i.o = m
j.s = n
g.o = i
g.s = i
g.q = i
k.s = g
m.o = i
m.s = i
m.q = i
a.s = g
n.o = i
n.s = i
n.q = i
assert j.s.o.o.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = 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.o: A = None
        self.s: A = None
        self.q: A = None
        self.txt = txt

i = A("i")
j = B("j")
g = C("g")
k = B("k")
m = C("m")
a = B("a")
n = C("n")

i.o = m
j.s = n
g.o = i
g.s = i
g.q = i
k.s = g
m.o = i
m.s = i
m.q = i
a.s = g
n.o = i
n.s = i
n.q = i
assert j.s.o.o.q.txt == "i"