Harryxun/stf_run huggingface dataset:
str = input()
while not str == '-':
  n = int(input())
  for i in range(n):
    str = str[n:] + [:n-1]
  print(str)
  str = input() 

### FIXED CODE ###

str = input()
while not str == '-':
  n = int(input())
  for i in range(n):
    h = int(input())
    str = str[h:] + str[:h]
  print(str)
  str = input()
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())



def calc(i,j):
    return i*w+j
def calc_inv(x):
    return x//w, x%w
def judge(x,y):
    i0,j0 = calc_inv(x)
    i1,j1 = calc_inv(y)
    if s[i0][j0] != s[i1][j1]:
        return True
    return False


h,w = map(int,input().split())
s = [[(i == "#")*1 for i in list(input())] for _ in range(h)]
uf = UnionFind(h*w)

for i in range(h):
    for j in range(w):
        now = calc(i,j)
        nxt = calc(i+1,j)
        if i+1 < h:
            if judge(now,nxt):
                uf.union(now,nxt)
        nxt = calc(i,j+1)
        if j+1 < w:
            if judge(now,nxt):
                uf.union(now,nxt)


cnt = [[0,0] for _ in range(h*w)]
ind = 0
for l in uf.all_group_members().values():
    for x in l:
        i,j = calc_inv(x)
        if s[i][j]:
            cnt[ind][0] += 1
        else:
            cnt[ind][1] += 1
    ind += 1
ans = 0
for i in range(ind):
    ans += cnt[i][0]*cnt[i][1]
print(ans)

### FIXED CODE ###

n = int(input())
h = int(input())
w = int(input())
print(max(0,n-w+1)*max(0,n-h+1))
#n = int(input())
#L = list(map(int, input().split()))
import math
import sys
import heapq
import fractions

nCr = {}
def cmb(n, r):
    if r == 0 or r == n:
        return 1
    if r == 1:
        return n
    if (n, r) in nCr:
        return nCr[(n, r)]
    nCr[(n, r)] = cmb(n-1, r) + cmb(n-1, r-1)
    return nCr[(n, r)]

N = int(input())
s = []
n = 0
for i in range(N):
    s.append(list(input()))
ans = 0
s.sort()
for i in range(N):
    s[i]=set(s[i])
for i in range(N-1):
    if s[i]==s[i+1]:
        n += 1
        if i == N-2:
            ans += cmb(n+1, 2)
    else:
        if n > 0:
            ans += cmb(n+1,2)
            n = 0
print(ans)


### FIXED CODE ###

#n = int(input())
#L = list(map(int, input().split()))
import math
import sys
import heapq
import fractions


def cmb(n, r):
    if n - r < r:
        r = n - r
    if r == 0:
        return 1
    if r == 1:
        return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

N = int(input())
s = []
n = 0
for i in range(N):
    s.append(list(input()))
ans = 0


for i in range(N):
    s[i].sort()
s.sort()

for i in range(1,N):

    if s[i]==s[i-1]:
        n += 1
        if i == N-1:
            ans += cmb(n+1, 2)
    else:
        if n > 0:
            ans += cmb(n+1,2)
            n = 0
print(ans)
D = int(input())
 
