#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, vector<long long>& rt, vector<long long>& rev,
         int n) {
  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] = (z > ai ? ai - z + mod : ai - z);
        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;
  vector<long long> L(a), R(b), out(n), rt(n, 1), rev(n);
  L.resize(n), R.resize(n);
  for (int i = 0; i < (n); ++i) rev[i] = (rev[i / 2] | (i & 1) << B) / 2;
  long long curL = mod / 2, inv = modpow(n, mod - 2);
  for (int k = 2; k < n; k *= 2) {
    long long z[] = {1, modpow(root, curL /= 2)};
    for (int i = k; i < (2 * k); ++i) rt[i] = rt[i / 2] * z[i & 1] % mod;
  }
  ntt(L, rt, rev, n);
  ntt(R, rt, rev, n);
  for (int i = 0; i < (n); ++i)
    out[-i & (n - 1)] = L[i] * R[i] % mod * inv % mod;
  ntt(out, rt, rev, n);
  return {out.begin(), out.begin() + s};
}
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<> uid(0, mod - 1);
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin.exceptions(cin.failbit);
  vector<int> p(26);
  for (auto& x : p) {
    cin >> x;
    --x;
  }
  string s, t;
  cin >> s >> t;
  reverse(begin(s), end(s));
  vector<vector<long long> > qs(3, vector<long long>((int)(s).size())),
      qt(3, vector<long long>((int)(t).size()));
  for (int i = 0; i < ((int)(s).size()); ++i) {
    long long x = s[i] - 'a', y = p[s[i] - 'a'], c = uid(rng);
    c = 1;
    qs[0][i] = x * y * c % mod;
    qs[1][i] = (mod - (x + y)) * c % mod;
    qs[2][i] = c % mod;
  }
  for (int i = 0; i < ((int)(t).size()); ++i) {
    long long z = t[i] - 'a', c = uid(rng);
    qt[0][i] = c % mod;
    qt[1][i] = c * z % mod;
    qt[2][i] = c * z * z % mod;
  }
  vector<long long> ans((int)(t).size() + (int)(s).size());
  for (int j = 0; j < (3); ++j) {
    auto r = conv(qs[j], qt[j]);
    for (int i = 0; i < (min((int)(ans).size(), (int)(r).size())); ++i)
      ans[i] = (ans[i] + r[i] + mod) % mod;
  }
  for (int i = (int)(s).size() - 1; i < ((int)(t).size()); ++i)
    cout << (ans[i] == 0);
  cout << endl;
}
