#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;
const int maxn = 2e5 + 5;
int n, p[maxn];
string s, t;
bitset<maxn> res, arr[30];
void readf() {
  for (int i = 0; i < 26; ++i) cin >> p[i], --p[i];
  cin >> s >> t;
}
void solve() {
  for (int i = 0; i < t.size(); ++i) arr[t[i] - 'a'][i] = 1;
  res.set();
  for (int i = 0; i < s.size(); ++i)
    res &= (arr[s[i] - 'a'] | arr[p[s[i] - 'a']]) >> i;
  for (int i = 0; i < t.size() - s.size() + 1; ++i) cout << res[i];
}
int main() {
  srand(time(NULL));
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  readf();
  solve();
}
