//config = { input: 'tmp', newline: '\r\n' }; // win
config = { input: '/dev/stdin', newline: '\n' }; // linux

line = require('fs').readFileSync(config.input, 'ascii')
  .split(config.newline);
T = line[0];
Q = Number(line[1]);
P = line.slice(2, 2+Q);
line = null; // dispose

for (i in P) console.log((T.indexOf(P[i]) !== -1) ? 1 : 0);