#include <bits/stdc++.h>
using namespace std;
const long long mod = (119 << 23) + 1, root = 62;
long long modpow(long long b, long long e) {
  long long ans = 1;
  for (; e; b = b * b % mod, e /= 2)
    if (e & 1) ans = ans * b % mod;
  return ans;
}
void ntt(vector<long long> &a) {
  int n = int(a.size()), L = 31 - __builtin_clz(n);
  static vector<long long> rt(2, 1);
  for (static int k = 2, s = 2; k < n; k *= 2, s++) {
    rt.resize(n);
    long long z[] = {1, modpow(root, mod >> s)};
    for (int i = (k); i < (2 * k); ++i) rt[i] = rt[i / 2] * z[i & 1] % mod;
  }
  vector<int> rev(n);
  for (int i = (0); i < (n); ++i) rev[i] = (rev[i / 2] | (i & 1) << L) / 2;
  for (int i = (0); i < (n); ++i)
    if (i < rev[i]) swap(a[i], a[rev[i]]);
  for (int k = 1; k < n; k *= 2)
    for (int i = 0; i < n; i += 2 * k)
      for (int j = (0); j < (k); ++j) {
        long long z = rt[j + k] * a[i + j + k] % mod, &ai = a[i + j];
        a[i + j + k] = ai - z + (z > ai ? mod : 0);
        ai += (ai + z >= mod ? z - mod : z);
      }
}
vector<long long> conv(const vector<long long> &a, const vector<long long> &b) {
  if (a.empty() || b.empty()) return {};
  int s = int(a.size()) + int(b.size()) - 1, B = 32 - __builtin_clz(s),
      n = 1 << B;
  int inv = modpow(n, mod - 2);
  vector<long long> L(a), R(b), out(n);
  L.resize(n), R.resize(n);
  ntt(L), ntt(R);
  for (int i = (0); i < (n); ++i)
    out[-i & (n - 1)] = (long long)L[i] * R[i] % mod * inv % mod;
  ntt(out);
  return {out.begin(), out.begin() + s};
}
char s[200001], t[200001];
int p[26];
long long val[26];
int main() {
  for (int i = (0); i < (26); ++i) val[i] = rand();
  for (int i = (0); i < (26); ++i) {
    scanf("%d", p + i);
    --p[i];
  }
  scanf("%s %s", s, t);
  int ss = (int)strlen(s), tt = (int)strlen(t);
  vector<long long> a(ss), b(tt);
  for (int i = (0); i < (ss); ++i) a[i] = val[s[i] - 'a'] + val[p[s[i] - 'a']];
  for (int i = (0); i < (tt); ++i) b[i] = val[t[i] - 'a'];
  reverse(a.begin(), a.end());
  long long goal = 0;
  for (int i = (0); i < (ss); ++i)
    goal = (goal + val[s[i] - 'a'] * val[p[s[i] - 'a']]) % mod;
  vector<long long> pre(tt + 1);
  for (int i = (0); i < (tt); ++i)
    pre[i + 1] = (pre[i] + val[t[i] - 'a'] * val[t[i] - 'a']) % mod;
  vector<long long> c = conv(a, b);
  for (int i = (0); i < (tt - ss + 1); ++i)
    if ((c[i + ss - 1] - pre[i + ss] + pre[i] - goal) % mod == 0)
      putchar('1');
    else
      putchar('0');
  puts("");
}
