#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
#pragma GCC option("arch=native", "tune=native", "no-zero-upper")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("Ofast")
using namespace std;
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
long long inf = 1e18, MOD = 998244353;
using cd = complex<double>;
const double PI = acos(-1);
struct point {
  double x, y;
};
point operator+(point a, point b) { return (point){a.x + b.x, a.y + b.y}; }
point operator-(point a, point b) { return (point){a.x - b.x, a.y - b.y}; }
point operator*(point a, point b) {
  return (point){a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x};
}
point operator/(point a, double x) { return (point){a.x / x, a.y / x}; }
const int maxb = 18;
const int N = (1 << maxb);
const int maxn = N + 20;
const double pi = acos(-1);
int r[maxn];
void init() {
  for (int i = 1; i < N; i++) r[i] = (r[i >> 1] >> 1) | ((i & 1) << (maxb - 1));
}
void mul(vector<point> &a, int mode) {
  for (int i = 0; i < N; i++)
    if (r[i] < i) swap(a[i], a[r[i]]);
  for (int len = 2; len <= N; len <<= 1) {
    point delta = (point){cos(2 * pi / len * mode), sin(2 * pi / len * mode)};
    for (int i = 0; i < N; i += len) {
      point now = (point){1, 0};
      for (int j = i, k = i + len / 2; k < i + len; j++, k++) {
        point tmp = a[j];
        point tnp = a[k] * now;
        a[j] = tmp + tnp;
        a[k] = tmp - tnp;
        now = now * delta;
      }
    }
  }
  if (mode == -1) {
    for (int i = 0; i < N; i++) a[i] = a[i] / N;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int ti = 1;
  while (ti--) {
    init();
    int n, m;
    string s, t;
    vector<int> per(26, 0), p(26, 0);
    for (int i = 0; i <= 25; i++) {
      cin >> p[i];
      p[i]--;
      per[p[i]] = i;
    }
    cin >> s >> t;
    n = t.length(), m = s.length();
    vector<vector<int>> xx(5, vector<int>(n)), yy(5, vector<int>(m));
    for (int i = 0; i < n; i++) {
      int val = t[i] - 'a';
      xx[0][i] = val * val * per[val] * per[val];
      xx[1][i] = -2 * val * per[val] * per[val] - 2 * val * val * per[val];
      xx[2][i] = val * val + per[val] * per[val] + 4 * val * per[val];
      xx[3][i] = -2 * val - 2 * per[val];
      xx[4][i] = 1;
    }
    for (int i = 0; i < m; i++) {
      int val = s[i] - 'a';
      yy[0][i] = 1;
      yy[1][i] = val;
      yy[2][i] = val * val;
      yy[3][i] = val * val * val;
      yy[4][i] = val * val * val * val;
    }
    vector<point> ans(N, (point){0, 0});
    for (int itr = 0; itr < 5; itr++) {
      reverse(yy[itr].begin(), yy[itr].end());
      vector<point> fa(N, point{0, 0}), fb(N, point{0, 0});
      for (int i = 0; i < n; i++) fa[i].x = xx[itr][i];
      for (int i = 0; i < m; i++) fb[i].x = yy[itr][i];
      mul(fa, 1);
      mul(fb, 1);
      for (int i = 0; i < N; i++) ans[i] = ans[i] + (fa[i] * fb[i]);
    }
    mul(ans, -1);
    string out = "";
    for (int i = m - 1; i < n; i++) {
      if (round(ans[i].x) == 0)
        out += '1';
      else
        out += '0';
    }
    cout << out << endl;
  }
  return 0;
}
