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

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

c = A("c")
i = B("i")
n = A("n")
l = B("l")
m = B("m")
j = A("j")
b = A("b")
a = A("a")
k = A("k")
f = A("f")

c.s = f
i.s = b
n.s = c
l.s = k
m.s = j
j.s = n
b.s = c
a.s = j
k.s = j
f.s = k
assert a.s.s.s.s.s.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.s: A = None
        self.txt = txt

c = A("c")
i = B("i")
n = A("n")
l = B("l")
m = B("m")
j = A("j")
b = A("b")
a = A("a")
k = A("k")
f = A("f")

c.s = f
i.s = b
n.s = c
l.s = k
m.s = j
j.s = n
b.s = c
a.s = j
k.s = j
f.s = k
assert a.s.s.s.s.s.s.s.s.s.s.txt == "k"