#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int pwr(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = (ans * 1LL * a) % mod;
    a = (a * 1LL * a) % mod;
    b >>= 1;
  }
  return ans;
}
struct base {
  double x, y;
  base() { x = y = 0; }
  base(double _x, double _y) { x = _x, y = _y; }
  base(double _x) { x = _x, y = 0; }
  void operator=(double _x) { x = _x, y = 0; }
  double real() { return x; }
  double imag() { return y; }
  base operator+(const base& b) { return base(x + b.x, y + b.y); }
  void operator+=(const base& b) { x += b.x, y += b.y; }
  base operator*(const base& b) {
    return base(x * b.x - y * b.y, x * b.y + y * b.x);
  }
  void operator*=(const base& b) {
    double p = x * b.x - y * b.y, q = x * b.y + y * b.x;
    x = p, y = q;
  }
  void operator/=(double k) { x /= k, y /= k; }
  base operator-(const base& b) { return base(x - b.x, y - b.y); }
  void operator-=(const base& b) { x -= b.x, y -= b.y; }
  base conj() { return base(x, -y); }
  base operator/(double k) { return base(x / k, y / k); }
  void Print() { cerr << x << " + " << y << "i\n"; }
};
double PI = 2.0 * acos(0.0);
const int MAXN = 19;
const int maxn = (1 << MAXN);
base W[maxn], invW[maxn], P1[maxn], Q1[maxn];
void precompute_powers() {
  for (int i = 0; i < maxn / 2; i++) {
    double ang = (2 * PI * i) / maxn;
    double _cos = cos(ang), _sin = sin(ang);
    W[i] = base(_cos, _sin);
    invW[i] = base(_cos, -_sin);
  }
}
void fft(vector<base>& a, bool invert) {
  int n = (int)a.size();
  for (int i = 1, j = 0; i < n; ++i) {
    int bit = n >> 1;
    for (; j >= bit; bit >>= 1) j -= bit;
    j += bit;
    if (i < j) swap(a[i], a[j]);
  }
  for (int len = 2; len <= n; len <<= 1) {
    for (int i = 0; i < n; i += len) {
      int ind = 0, add = maxn / len;
      for (int j = 0; j < len / 2; ++j) {
        base u = a[i + j],
             v = (a[i + j + len / 2] * (invert ? invW[ind] : W[ind]));
        a[i + j] = (u + v);
        a[i + j + len / 2] = (u - v);
        ind += add;
      }
    }
  }
  if (invert)
    for (int i = 0; i < n; ++i) a[i] /= n;
}
int p[30], ip[30];
vector<base> sp[26];
vector<base> temp;
const int N = 2e5 + 5;
char s[N], t[N];
int main() {
  precompute_powers();
  for (int i = 0; i < 26; i++) {
    scanf("%d", &p[i]);
    p[i]--;
    ip[p[i]] = i;
  }
  scanf("%s", s);
  scanf("%s", t);
  int n = strlen(s), m = strlen(t);
  int tot = n + m - 1;
  int sz = 1;
  while (sz < tot) sz <<= 1;
  for (int i = 0; i < 26; i++) {
    sp[i].reserve(sz);
    sp[i].resize(sz);
  }
  for (int i = 0; i < n; i++) {
    sp[s[i] - 'a'][n - 1 - i].x = 1;
  }
  for (int j = 0; j < m; j++) {
    sp[t[j] - 'a'][j].y = 1;
    sp[ip[t[j] - 'a']][j].y = 1;
  }
  vector<base> ans(sz);
  for (int i = 0; i < 26; i++) {
    fft(sp[i], 0);
    for (int j = 0; j < sz; j++) {
      base a = sp[i][j], b = sp[i][(sz - j) & (sz - 1)].conj();
      base p = (a + b) * base(0.5, 0), q = (a - b) * base(0, -0.5);
      ans[j] += p * q;
    }
  }
  fft(ans, 1);
  const double EPS = 1e-3;
  for (int i = n - 1; i <= m - 1; i++) {
    if (fabs(ans[i].x - n) < EPS) {
      putchar('1');
    } else {
      putchar('0');
    }
  }
  return 0;
}
