#include <bits/stdc++.h>
const int mod = 998244353;
const int MaxN = 6e5 + 10;
const int G = 3, Ginv = 332748118;
char s[MaxN], t[MaxN];
int n, m, lg, now, lim = 1, w[27], p[27], f[MaxN], c[MaxN];
int g[MaxN], h[MaxN], a[MaxN], b[MaxN], r[MaxN], ans[MaxN], pre[MaxN];
int Rand() { return rand() << 15 | rand(); }
int fast_pow(int a, int b) {
  int ret = 1;
  while (b) {
    if (b & 1) ret = ret * 1ll * a % mod;
    a = a * 1ll * a % mod;
    b >>= 1;
  }
  return ret;
}
inline int read() {
  int x = 0;
  char ch = getchar();
  while (ch > '9' || ch < '0') ch = getchar();
  while (ch <= '9' && ch >= '0')
    x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  return x;
}
void ntt(int *a, int lim, int flag) {
  for (int i = 0; i < lim; i++)
    if (i < r[i]) std::swap(a[i], a[r[i]]);
  for (int i = 1; i < lim; i <<= 1) {
    int w = fast_pow((~flag) ? G : Ginv, (mod - 1) / 2 / i);
    for (int j = 0; j < lim; j += (i << 1)) {
      int t = 1;
      for (int k = 0; k < i; k++, t = t * 1ll * w % mod) {
        int nx = a[j + k], ny = 1ll * t * a[i + j + k] % mod;
        a[j + k] = (nx + ny) % mod, a[j + k + i] = (nx - ny + mod) % mod;
      }
    }
  }
  if (flag == -1) {
    int inv = fast_pow(lim, mod - 2);
    for (int i = 0; i < lim; i++) a[i] = (long long)a[i] * inv % mod;
  }
}
signed main() {
  for (int i = 0; i < 26; i++) p[i] = read() - 1, w[i] = Rand() % mod;
  scanf("%s%s", s + 1, t + 1), m = strlen(s + 1), n = strlen(t + 1);
  while (lim <= n + m) lim <<= 1, ++lg;
  for (int i = 0; i < lim; i++) r[i] = (r[i >> 1] >> 1) | ((i & 1) << (lg - 1));
  std::reverse(s + 1, s + m + 1);
  for (int i = 1; i <= n; i++)
    b[i] = f[i] = w[t[i] - 'a'],
    pre[i] = (((pre[i - 1]) + ((long long)f[i] * f[i] % mod)) % mod);
  for (int i = 1; i <= m; i++)
    g[i] = w[p[s[i] - 'a']], h[i] = w[s[i] - 'a'],
    now = (((now) + ((long long)h[i] * g[i])) % mod);
  for (int i = 1; i <= m; i++) a[i] = (((h[i]) + (g[i])) % mod);
  ntt(a, lim, 1), ntt(b, lim, 1);
  for (int i = 0; i < lim; i++) c[i] = (long long)a[i] * b[i] % mod;
  ntt(c, lim, -1);
  for (int i = 1; i <= n + m; i++) ans[i] = (((ans[i]) + (mod - c[i])) % mod);
  for (int i = m + 1; i <= n + 1; i++) {
    ans[i] =
        ((((((ans[i]) + (now)) % mod)) + (pre[i - 1] - pre[i - m - 1] + mod)) %
         mod);
    printf((ans[i] == 0) ? "1" : "0");
  }
  return 0;
}
