#include <bits/stdc++.h>
using namespace std;
const int maxn = 8e5 + 13;
const double pi = acos(-1.0);
char s[maxn], t[maxn];
int ids[maxn], idt[maxn];
int p[maxn];
int pos[maxn], n, m;
double res = 0;
int len = 1;
double f[maxn];
struct cpx {
  double a, b;
  cpx(double x = 0.0, double y = 0.0) { a = x, b = y; }
  cpx operator-(cpx &x) { return cpx(a - x.a, b - x.b); }
  cpx operator+(cpx &x) { return cpx(a + x.a, b + x.b); }
  cpx operator*(cpx &x) { return cpx(x.a * a - x.b * b, a * x.b + b * x.a); }
} c[9][maxn], ans[9][maxn];
void ini() {
  for (int i = 0; i < len; i++) {
    pos[i] = pos[i >> 1] >> 1;
    if (i & 1) pos[i] |= (len >> 1);
  }
}
void fft(cpx x[], int on) {
  for (int i = 0; i < len; i++)
    if (i < pos[i]) swap(x[i], x[pos[i]]);
  for (int i = 2; i <= len; i <<= 1) {
    int step = i >> 1;
    cpx wm(cos(2 * pi / (double)i), sin(2 * pi * on / (double)i));
    for (int j = 0; j < len; j += i) {
      int mx = j + step;
      cpx now(1, 0);
      for (int k = j; k < mx; k++) {
        cpx aa = x[k], bb = x[k + step] * now;
        now = now * wm;
        x[k] = aa + bb;
        x[k + step] = aa - bb;
      }
    }
  }
  if (on == -1)
    for (int i = 0; i < len; i++) x[i].a /= (double)len;
}
void pre() {
  res = 0;
  for (int i = 0; i < m; i++) ids[i] = s[i] - 'a' + 1;
  for (int i = 0; i < n; i++) idt[i] = t[i] - 'a' + 1;
  for (int i = 0; i < m; i++) res += ids[i] * ids[i] * p[ids[i]] * p[ids[i]];
  for (int i = m - 1, j = 0; i >= 0; i--, j++) {
    c[0][j].a =
        ids[i] * ids[i] + p[ids[i]] * p[ids[i]] + 4 * ids[i] * p[ids[i]];
    c[1][j].a =
        2 * ids[i] * ids[i] * p[ids[i]] + 2 * ids[i] * p[ids[i]] * p[ids[i]];
    c[2][j].a = 2 * p[ids[i]] + 2 * ids[i];
  }
  for (int i = 0; i < n; i++) {
    c[3][i].a = idt[i];
    c[4][i].a = idt[i] * idt[i];
    c[5][i].a = idt[i] * idt[i] * idt[i];
    c[6][i + 1].a = c[6][i].a + idt[i] * idt[i] * idt[i] * idt[i];
  }
}
int main() {
  for (int i = 1; i <= 26; i++) scanf("%d", &p[i]);
  scanf("%s", s);
  scanf("%s", t);
  n = strlen(t);
  m = strlen(s);
  pre();
  while (len < (n + m)) len <<= 1;
  ini();
  fft(c[4], 1), fft(c[0], 1);
  for (int i = 0; i < len; i++) ans[0][i] = c[4][i] * c[0][i];
  fft(ans[0], -1);
  fft(c[3], 1), fft(c[1], 1);
  for (int i = 0; i < len; i++) ans[1][i] = c[3][i] * c[1][i];
  fft(ans[1], -1);
  fft(c[5], 1), fft(c[2], 1);
  for (int i = 0; i < len; i++) ans[2][i] = c[5][i] * c[2][i];
  fft(ans[2], -1);
  for (int i = 0; i < n - m + 1; i++)
    f[i] = res + ans[0][m - 1 + i].a - ans[1][m - 1 + i].a -
           ans[2][m - 1 + i].a + c[6][i + m].a - c[6][i].a;
  for (int i = 0; i < n - m + 1; i++) printf("%d", ((int)(f[i] + 0.5) == 0));
}
