T = input()
n = int(input())
P = input()

for a in range(n):
    for i in range(len(T)-len(P)+1):
        if T[i:i+len(P)] == P:
            print(1)
            return
        else:
            print(0)
            return: