#include <bits/stdc++.h>
using namespace std;
const int MAXL = 555555;
const int D = 998244353, G = 3, invG = 332748118;
int p[27];
int n, m, lim;
char a[MAXL], b[MAXL];
int val[27];
int rev[MAXL];
int A[MAXL], B[MAXL], F[MAXL], S[MAXL], out[MAXL];
int add(int x, int y) { return x + y < D ? x + y : x + y - D; }
int dec(int x, int y) { return x < y ? x - y + D : x - y; }
int qpow(int x, int y) {
  int ret = 1;
  while (y) {
    if (y & 1) ret = 1ll * ret * x % D;
    x = 1ll * x * x % D;
    y >>= 1;
  }
  return ret;
}
void NTT(int *f, int op) {
  for (int i = 1; i < lim; i++)
    if (i < rev[i]) swap(f[i], f[rev[i]]);
  for (int i = 1; i < lim; i <<= 1)
    for (int sta = qpow((~op) ? G : invG, (D - 1) / (i << 1)), j = 0; j < lim;
         j += (i << 1))
      for (int w = 1, t1, t2, k = 0; k < i; k++, w = 1ll * w * sta % D)
        t1 = f[j + k], t2 = 1ll * w * f[i + j + k] % D, f[j + k] = add(t1, t2),
        f[i + j + k] = dec(t1, t2);
  if (op == -1)
    for (int inv_lim = qpow(lim, D - 2), i = 0; i < lim; i++)
      f[i] = 1ll * f[i] * inv_lim % D;
}
int gv(char c) { return c ? val[c - 'a' + 1] : 0; }
int gvp(char c) { return c ? val[p[c - 'a' + 1]] : 0; }
int main() {
  srand(19260817);
  for (int i = 1; i <= 26; i++)
    scanf("%d", &p[i]), val[i] = rand() % (D - 1) + 1;
  scanf("%s%s", a, b);
  n = strlen(a), m = strlen(b);
  reverse(a, a + n);
  for (lim = 1; lim <= n + m; lim <<= 1)
    ;
  for (int i = 1; i < lim; i++)
    rev[i] = (rev[i >> 1] >> 1) | (i & 1 ? lim >> 1 : 0);
  for (int i = 0; i < lim; i++) A[i] = add(gv(a[i]), gvp(a[i]));
  for (int i = 0; i < lim; i++) B[i] = gv(b[i]);
  NTT(A, 1), NTT(B, 1);
  for (int i = 0; i < lim; i++) F[i] = 1ll * A[i] * B[i] % D;
  NTT(F, -1);
  for (int i = 0; i < lim; i++)
    S[i] = add(i ? S[i - 1] : 0,
               (1ll * gv(a[i]) * gvp(a[i]) + 1ll * gv(b[i]) * gv(b[i])) % D);
  for (int i = 0; i < lim; i++)
    out[i] = add(i ? out[i - 1] : 0, 1ll * gv(b[i]) * gv(b[i]) % D);
  putchar(dec(S[n - 1], F[n - 1]) == 0 ? '1' : '0');
  for (int i = n; i < m; i++)
    putchar(dec(S[i], F[i]) == out[i - n] ? '1' : '0');
  puts("");
  return 0;
}
