#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const long long inff = 0x3f3f3f3f3f3f3f3f;
using namespace std;
const int N = 2e5 + 8;
int n, m, p[28], e[N], f[N], ss[N];
string s, t;
struct CP {
  double x, y;
  CP() {}
  CP(double a, double b) : x(a), y(b) {}
  CP operator+(const CP& r) const { return CP(x + r.x, y + r.y); }
  CP operator-(const CP& r) const { return CP(x - r.x, y - r.y); }
  CP operator*(const CP& r) const {
    return CP(x * r.x - y * r.y, x * r.y + y * r.x);
  }
} a[2000008], b[2000008], ans[2000008], tt;
inline void Swap(CP& a, CP& b) {
  tt = a;
  a = b;
  b = tt;
}
inline void fft(CP* a, int f) {
  int i, j, k;
  for (i = j = 0; i < n; i++) {
    if (i > j) Swap(a[i], a[j]);
    for (k = n >> 1; (j ^= k) < k; k >>= 1)
      ;
  }
  for (int i = 1; i < n; i <<= 1) {
    CP wn(cos(acos(-1) / i), f * sin(acos(-1) / i));
    for (int j = 0; j < n; j += i << 1) {
      CP w(1, 0);
      for (int k = 0; k < i; k++, w = w * wn) {
        CP x = a[j + k], y = w * a[i + j + k];
        a[j + k] = x + y;
        a[i + j + k] = x - y;
      }
    }
  }
  if (f == -1)
    for (int i(0); i <= (n); ++i) a[i].x /= n;
}
int main() {
  cin.tie(0);
  cout.tie(0);
  for (int i(0); i <= (25); ++i) scanf("%d", &p[i]), p[i]--;
  cin >> s >> t;
  n = t.size(), m = s.size();
  int qw = n, zz = m, k = 0;
  reverse(s.begin(), s.end());
  for (int i(0); i <= (m - 1); ++i) e[i] = s[i] - 'a';
  for (int i(0); i <= (n - 1); ++i) f[i] = t[i] - 'a';
  for (m = n + m, n = 1; n <= m; n <<= 1)
    ;
  for (int i(0); i <= (qw - 1); ++i) a[i] = CP(f[i] * f[i] * f[i], 0);
  for (int i(0); i <= (zz - 1); ++i) b[i] = CP(p[e[i]], 0);
  fft(a, 1), fft(b, 1);
  for (int i(0); i <= (n - 1); ++i) ans[i] = ans[i] - CP(2, 0) * a[i] * b[i];
  for (int i(0); i <= (n - 1); ++i) a[i] = b[i] = CP(0, 0);
  for (int i(0); i <= (qw - 1); ++i) a[i] = CP(f[i] * f[i], 0);
  for (int i(0); i <= (zz - 1); ++i) b[i] = CP(p[e[i]] * p[e[i]], 0);
  fft(a, 1), fft(b, 1);
  for (int i(0); i <= (n - 1); ++i) ans[i] = ans[i] + a[i] * b[i];
  for (int i(0); i <= (n - 1); ++i) a[i] = b[i] = CP(0, 0);
  for (int i(0); i <= (qw - 1); ++i) a[i] = CP(f[i] * f[i] * f[i], 0);
  for (int i(0); i <= (zz - 1); ++i) b[i] = CP(e[i], 0);
  fft(a, 1), fft(b, 1);
  for (int i(0); i <= (n - 1); ++i) ans[i] = ans[i] - CP(2, 0) * a[i] * b[i];
  for (int i(0); i <= (n - 1); ++i) a[i] = b[i] = CP(0, 0);
  for (int i(0); i <= (qw - 1); ++i) a[i] = CP(f[i] * f[i], 0);
  for (int i(0); i <= (zz - 1); ++i) b[i] = CP(e[i] * p[e[i]], 0);
  fft(a, 1), fft(b, 1);
  for (int i(0); i <= (n - 1); ++i) ans[i] = ans[i] + CP(4, 0) * a[i] * b[i];
  for (int i(0); i <= (n - 1); ++i) a[i] = b[i] = CP(0, 0);
  for (int i(0); i <= (qw - 1); ++i) a[i] = CP(f[i], 0);
  for (int i(0); i <= (zz - 1); ++i) b[i] = CP(e[i] * p[e[i]] * p[e[i]], 0);
  fft(a, 1), fft(b, 1);
  for (int i(0); i <= (n - 1); ++i) ans[i] = ans[i] - CP(2, 0) * a[i] * b[i];
  for (int i(0); i <= (n - 1); ++i) a[i] = b[i] = CP(0, 0);
  for (int i(0); i <= (zz - 1); ++i) a[i] = CP(e[i] * e[i], 0);
  for (int i(0); i <= (qw - 1); ++i) b[i] = CP(f[i] * f[i], 0);
  fft(a, 1), fft(b, 1);
  for (int i(0); i <= (n - 1); ++i) ans[i] = ans[i] + a[i] * b[i];
  for (int i(0); i <= (n - 1); ++i) a[i] = b[i] = CP(0, 0);
  for (int i(0); i <= (qw - 1); ++i) a[i] = CP(f[i], 0);
  for (int i(0); i <= (zz - 1); ++i) b[i] = CP(e[i] * e[i] * p[e[i]], 0);
  fft(a, 1), fft(b, 1);
  for (int i(0); i <= (n - 1); ++i) ans[i] = ans[i] - CP(2, 0) * a[i] * b[i];
  for (int i(0); i <= (n - 1); ++i) a[i] = b[i] = CP(0, 0);
  for (int i(0); i <= (qw - 1); ++i) a[i] = CP(f[i] * f[i] * f[i] * f[i], 0);
  for (int i(0); i <= (zz - 1); ++i) b[i] = CP(1, 0);
  fft(a, 1), fft(b, 1);
  for (int i(0); i <= (n - 1); ++i) ans[i] = ans[i] + a[i] * b[i];
  for (int i(0); i <= (n - 1); ++i) a[i] = b[i] = CP(0, 0);
  for (int i(0); i <= (zz - 1); ++i)
    a[i] = CP(e[i] * e[i] * p[e[i]] * p[e[i]], 0);
  for (int i(0); i <= (qw - 1); ++i) b[i] = CP(1, 0);
  fft(a, 1), fft(b, 1);
  for (int i(0); i <= (n - 1); ++i) ans[i] = ans[i] + a[i] * b[i];
  fft(ans, -1);
  for (int i = zz - 1; i < qw; i++)
    if (fabs(ans[i].x) <= 0.1) ss[i - zz + 2] = 1;
  for (int i(1); i <= (qw - zz + 1); ++i) printf("%d", ss[i]);
  puts("");
  return 0;
}