if D ==25;
  print("Christmas)"
else if D ==24;
  print("Christmas Eve")
else if D ==23;
  print("Christmas Eve Eve")
else if D ==22;
  print("Crhistmas Eve Eve Eve")

### FIXED CODE ###

D = int(input())
if D == 25:
  print("Christmas")
elif D == 24:
  print("Christmas Eve")
elif D == 23:
  print("Christmas Eve Eve")
elif D == 22:
  print("Christmas Eve Eve Eve")
N = int(input())
value_list = input().split()
value_list.sort()
i = 0

for i in range(N):
	if i == 0:
		new_value = int(value_list[i])
	else:
		new_value = (new_value + int(value_list[i])) / 2
    i += 1

print(new_value)

### FIXED CODE ###

a = int(input())
s = input()
if a < 3200:
  s = 'red'
print(s)
N = int(input())
A = [int(a) for a in input().split()]
mod = 10**9+7
SUM = 0

maxA = max(A)
d = 0
while 1:
    if maxA < 2**d:
        break
    d += 1

BitA = [[0]*d for _ in range(N)]
for i in range(N):
    for j in range(d):
        BitA[i][j] = int(bin(A[i]|2**d)[3+j])

BitSumB = 0
for i in range(d):
    tmp = sum([BitA[j][i] for j in range(N)])
    BitSumB += 2 ** (d-i-1) * (tmp * (N - tmp))
    BitSumB = BitsumB % mod

print(BitSumB)

### FIXED CODE ###

N = int(input())
A = [int(a) for a in input().split()]
mod = 10**9+7
SUM = 0

maxA = max(A)
d = 0
while 1:
    if maxA < 2**d:
        break
    d += 1

BitSumB = 0
for i in range(d):
    tmp = 0
    for n in range(N):
        tmp += (A[n] >> i) & 1
    BitSumB += (2**i) * tmp * (N - tmp)



"""
BitA = [[0]*d for _ in range(N)]
for i in range(N):
    BitA[i] = list(map(int, format(bin(A[i])[2:], '0>{}'.format(d))))

BitSumB = 0
for i in range(d):
    tmp = sum([BitA[j][i] for j in range(N)])
    BitSumB += 2 ** (d-i-1) * (tmp * (N - tmp))
    #BitSumB = BitSumB % mod
"""

print(BitSumB % mod)
def solve(): 
    a,b,k = map(int,input().split())
    li = list(range(a,b+1))
    if b - a + 1 >= 2 * k:
        for i in li[:k]:
            print(i)
        for i in li[-k:]:
            print(i)
    else:
        for i in li:
            print(i)
            
if __name __ == "__main__":
    solve()

### FIXED CODE ###

a,b,k = map(int,input().split())

if (b-a+1) > 2*k:
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)
else:
    for i in range(a,b+1):
        print(i)
input = sys.stdin.readline
h,w=map(int, input().split())
a=[list(map(int, input().split())) for i in range(h)]
x=0
for i in range(h):
    for j in range(w):
        x+=a[i][j]*((h-i-1)+(w-j-1))
        
print(x)

for i in range(h):
    for j in range(w):
        if a[i][j]!=0:
            for k in range(a[i][j]):
                for l in range(1,w-j):
                    print(i+1,j+l,i+1,j+l+1)
                for m in range(1,h-i):
                    print(i+m,w,i+m+1,w)

### FIXED CODE ###

import sys
input = sys.stdin.readline
h,w=map(int, input().split())
a=[list(map(int, input().split())) for i in range(h)]
ans=[]


for i in range(h):
    for j in range(w):
        if i==h-1 and j==w-1:
            continue
        
        if a[i][j]%2==0:
            continue
        
        if j!=w-1:
            ans.append([i+1,j+1,i+1,j+2])
            a[i][j+1]+=1
        else:
            ans.append([i+1,j+1,i+2,j+1])
            a[i+1][j]+=1
            
print(len(ans))
for i in range(len(ans)):
    print(*ans[i])
import fractions
import functools
import sys
sys.setrecursionlimit(100000000)

n=int(input())
a = [int(i) for i in input().split()]
a.sort()

if len(a) == 2:
  print(max(a))
  sys.exit()
  
gcd_a = functools.reduce(fractions.gcd, a)
a=[i//gcd_a for i in a]

cnt = 0
gcd_0 = functools.reduce(fractions.gcd, a[1:])
for i in range(1,len(a)):
  if fractions.gcd(a[0],a[i]) == 1:
    so = i
    cnt+=1
    if cnt == 2:
      print(max(gcd_a,gcd_0*gcd_a))
      sys.exit()

a_i = [i for i in a if i != a[so]]
gcd_i = functools.reduce(fractions.gcd, a_i)

print(max(gcd_0,gcd_i)*gcd_a)
   

### FIXED CODE ###

import fractions
import functools
import sys

n=int(input())
a = [int(i) for i in input().split()]
a.sort()

if len(a) == 2:
  print(max(a))
  sys.exit()
  
gcd_a = functools.reduce(fractions.gcd, a)
a=[i//gcd_a for i in a]

so = 0
cnt = 0
gcd_0 = functools.reduce(fractions.gcd, a[1:])
for i in range(1,len(a)):
  if fractions.gcd(a[0],a[i]) == 1:
    so = i
    cnt+=1
    if cnt == 2:
      print(max(gcd_a,gcd_0*gcd_a))
      sys.exit()

a_i = [i for i in a if i != a[so]]
gcd_i = functools.reduce(fractions.gcd, a_i)

print(max(gcd_0,gcd_i)*gcd_a)
import sys
sys.setrecursionlimit
mo=10**9+7
def fact(x):
  if x==0:
    return 1
  else:
    return x*fact(x-1)%mo
n,m=map(int,input().split())
if abs(n-m)>1:
  print(0)
elif m==n:
  print((2*fact(m)*fact(n))%mo)
else:
  print((fact(m)*fact(n))%mo)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
mo=10**9+7
def fact(x):
  if x==0:
    return 1
  else:
    return x*fact(x-1)%mo
n,m=map(int,input().split())
if abs(n-m)>1:
  print(0)
elif m==n:
  print((2*fact(m)*fact(n))%mo)
else:
  print((fact(m)*fact(n))%mo)
#!/usr/bin/env python3
import sys
import collections


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N, K = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]

    cur = 1
    c = {}
    route = []
    roop = None
    while (True):
        if cur in c:
            roop = cur
            break
        route.append(cur)
        c[cur] = 1
        cur = A[cur - 1]
    idx = route.index(roop)
    route = route[idx:]
    print(route[K % len(route) - idx])
    return


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import collections


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N, K = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]

    cur = 1
    c = {}
    route = []
    roop = None
    while (True):
        if cur in c:
            roop = cur
            break
        route.append(cur)
        c[cur] = 1
        cur = A[cur - 1]
    idx = route.index(roop)
    if K <= idx:
        print(route[K])
        return
    # route = route[idx:]
    print(route[(K - idx) % (len(route) - idx) + idx])
    return


