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

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

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

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

c.q = i
m.y = e
m.q = j
m.r = a
k.p = e
k.s = a
f.q = i
j.y = f
j.q = a
j.r = m
n.q = k
e.q = i
a.y = n
a.q = m
a.r = m
i.p = c
i.s = j
g.q = k
assert c.q.p.q.s.y.q.s.q.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

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

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

c.q = i
m.y = e
m.q = j
m.r = a
k.p = e
k.s = a
f.q = i
j.y = f
j.q = a
j.r = m
n.q = k
e.q = i
a.y = n
a.q = m
a.r = m
i.p = c
i.s = j
g.q = k
assert c.q.p.q.s.y.q.s.q.y.txt == "n"