#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int N = 8e5 + 5;
namespace poly {
const double PI = acos(-1);
int rev[N];
struct complex {
  double x, y;
};
complex operator+(complex a, complex b) {
  return (complex){a.x + b.x, a.y + b.y};
}
complex operator-(complex a, complex b) {
  return (complex){a.x - b.x, a.y - b.y};
}
complex operator*(complex a, complex b) {
  return (complex){a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x};
}
void FFT(int len, complex *a, int opt) {
  for (int i = 0; i < len; i++) {
    if (i < rev[i]) {
      swap(a[i], a[rev[i]]);
    }
  }
  for (int siz = 2; siz <= len; siz <<= 1) {
    int mid = siz >> 1;
    complex Wn = (complex){cos(2.0 * PI / siz), opt * sin(2.0 * PI / siz)};
    for (int l = 0; l < len; l += siz) {
      complex w = (complex){1, 0};
      for (int i = l; i < l + mid; i++, w = w * Wn) {
        complex x = a[i], y = w * a[i + mid];
        a[i] = x + y, a[i + mid] = x - y;
      }
    }
  }
  if (opt == -1) {
    for (int i = 0; i < len; i++) {
      a[i].x /= len, a[i].y /= len;
    }
  }
}
}  // namespace poly
void solve() {
  static char s[N], t[N];
  static int p[30];
  static poly::complex f[N], g[N], h[N];
  for (int i = 1; i <= 26; i++) {
    scanf("%d", &p[i]);
  }
  scanf("%s%s", t, s);
  int n = strlen(s), m = strlen(t);
  int len = 1;
  while (len < n - 1) {
    len <<= 1;
  }
  for (int i = 0; i < len; i++) {
    poly::rev[i] = (poly::rev[i >> 1] >> 1) | ((i & 1) * (len >> 1));
  }
  reverse(t, t + m);
  for (int k = 1; k <= 26; k += 2) {
    memset(f, 0, sizeof(f));
    memset(g, 0, sizeof(g));
    for (int i = 0; i < n; i++) {
      int ch = s[i] - 'a' + 1;
      f[i].x = (ch == k);
      f[i].y = (ch == k + 1);
    }
    for (int i = 0; i < m; i++) {
      int ch = t[i] - 'a' + 1;
      g[i].x = ((ch == k) || (p[ch] == k));
      g[i].y = -((ch == k + 1) || (p[ch] == k + 1));
    }
    poly::FFT(len, f, 1), poly::FFT(len, g, 1);
    for (int i = 0; i < len; i++) {
      h[i] = h[i] + f[i] * g[i];
    }
  }
  poly::FFT(len, h, -1);
  for (int i = 0; i <= n - m; i++) {
    if ((long long)(h[m + i - 1].x + 0.5) == m) {
      printf("1");
    } else {
      printf("0");
    }
  }
  printf("\n");
}
int main() {
  solve();
  return 0;
}
