#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
const int P = 1e9 + 7, INF = 0x3f3f3f3f;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long qpow(long long a, long long n) {
  long long r = 1 % P;
  for (a %= P; n; a = a * a % P, n >>= 1)
    if (n & 1) r = r * a % P;
  return r;
}
long long inv(long long first) {
  return first <= 1 ? 1 : inv(P % first) * (P - P / first) % P;
}
inline int rd() {
  int first = 0;
  char p = getchar();
  while (p < '0' || p > '9') p = getchar();
  while (p >= '0' && p <= '9') first = first * 10 + p - '0', p = getchar();
  return first;
}
const int N = 2e5 + 10;
int n, m, a[26], pos[26];
char s[N], t[N];
bitset<N> ch[26], ans;
int main() {
  for (int i = 0; i <= 25; ++i) scanf("%d", a + i), pos[a[i] - 1] = i;
  scanf("%s%s", s, t);
  n = strlen(s), m = strlen(t);
  for (int i = 0; i <= m - 1; ++i) {
    ch[t[i] - 'a'].set(i);
    ch[pos[t[i] - 'a']].set(i);
  }
  ans.set();
  for (int i = 0; i <= n - 1; ++i) ans &= ch[s[i] - 'a'] >> i;
  for (int i = 0; i <= m - n; ++i) cout << ans[i];
  putchar(10);
}
