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

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

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

i = A("i")
g = B("g")
l = C("l")
n = B("n")
f = A("f")
c = C("c")
j = A("j")
k = C("k")

i.s = j
g.o = l
g.r = l
g.q = n
l.q = n
l.s = n
l.x = n
n.o = c
n.r = c
n.q = g
f.s = i
c.q = n
c.x = n
c.s = g
j.s = f
k.q = g
k.x = g
k.s = n
assert c.s.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

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

i = A("i")
g = B("g")
l = C("l")
n = B("n")
f = A("f")
c = C("c")
j = A("j")
k = C("k")

i.s = j
g.o = l
g.r = l
g.q = n
l.q = n
l.s = n
l.x = n
n.o = c
n.r = c
n.q = g
f.s = i
c.q = n
c.x = n
c.s = g
j.s = f
k.q = g
k.x = g
k.s = n
assert c.s.r.q.txt == "n"