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

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

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

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

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

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

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

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

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