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

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

c = A("c")
j = B("j")
m = A("m")
a = B("a")
g = A("g")
n = B("n")
k = B("k")
b = B("b")
i = B("i")
h = B("h")

c.z = n
c.q = j
j.s = a
j.z = b
m.z = a
m.q = k
a.s = i
a.z = i
g.z = h
g.q = j
n.s = b
n.z = h
k.s = n
k.z = i
b.s = n
b.z = j
i.s = k
i.z = n
h.s = i
h.z = b
assert j.z.s.z.s.z.s.s.z.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.q: B = None
        self.txt = txt

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

c = A("c")
j = B("j")
m = A("m")
a = B("a")
g = A("g")
n = B("n")
k = B("k")
b = B("b")
i = B("i")
h = B("h")

c.z = n
c.q = j
j.s = a
j.z = b
m.z = a
m.q = k
a.s = i
a.z = i
g.z = h
g.q = j
n.s = b
n.z = h
k.s = n
k.z = i
b.s = n
b.z = j
i.s = k
i.z = n
h.s = i
h.z = b
assert j.z.s.z.s.z.s.s.z.s.s.txt == "k"