#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops", "omit-frame-pointer", "inline")
#pragma GCC option("arch=native", "tune=native", "no-zero-upper")
#pragma GCC target("avx2")
using namespace std;
const int mod = 998244353;
int n, m, p[26];
bitset<200005> T[26], mat[26], ans;
char s[200005], t[200005];
int main() {
  for (int i = 0; i < 26; i++) scanf("%d", &p[i]), --p[i];
  scanf("%s%s", s, t), n = strlen(t), m = strlen(s);
  for (int i = 0; i < n; i++) T[t[i] - 'a'][i] = 1;
  for (int i = 0; i < 26; i++) mat[i] = T[i] | T[p[i]];
  for (int i = 0; i < n - m + 1; i++) ans[i] = 1;
  for (int i = 0; i < m; i++) ans &= mat[s[i] - 'a'] >> i;
  for (int i = 0; i < n - m + 1; i++) printf("%d", ans[i] ? 1 : 0);
}
