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

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

k = A("k")
n = B("n")
h = B("h")
e = B("e")
f = A("f")
d = B("d")
a = B("a")
i = B("i")
j = A("j")
m = A("m")

k.q = f
n.s = a
h.s = i
e.s = i
f.q = m
d.s = a
a.s = e
i.s = a
j.q = f
m.q = f
assert j.q.q.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

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

k = A("k")
n = B("n")
h = B("h")
e = B("e")
f = A("f")
d = B("d")
a = B("a")
i = B("i")
j = A("j")
m = A("m")

k.q = f
n.s = a
h.s = i
e.s = i
f.q = m
d.s = a
a.s = e
i.s = a
j.q = f
m.q = f
assert j.q.q.q.q.q.q.q.txt == "f"