#include <bits/stdc++.h>
using namespace std;
const int P = 998244353;
const int mo = 998244353;
const int N = (1 << 20) + 10;
const int maxn = (1 << 20) + 10;
int fexp(int a, int n) {
  int res = 1;
  for (; n; n >>= 1, a = 1ll * a * a % P)
    if (n & 1) res = 1ll * res * a % P;
  return res;
}
struct da {
  int n, w[2][N];
  void init(int lim) {
    for (n = 1; n < lim; n <<= 1)
      ;
    w[0][0] = w[0][n] = 1;
    int g = fexp(3, (P - 1) / n);
    for (int i = 1; i < n; i++) w[0][i] = 1ll * w[0][i - 1] * g % P;
    for (int i = 0; i <= n; i++) w[1][i] = w[0][n - i];
  }
  void ntt(int *a, int v) {
    for (int i = 0, j = 0; i < n; i++) {
      if (i > j) swap(a[i], a[j]);
      for (int l = n >> 1; (j ^= l) < l; l >>= 1)
        ;
    }
    for (int l = 2; l <= n; l <<= 1) {
      int m = l >> 1;
      for (int i = 0; i < n; i += l)
        for (int k = 0; k < m; k++) {
          int t = 1ll * w[v][n / l * k] * a[i + k + m] % P;
          a[i + k + m] =
              (a[i + k] - t >= 0) ? (a[i + k] - t) : (a[i + k] - t + P);
          a[i + k] = (a[i + k] + t < P) ? (a[i + k] + t) : (a[i + k] + t - P);
        }
    }
    if (!v) return;
    int rv = fexp(n, P - 2);
    for (int i = 0; i < n; i++) a[i] = 1ll * a[i] * rv % P;
  }
  void work(int *a, int *b, int *c, int m) {
    init(m);
    ntt(a, 0);
    ntt(b, 0);
    for (int i = 0; i < n; i++) c[i] = 1ll * a[i] * b[i] % P;
    ntt(c, 1);
  }
} NTT;
int n, m, p[30], val[30], a[6][maxn], b[6][maxn], c[maxn], ans[maxn];
char s[maxn], t[maxn];
set<int> ssss;
int main() {
  srand((unsigned)time(0));
  for (int i = 0; i < 26; i++)
    val[i] = rand() % 20000313 + 1, ssss.insert(val[i]);
  if ((int)ssss.size() < 26) assert(0);
  for (int i = 0; i < 26; i++) {
    int x;
    scanf("%d", &x);
    p[x - 1] = i;
  }
  scanf("%s%s", s, t);
  m = strlen(s);
  n = strlen(t);
  for (int i = 0; i < m; i++) {
    int u = val[s[i] - 'a'];
    b[4][i] = 1;
    for (int j = 3; j >= 0; --j) b[j][i] = 1ll * b[j + 1][i] * u % mo;
  }
  for (int i = 0; i < n; i++) {
    int u = val[t[i] - 'a'], v = val[p[t[i] - 'a']];
    a[0][i] = 1 % mo;
    a[1][i] = (mo - 2ll * (u + v) % mo) % mo;
    a[2][i] = (1ll * v * v % mo + 1ll * u * u % mo + 4ll * u * v % mo) % mo;
    a[3][i] =
        (mo -
         2ll * (1ll * u * v % mo * v % mo + 1ll * v * u % mo * u % mo) % mo) %
        mo;
    a[4][i] = 1ll * v * v % mo * u % mo * u % mo;
  }
  for (int i = 0; i <= 4; i++) {
    reverse(b[i], b[i] + m);
    memset(c, 0, sizeof c);
    NTT.work(a[i], b[i], c, n + m + 100);
    for (int j = m - 1; j < n; ++j) ans[j] = (ans[j] + c[j]) % mo;
  }
  for (int i = m - 1; i < n; i++) printf("%d", (ans[i] == 0));
  printf("\n");
  return 0;
}
