#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  if (c == '-') f = -1, c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return f * x;
}
const int maxn = (1 << 19) + 7;
const long double PI = acos(-1);
struct CP {
  long double x, y;
  CP(long double x = 0, long double y = 0) : x(x), y(y) {}
  CP operator+(CP const &rhs) const { return CP(x + rhs.x, y + rhs.y); }
  CP operator-(CP const &rhs) const { return CP(x - rhs.x, y - rhs.y); }
  CP operator*(CP const &rhs) const {
    return CP(x * rhs.x - y * rhs.y, x * rhs.y + y * rhs.x);
  }
  friend CP operator*(int a, CP const &b) { return CP(a * b.x, a * b.y); }
} f[maxn], g[maxn], sum[maxn];
int n, m, nm, up;
char s[maxn], t[maxn];
int p[27], ans[maxn];
int tr[maxn], a[maxn], b[maxn];
long long pre[maxn];
void FFT(CP *f, int op) {
  for (int i = 0; i < up; ++i)
    if (i < tr[i]) swap(f[i], f[tr[i]]);
  for (int len = 2; len <= up; len <<= 1) {
    CP w1(cos(2 * PI / len), op * sin(2 * PI / len));
    int hf = len >> 1;
    for (int l = 0; l < up; l += len) {
      CP w(1, 0);
      for (int i = l; i < l + hf; ++i) {
        CP tp = w * f[i + hf];
        f[i + hf] = f[i] - tp;
        f[i] = f[i] + tp;
        w = w * w1;
      }
    }
  }
  if (op == -1)
    for (int i = 0; i < up; ++i) f[i].x /= up;
}
int main() {
  for (int i = 1; i <= 26; ++i) p[i] = read();
  scanf("%s%s", s, t);
  m = strlen(s), n = strlen(t);
  reverse(s, s + m);
  for (int i = 0; s[i]; ++i) a[i] = s[i] - 'a' + 1;
  for (int i = 0; t[i]; ++i) b[i] = t[i] - 'a' + 1;
  for (nm = n + m, up = 1; up <= nm; up <<= 1)
    ;
  for (int i = 0; i < up; ++i)
    tr[i] = (tr[i >> 1] >> 1) | ((i & 1) ? up >> 1 : 0);
  for (int i = 0; i < up; ++i) {
    if (i >= m)
      f[i].x = 0;
    else
      f[i].x = a[i] * p[a[i]] * (a[i] + p[a[i]]);
    f[i].y = 0;
  }
  for (int i = 0; i < up; ++i) {
    if (i >= n)
      g[i].x = 0;
    else
      g[i].x = b[i];
    g[i].y = 0;
  }
  FFT(f, 1);
  FFT(g, 1);
  for (int i = 0; i < up; ++i) sum[i] = sum[i] - 2 * f[i] * g[i];
  for (int i = 0; i < up; ++i) {
    if (i >= m)
      f[i].x = 0;
    else
      f[i].x = a[i] * a[i] + p[a[i]] * p[a[i]] + 4 * a[i] * p[a[i]];
    f[i].y = 0;
  }
  for (int i = 0; i < up; ++i) {
    if (i >= n)
      g[i].x = 0;
    else
      g[i].x = b[i] * b[i];
    g[i].y = 0;
  }
  FFT(f, 1);
  FFT(g, 1);
  for (int i = 0; i < up; ++i) sum[i] = sum[i] + f[i] * g[i];
  for (int i = 0; i < up; ++i) {
    if (i >= m)
      f[i].x = 0;
    else
      f[i].x = a[i] + p[a[i]];
    f[i].y = 0;
  }
  for (int i = 0; i < up; ++i) {
    if (i >= n)
      g[i].x = 0;
    else
      g[i].x = b[i] * b[i] * b[i];
    g[i].y = 0;
  }
  FFT(f, 1);
  FFT(g, 1);
  for (int i = 0; i < up; ++i) sum[i] = sum[i] - 2 * f[i] * g[i];
  FFT(sum, -1);
  long long pre0 = 0;
  for (int i = 0; i < m; ++i) pre0 += a[i] * a[i] * p[a[i]] * p[a[i]];
  for (int i = 0; i < n; ++i) pre[i] = b[i] * b[i] * b[i] * b[i];
  for (int i = 1; i < n; ++i) pre[i] += pre[i - 1];
  for (int i = m - 1; i < n; ++i) {
    sum[i].x += pre[i] + pre0;
    if (i != m - 1) sum[i].x -= pre[i - m];
  }
  for (int i = m - 1; i < n; ++i) ans[i] = fabs(sum[i].x) < 0.5;
  for (int i = m - 1; i < n; ++i) printf("%d", ans[i]);
  puts("");
}
