#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define M 1000000
#define N 1000

int main(){

 int i;
 int j;
 int num;
 int str_length;
 int cmp_length;
 char *str;
 char *cmp;

  str = (char *)malloc(sizeof(char) * M);
  cmp = (char *)malloc(sizeof(char) * N);

  scanf("%s",str);
  str_length = strlen(str);

  scanf("%d",&num);
  for(i=0;i<num;i++){
  scanf("%s",cmp);
  cmp_length = strlen(cmp);
  for(j=0;j<str_length;j++){

  if( strncmp(str+j,cmp,cmp_length) ==0 ){
  printf("1");
  break;
  }

  if(j==str_length-1){
  printf("0");
  }

   }
  }

  return 0;