S = input().strip()

K = int(eval(input()))

N = len(S)

ind = N

for i in range(N):

    if S[i]!="1":

        ind = i

        break

if K<=ind:

    print((1))

else:

    print((S[ind]))
S = input().strip()

K = int(eval(input()))

a = "1"

ind = len(S)

for i in range(len(S)):

    if S[i]!="1":

        a = S[i]

        ind = i

        break

if K<=ind:

    print((1))

else:

    print(a)
S = input().strip()
K = int(eval(input()))
N = len(S)
ind = N
for i in range(N):
    if S[i] != "1":
        ind = i
        break
if K <= ind:
    print((1))
else:
    print((S[ind]))

S = input().strip()
K = int(eval(input()))
a = "1"
ind = len(S)
for i in range(len(S)):
    if S[i] != "1":
        a = S[i]
        ind = i
        break
if K <= ind:
    print((1))
else:
    print(a)

-N = len(S) -ind = N -for i in range(N): +a = "1" +ind = len(S) +for i in range(len(S)): +        a = S[i] -    print((S[ind])) +    print(a)