#include <bits/stdc++.h>
long long gi() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) f ^= ch == '-', ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return f ? x : -x;
}
template <class T>
void cxk(T& a, T b) {
  a = a > b ? a : b;
}
template <class T>
void cnk(T& a, T b) {
  a = a < b ? a : b;
}
struct cp {
  double x, y;
  cp() {}
  cp(double x, double y = 0) : x(x), y(y) {}
};
cp operator+(cp a, cp b) { return cp(a.x + b.x, a.y + b.y); }
void operator+=(cp& a, cp b) { a.x += b.x, a.y += b.y; }
cp operator-(cp a, cp b) { return cp(a.x - b.x, a.y - b.y); }
cp operator*(cp a, cp b) {
  return cp(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x);
}
cp operator/=(cp& a, int b) { return a.x /= b, a.y /= b; }
cp conj(cp a) { return cp(a.x, -a.y); }
cp A[1 << 19], B[1 << 19];
cp w[1 << 19], P[30], Q[1 << 19];
int rev[1 << 19];
const double pi = acos(-1);
void fft(cp* A, int n, int t) {
  for (int i = 0; i < n; ++i)
    if (rev[i] > i) std::swap(A[i], A[rev[i]]);
  for (int s = 1, _ = 1; s < n; s <<= 1, ++_) {
    for (int i = 1; i < s; ++i) Q[i] = Q[i - 1] * P[_];
    for (cp* p = A; p != A + n; p += s << 1)
      for (int i = 0; i < s; ++i) {
        cp t = Q[i] * p[s + i];
        p[s + i] = p[i] - t;
        p[i] += t;
      }
  }
  if (!t) {
    std::reverse(A + 1, A + n);
    for (int i = 0; i < n; ++i) A[i] /= n;
  }
}
int p[26];
char S[200010], T[200010];
int ans[200010];
int main() {
  for (int i = 1; i < 30; ++i)
    P[i] = {cos(2 * pi / (1 << i)), sin(2 * pi / (1 << i))};
  Q[0] = {1, 0};
  for (int i = 0; i < 26; ++i) p[gi() - 1] = i;
  scanf("%s%s", S + 1, T + 1);
  int ls = strlen(S + 1), lt = strlen(T + 1);
  int N = 1;
  while (N < lt * 2 + 3) N <<= 1;
  for (int i = 1; i < N; ++i) rev[i] = (rev[i >> 1] >> 1) + (N >> 1) * (i & 1);
  std::reverse(S + 1, S + ls + 1);
  for (int c = 0, c2 = 13; c < 13; ++c, ++c2) {
    for (int i = 1; i <= ls; ++i)
      if (S[i] == c + 'a' || S[i] == p[c] + 'a') A[i].x = 1;
    for (int i = 1; i <= lt; ++i)
      if (T[i] == c + 'a') B[i].x = 1;
    for (int i = 1; i <= ls; ++i)
      if (S[i] == c2 + 'a' || S[i] == p[c2] + 'a') A[i].y = 1;
    for (int i = 1; i <= lt; ++i)
      if (T[i] == c2 + 'a') B[i].y = -1;
    fft(A, N, 1);
    fft(B, N, 1);
    for (int i = 0; i < N; ++i) A[i] = A[i] * B[i];
    fft(A, N, 0);
    for (int i = ls; i <= lt; ++i) ans[i] += int(A[i + 1].x + 0.5);
    memset(A, 0, sizeof(cp) * N);
    memset(B, 0, sizeof(cp) * N);
  }
  for (int i = ls; i <= lt; ++i) putchar('0' + (ans[i] == ls));
  return 0;
}
