#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
const double pi = acos(-1.0);
struct Complex {
  double x, y;
  Complex(double x = 0.0, double y = 0.0) {
    this->x = x;
    this->y = y;
  }
  Complex operator-(const Complex &b) const {
    return Complex(x - b.x, y - b.y);
  }
  Complex operator+(const Complex &b) const {
    return Complex(x + b.x, y + b.y);
  }
  Complex operator*(const Complex &b) const {
    return Complex(x * b.x - y * b.y, x * b.y + y * b.x);
  }
};
void change(Complex y[], int len) {
  for (int i = 1, j = len / 2; i < len - 1; i++) {
    if (i < j) swap(y[i], y[j]);
    int k = len / 2;
    while (j >= k) {
      j -= k;
      k /= 2;
    }
    if (j < k) j += k;
  }
}
void fft(Complex y[], int len, int on) {
  change(y, len);
  for (int h = 2; h <= len; h <<= 1) {
    Complex wn(cos(-on * 2 * pi / h), sin(-on * 2 * pi / h));
    for (int j = 0; j < len; j += h) {
      Complex w(1, 0);
      for (int k = j; k < j + h / 2; k++) {
        Complex u = y[k];
        Complex t = w * y[k + h / 2];
        y[k] = u + t;
        y[k + h / 2] = u - t;
        w = w * wn;
      }
    }
  }
  if (on == -1)
    for (int i = 0; i < len; i++) y[i].x /= len;
}
int n, m, k, i, j, p[30];
Complex A[N], B[N], C[N];
int a[N], b[N];
char sa[N], sb[N];
int main() {
  for (i = 1; i <= 26; i++) scanf("%d", &p[i]);
  scanf("%s %s", sa, sb);
  m = strlen(sa), n = strlen(sb);
  for (i = 0, j = m - 1; i < j; i++, j--) swap(sa[i], sa[j]);
  for (i = 0; i < m; i++) a[i] = sa[i] - 'a' + 1;
  for (i = 0; i < n; i++) b[i] = sb[i] - 'a' + 1;
  for (k = 1; k < n; k <<= 1)
    ;
  for (i = 0; i < k; i++)
    A[i] = Complex(2 * a[i] * p[a[i]] * (a[i] + p[a[i]]), 0),
    B[i] = Complex(b[i], 0);
  for (fft(A, k, 1), fft(B, k, 1), i = 0; i < k; i++) C[i] = C[i] - A[i] * B[i];
  for (i = 0; i < k; i++)
    A[i] = Complex(a[i] * a[i] + p[a[i]] * p[a[i]] + 4 * a[i] * p[a[i]], 0),
    B[i] = Complex(b[i] * b[i], 0);
  for (fft(A, k, 1), fft(B, k, 1), i = 0; i < k; i++) C[i] = C[i] + A[i] * B[i];
  for (i = 0; i < k; i++)
    A[i] = Complex(2 * (a[i] + p[a[i]]), 0),
    B[i] = Complex(b[i] * b[i] * b[i], 0);
  for (fft(A, k, 1), fft(B, k, 1), i = 0; i < k; i++) C[i] = C[i] - A[i] * B[i];
  for (i = 0; i < k; i++) {
    if (i < m)
      A[i] = Complex(1, 0);
    else
      A[i] = Complex(0, 0);
    B[i] = Complex(b[i] * b[i] * b[i] * b[i], 0);
  }
  for (fft(A, k, 1), fft(B, k, 1), i = 0; i < k; i++) C[i] = C[i] + A[i] * B[i];
  for (i = 0; i < k; i++) {
    A[i] = Complex(a[i] * a[i] * p[a[i]] * p[a[i]], 0);
    if (i < n)
      B[i] = Complex(1, 0);
    else
      B[i] = Complex(0, 0);
  }
  for (fft(A, k, 1), fft(B, k, 1), i = 0; i < k; i++) C[i] = C[i] + A[i] * B[i];
  fft(C, k, -1);
  for (int i = 0; i < n - m + 1; i++)
    printf("%d", ((long long)(C[i + m - 1].x + 0.5) == 0));
  return 0;
}
