#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2e5, mod = 998244353;   inline int mod1(int x) { return x < mod ? x : x - mod; }   inline int mod2(int x) { return x < 0 ? x + mod : x; }   inline void add(int &x, int y) { x = mod1(x + y); }   inline void sub(int &x, int y) { x = mod2(x - y); }   inline int pow_mod(int x, int i) {     int y = 1;     while (i) {       if (i & 1) y = (long long)y * x % mod;       x = (long long)x * x % mod;       i >>= 1;     }     return y;   }   int p[26], val[26], m, n, s[MAXN + 5], t[MAXN + 5], vs[MAXN + 5], vt[MAXN + 5],       res[MAXN + 5], f[MAXN * 4 + 5], g[MAXN * 4 + 5], rev[MAXN * 4 + 5];   char str[MAXN + 5];   void NTT(int *a, int n, int flag) {     for (int i = 0; i < n; ++i)       if (i < rev[i]) swap(a[i], a[rev[i]]);     for (int i = 1; i < n; i <<= 1) {       int T = pow_mod(3, (mod - 1) / (i << 1));       if (flag == -1) T = pow_mod(T, mod - 2);       for (int j = 0; j < n; j += (i << 1)) {         for (int k = 0, t = 1; k < i; ++k, t = (long long)t * T % mod) {           int Nx = a[j + k], Ny = (long long)a[i + j + k] * t % mod;           a[j + k] = mod1(Nx + Ny);           a[i + j + k] = mod2(Nx - Ny);         }       }     }     if (flag == -1) {       int invn = pow_mod(n, mod - 2);       for (int i = 0; i < n; ++i) a[i] = (long long)a[i] * invn % mod;     }   }   bool ck(int i) {     for (int j = 0; j < i; ++j)       if (val[i] == val[j]) return 0;     return 1;   }   int main() {     for (int i = 0; i < 26; ++i) {       val[i] = rand() % mod;       while (!ck(i)) add(val[i], 1);     }     for (int i = 0; i < 26; ++i) cin >> p[i], p[i] = val[p[i] - 1];     cin >> str;     m = strlen(str);     reverse(str, str + m);     for (int i = 0; i < m; ++i) vs[i] = val[s[i] = str[i] -  a ];     cin >> str;     n = strlen(str);     for (int i = 0; i < n; ++i) vt[i] = val[t[i] = str[i] -  a ];     int tmp = 0, tmpp = 0;     for (int i = 0; i < m; ++i)       add(tmp, (long long)p[s[i]] * p[s[i]] % mod * vs[i] % mod * vs[i] % mod);     for (int i = 0; i < m; ++i) add(tmpp, (long long)pow_mod(vt[i], 4));     res[m - 1] = (tmpp + tmp) % mod;     for (int i = m; i < n; ++i)       res[i] =           ((res[i - 1] + pow_mod(vt[i], 4) - pow_mod(vt[i - m], 4)) % mod + mod) %           mod;     for (int i = 0; i < m; ++i)       f[i] = (long long)p[s[i]] * vs[i] % mod * mod1(p[s[i]] + vs[i]) % mod;     for (int i = 0; i < n; ++i) g[i] = vt[i];     int len = 1, ct = 0;     while (len <= n + m) len <<= 1, ++ct;     for (int i = 0; i < len; ++i)       rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (ct - 1));     NTT(f, len, 1);     NTT(g, len, 1);     for (int i = 0; i < len; ++i) f[i] = (long long)f[i] * g[i] % mod;     NTT(f, len, -1);     for (int i = m - 1; i < n; ++i) sub(res[i], mod1(2 * f[i]));     for (int i = 0; i < m; ++i)       f[i] = ((long long)vs[i] * vs[i] % mod +               (long long)p[s[i]] * p[s[i]] % mod + 4LL * vs[i] * p[s[i]] % mod) %              mod;     for (int i = m; i < len; ++i) f[i] = 0;     for (int i = 0; i < n; ++i) g[i] = (long long)vt[i] * vt[i] % mod;     for (int i = n; i < len; ++i) g[i] = 0;     NTT(f, len, 1);     NTT(g, len, 1);     for (int i = 0; i < len; ++i) f[i] = (long long)f[i] * g[i] % mod;     NTT(f, len, -1);     for (int i = m - 1; i < n; ++i) add(res[i], f[i]);     for (int i = 0; i < m; ++i) f[i] = mod1(vs[i] + p[s[i]]);     for (int i = m; i < len; ++i) f[i] = 0;     for (int i = 0; i < n; ++i)       g[i] = (long long)vt[i] * vt[i] % mod * vt[i] % mod;     for (int i = n; i < len; ++i) g[i] = 0;     NTT(f, len, 1);     NTT(g, len, 1);     for (int i = 0; i < len; ++i) f[i] = (long long)f[i] * g[i] % mod;     NTT(f, len, -1);     for (int i = m - 1; i < n; ++i) sub(res[i], mod1(2 * f[i]));     for (int i = m - 1; i < n; ++i)       if (!res[i])         cout <<  1 ;       else         cout <<  0 ;   }