#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
using namespace std;
template <class T1, class T2>
ostream &operator<<(ostream &os, pair<T1, T2> &p);
template <class T>
ostream &operator<<(ostream &os, vector<T> &v);
template <class T>
ostream &operator<<(ostream &os, set<T> &v);
const long long mod = 1e9 + 7;
const int N = 2e5 + 5;
char s[N], t[N];
bitset<N> bt[26], ans;
void SOLVE(int cas) {
  int p[26];
  for (int i = 0; i < 26; i++) {
    scanf("%d", &p[i]);
    p[i]--;
  }
  scanf("%s", s);
  scanf("%s", t);
  int n = strlen(s);
  int m = strlen(t);
  ans.set();
  for (int i = 0; i < m; i++) {
    bt[t[i] - 'a'][i] = 1;
  }
  for (int i = 0; i < n; i++) {
    int now = s[i] - 'a';
    ans &= ((bt[now] | bt[p[now]]) >> i);
  }
  for (int i = 0; i < (m - n + 1); i++) {
    char ch = (ans[i] + '0');
    printf("%c", ch);
  }
}
int main() {
  int t = 1, cas = 0;
  while (t--) {
    SOLVE(++cas);
  }
  return 0;
}
template <class T1, class T2>
ostream &operator<<(ostream &os, pair<T1, T2> &p) {
  os << "{" << p.first << ", " << p.second << "} ";
  return os;
}
template <class T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "[ ";
  for (int i = 0; i < v.size(); i++) {
    os << v[i] << " ";
  }
  os << " ]";
  return os;
}
template <class T>
ostream &operator<<(ostream &os, set<T> &v) {
  os << "[ ";
  for (T i : v) {
    os << i << " ";
  }
  os << " ]";
  return os;
}