if __name__ == '__main__':
    main()
n,m = list(map(int, input().split()))
a=list(map(int, input().split()))
a.sorted()
d=[a[i+1]-a[i] for i in range(n)]
d.sorted()
print(sum(d[:m-n]) if m>n else 0)

### FIXED CODE ###

n,m = list(map(int, input().split()))
a=list(map(int, input().split()))
a.sort()
d=[a[i+1]-a[i] for i in range(m-1)]
d.sort()
print(sum(d[:m-n]) if m>n else 0)
A,B = [int(x) for x in input().split()]
print((B-1)//(A-1)+1)

### FIXED CODE ###

S = str(input())
T = str(input())
# 出力
A = 0

for i in range(3):
    if S[i] == T[i]:
        A += 1

print(A)
import sys
line = sys.stdin.read().splitlines()
for line in len(line):
    num = map(float,raw_input().split())
    x = (num[2]*num[4] - num[1]*num[5]) / (num[0]*num[4] - num[1]*num[3])
    y = (num[5]*num[0]-num[2]*num[3]) / (num[0]*num[4]-num[3]*num[1])
    print "%0.3f %0.3f"%(x,y)

### FIXED CODE ###

import sys
out=[]
for line in sys.stdin.readlines():
    num = map(float, line.strip().split())
    x = (num[2]*num[4] - num[1]*num[5]) / (num[0]*num[4] - num[1]*num[3])
    y = (num[5]*num[0] - num[2]*num[3]) / (num[0]*num[4] - num[3]*num[1])
    if x == 0:
        x=0.00
    if y == 0:
        y=0.00
    out.append( "%.3f %.3f"%(round(x,3),round(y,3)))
for i in xrange(len(out)):
    print out[i]
print(["ABD","ABC][len(input())==3])

### FIXED CODE ###

print(["ABC","ABD"][len(input())==4])
a = input().strip()
l = a.split()

m_l = set()
for i in range(1 , n + 1):
    m_l.add(l[i])
print(len(m_l))


### FIXED CODE ###


a = int(input())
l = [input() for i in range(a)]
print(len(set(l)))
n,c,k = map(int,input().split())
t = []
for i in range(n):
  t.append(int(input()))


sort(t)
ans = 0
now = 0
ter = -1
for i in range(n):
  if ter < t[i]+k:
    ans+=1
    ter = t[i]+k
    now = 1
  else:
    if(c>=now):
      ans+=1
      ter = t[i]+k
      now = 1
    else:
      now += 1
      
print(ans)

### FIXED CODE ###

n,c,k = map(int,input().split())
t = []
for i in range(n):
  t.append(int(input()))

t.sort()
ans = 0
now = 0
ter = -1
for i in range(n):
  if ter < t[i]:
    ans += 1
    ter = t[i]+k
    now = 1
  else:
    if(c<=now):
      ans+=1
      ter = t[i]+k
      now = 1
    else:
      now += 1
      
print(ans)
def search(m,n,l): //startCは常に満たす、stopC+1は常に満たさない
  if l[0]<=m: return 0
  elif l[n-1]>m: return n
  startC,stopC=0,n-1
  while startC-stopC!=0:
    if l[(stopC-startC)>>1]<=m:
      stopC=startC-1+(stopC-startC)>>1
    else:
      startC+=(stopC-startC)>>1
  return stopC+1

n=int(input())
l=list(map(int,input().split()))
l.sort(reverse=True)
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    ans+=search(l[i]-l[j],n,l[j+1:]) //l[i]-l[j]<l[ans]を満たす最小のansを求める
print(ans)

### FIXED CODE ###

import bisect
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(n-1,1,-1):
  for j in range(i-1,0,-1):
    ans+=j-bisect.bisect_left(l,l[i]-l[j]+1,hi=j)
print(ans)
from math import factorial

memo = {}
def combination(n,k):
  return memo.setdefault((n,k), int(factorial(n)/(factorial(k)*factorial(n-k))))

n, k = map(int, input().split())
for i in range(1, k + 1):
  print((combination(n-k+1,i)*combination(k-1,i-1))%(10**9+7))


### FIXED CODE ###

from math import factorial
import sys

sys.setrecursionlimit(2000)
mod = 10**9+7
n, k = map(int, input().split())

memo = {}
def combination(n,k):
  if n < k:
    return 0
  return factorial(n)//factorial(k)//factorial(n-k)
  if n / 2 < k:
    k = n - k
  if n in memo and k in memo[n]:
    return memo[n][k]
  v = 0
  if k == 0:
    v = 1
  elif k == 1:
    v = n
  else:
    v = combination(n-1,k) + combination(n-1,k-1)
  return memo.setdefault(n, {}).setdefault(k, v)

for i in range(1, k + 1):
  print(combination(n-k+1,i)*combination(k-1,i-1)%mod)
a, b, c = map(int, input().split().split())
if  b−a==c−b:
  print ("YES")
elif print("NO")

### FIXED CODE ###

a,b,c = map(int,input().split())
if b-a == c-b:
    print("YES")
else:
    print("NO")
n = int(input())
a = list(map(int,input().split()))
plus = 0
for i in range(n):
  plus += ( 2 * int( a[i] > 0 ) - 1 )
score = 0
for i in range(n):
  score += abs(a[i])
if plus != n:
  print(score)
  a.sort()
  if plus >=0:
    for k in range(plus):
      print(a[0],a[-1])
      a[0] -= a[-1]
      del a[-1]
    half = ( n - plus ) // 2
    if half != 0:
      for k in range(half-1):
        print(a[k],a[-1])
        a[k] -= a[-1]
        del a[-1]
      for k in range(half):
        print(a[-1],a[0])
        a[-1] -= a[0]
        del a[0]
  else:
    plus *= -1
    for k in range(plus):
      print(a[-1],a[0])
      a[-1] -= a[0]
      del a[0]
    half = ( n - plus ) // 2
    if half != 0:
      for k in range(half-1):
        print(a[k],a[-1])
        a[k] -= a[-1]
        del a[-1]
      for k in range(half):
        print(a[-1],a[0])
        a[-1] -= a[0]
        del a[0]
else:
  unchi

### FIXED CODE ###

#12:17
n = int(input())
a = list(map(int,input().split()))
plus = []
minus = []
for i in range(n):
  if a[i] >= 0:
    plus.append(a[i])
  else:
    minus.append(a[i])
plus.sort()
minus.sort(reverse=True)
lp = len(plus)
lm = len(minus)
if lp >= 1 and lm >= 1:
  ans = sum(plus) - sum(minus)
  print(ans)
  x = minus[0]
  lp = len(plus)
  for i in range(1,lp):
    print(x,plus[i])
    x = x - plus[i]
  minus[0] = x
  x = plus[0]
  for j in range(lm):
    print(x,minus[j])
    x = x - minus[j]
elif lp == 0:
  ans = - sum(minus) + 2 * max(minus)
  print(ans)
  x = minus[1]
  for j in range(2,lm):
    print(x,minus[j])
    x = x - minus[j]
  print(x,minus[0])
elif lm == 0:
  ans = sum(plus) - 2 * min(plus)
  print(ans)
  x = plus[0]
  for i in range(2,lp):
    print(x,plus[i])
    x = x - plus[i]
  print(plus[1],x)
a=input()
ans="AC"
if not a[0]=="A":
  ans="WA"
if not "C" in a[2:-2]:
  ans="WA"
a.remove("A").remove("C")
if not a.islower():
  ans="WA"
print(ans)
  

### FIXED CODE ###

a=input()
ans="AC"
if not a[0]=="A":
  ans="WA"
if not a[2:-1].count("C")==1:
  ans="WA"
a=a.replace("A","",1).replace("C","",1)
if not a.islower():
  ans="WA"
print(ans)
n,k=map(int,input().split())
a=list(map(int, input().split()))
b=[1]
ba={1}
c=0
m=0
# while flag==1:
for i in range(n):
    if a[m] not in ba:
        b.append(a[m])
        ba.add(a[m])
        c+=1
        m=a[m]-1
    else:
        e=a[m]
        break
# print(b,e,c+1)
e=b.index(e)
# print(b,e)
b=b[e:c+1]
f=c+1-e
if n>k:
    print(b[k])
    exit()
if 1 not in b:
    ans=(k-e)%f
    print(b[ans])
else:
    # print(b,f)
    ans=k%f
    print(b[ans])


### FIXED CODE ###


n,k=map(int,input().split())
a=list(map(int, input().split()))
b=[1]
ba={1}
c=0
m=0
# while flag==1:
for i in range(n):
    if a[m] not in ba:
        b.append(a[m])
        ba.add(a[m])
        c+=1
        m=a[m]-1
    else:
        e=a[m]
        break
# print(b,e,c+1)
e=b.index(e)
# print(b,e)
bc=b
b=b[e:c+1]
f=c+1-e
if c>k:
    if c-1>=k:

        print(bc[k])
        exit()
if 1 not in b:
    # print(b,f)
    ans=(k-e)%f
    print(b[ans])
else:

    ans=k%f
    print(b[ans])
n,m = map(int,input().split())
ans = [1]*n

for i in range(m):
    a = int(input())
    ans[a-1] = 0

if ans[0] != 0 and ans[1] != 0:
    ans[0] = 1
    ans[1] = 2

for i in range(2,n):
    if ans[i] != 0:
        ans[i] = (ans[i-1] + ans[i-2])%1000000007
        
print(ans[n-1])


### FIXED CODE ###

n,m = map(int,input().split())
ans = [1]*n

if n == 1:
    print(1)
else:
    for i in range(m):
        a = int(input())
        ans[a-1] = 0

    if ans[0] != 0 and ans[1] != 0:
        ans[0] = 1
        ans[1] = 2

    for i in range(2,n):
        if ans[i] != 0:
            ans[i] = (ans[i-1] + ans[i-2])%1000000007
        
    print(ans[n-1])
n = int(input())

a = list(range(1, n+1))
ans = 0
for i in range(n):
    ans += a[i] % a[(i+1)%n]

print(ans)


### FIXED CODE ###

n = int(input())

ans = n * (n - 1) // 2
print(ans)
i = input()
i1=int(i/100)
i2=int((i-i1*100)/10)
i3=i-i1*100-i2*10

if (i1 == 7 or i2 == 7 or i3 == 7):
    print ('Yes')
else:
    print ('No')


### FIXED CODE ###

i = input()

if (i[0] == '7' or i[1] == '7' or i[2] == '7'):
    print ('Yes')
else:
    print ('No')
A,B,K=map(int,input().split())
c=[]
for i in range(1,abs(A-B)+1):
  if A%i==0 and B%i==0:
    c.append(i)
    
print(c[-K])


### FIXED CODE ###

A,B,K=map(int,input().split())
c=[]
for i in range(1,min(A,B)+1):
  if A%i==0 and B%i==0:
    c.append(i)
    
print(c[-K])
sum=0
i = 1
while i < 4:
  val = int(input(""))
  sum+=val
  i += 1

if sum>=22:
    print('bust') 
else:
    print('win')    
 

### FIXED CODE ###

a, b, c = map(int, input().split())
sum = a + b + c
if sum>=22:
    print('bust') 
else:
    print('win')
import math

ranks = [False for i in range(8)]
highs = 0
n = int(input())
inps = [int(i) for i in input().split()]
highs = len([i for i in inps if i > 3199])
inps = [i for i in inps if i <= 3199]
for i in inps:
    ranks[math.floor(i/399)] = True

lows = len([i for i in ranks if i == True]) 

minimum = lows + (1 if ranks != 0 else 0) - 1
maximum = lows + highs

print(minimum, maximum)


### FIXED CODE ###

import math

ranks = [False for i in range(8)]
highs = 0
n = int(input())
inps = [int(i) for i in input().split()]
highs = len([i for i in inps if i > 3199])
inps = [i for i in inps if i <= 3199]
for i in inps:
    if i >= 1 and i <= 399:
        ranks[0] = True
    elif i >= 400 and i <= 799:
        ranks[1] = True
    elif i >= 800 and i <= 1199:
        ranks[2] = True
    elif i >= 1200 and i <= 1599:
        ranks[3] = True
    elif i >= 1600 and i <= 1999:
        ranks[4] = True
    elif i >= 2000 and i <= 2399:
        ranks[5] = True
    elif i >= 2400 and i <= 2799:
        ranks[6] = True
    elif i >= 2800 and i <= 3199:
        ranks[7] = True
lows = len([i for i in ranks if i == True])

minimum = max(lows, 1)
maximum = lows + highs

print(minimum, maximum)
a

### FIXED CODE ###

import random as rng
import itertools as it
import collections as col
import heapq as hq
import sys
import copy as cp
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def dump_impl(*objects):
    print(*objects, file=sys.stderr)


def dump_dummy(*objects):
    pass


dump = dump_impl if "DEBUG" in sys.argv else dump_dummy


def odd(n): return n & 1


def even(n): return not odd(n)


A, B, C = map(int, input().split())
ans = 0
a, b, c = A, B, C
while True:
    dump(a, b, c)
    if odd(a) or odd(b) or odd(c):
        print(ans)
        exit()
    if ans > 0 and a == A and b == B and c == C:
        print(-1)
        exit()
    a, b, c = (b+c)//2, (a+c)//2, (a+b)//2
    ans += 1
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N=one_int()
S=one_str()

bit_count = S.count("1")

#bit数
calc_dict = {i:-1 for i in range(22000)}
res_dict =  {i:-1 for i in range(2*(10**5))}

res_dict = {i:-1 for i in range(1001)}
res_dict[0]=0

for i in range(1, 1001):
    if calc_dict[i]==-1:
        calc_dict[i] = bin(i).count("1")
    
    res_dict[i] = i%calc_dict[i]+1


bit_count = S.count("1")
for i in range(len(S)):
    if S[i]=="0":

        bit_count+=1
        num = int(S,2) + 2**(N-i-1)
        if num==0:
            print(0)
        else:
            print(res_dict[num%bit_count]+1)

#         print(mods(num, bit_count, 0))
        bit_count-=1
    else:

        bit_count-=1
        num = int(S,2) - 2**(N-i-1)
        if num==0:
            print(0)
        else:
            print(res_dict[num%bit_count]+1)
        bit_count+=1

### FIXED CODE ###

def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N=one_int()
S=one_str()

bit_count = S.count("1")
S_num = int(S,2)
S_min = S_num % (bit_count-1) if bit_count-1!=0 else 0
S_plu = S_num % (bit_count+1)




# calc_dict = {i:-1 for i in range(10000)}
# res_dict =  {i:-1 for i in range(10**4)}

# for i in range(1, 10000):
#     if calc_dict[i]==-1:
#         calc_dict[i] = bin(i).count("1")

#     res_dict[i] = i%calc_dict[i]+1

def mods(temp, count):
    count+=1
    if temp!=0:

#         if temp in res_dict:
#             return count+res_dict[temp]
        
#         if temp not in calc_dict:
#             calc_dict[temp]= bin(temp).count("1") 
        count = mods(temp%bin(temp).count("1") , count)

    return count

for i in range(N):
    if S[i]=="0":
        part = pow(2, (N-i-1), bit_count+1)
        num = (S_plu + part ) % (bit_count+1)
        print(mods(num, 0))
    else:
        if S_num == 2**(N-i-1):
            print(0)
            continue
        part = pow(2, (N-i-1), bit_count-1)
        num = (S_min - part)%(bit_count-1)
        print(mods(num, 0))
import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = readline().decode().strip()
K = int(readline())
cnt = 0
ans = 0
for i in N:
    if len(N) == 1:
        ans = N[0]
        break
    if i == '1':
        cnt += 1
        continue
    else:
        if int(i) * 5000 * 10 ** 12 + cnt >= K:
            ans = i
            break
        else:
            ans = N[N.find(i) + 1]
            break

print(ans)


### FIXED CODE ###

import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *d = map(int, read().split())
d.sort()

ans = d[N // 2] - d[N // 2 - 1]
print(ans)