#include <bits/stdc++.h>
using namespace std;
const int LOGN = 20;
const int N = (1 << LOGN);
const long double PI = acos(-1.0);
struct comp {
  long double x, y;
  comp(long double x = .0, long double y = .0) : x(x), y(y) {}
  inline comp conj() { return comp(x, -y); }
};
inline comp operator+(const comp &a, const comp &b) {
  return comp(a.x + b.x, a.y + b.y);
}
inline comp operator-(const comp &a, const comp &b) {
  return comp(a.x - b.x, a.y - b.y);
}
inline comp operator*(const comp &a, const comp &b) {
  return comp(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x);
}
inline comp operator/(const comp &a, const long double &b) {
  return comp(a.x / b, a.y / b);
}
vector<comp> w[LOGN];
vector<int> rv[LOGN];
void precalc() {
  for (int st = 0; st < LOGN; st++) {
    w[st].assign(1 << st, comp());
    for (int k = 0; k < (1 << st); k++) {
      double ang = PI / (1 << st) * k;
      w[st][k] = comp(cos(ang), sin(ang));
    }
    rv[st].assign(1 << st, 0);
    if (st == 0) {
      rv[st][0] = 0;
      continue;
    }
    int h = (1 << (st - 1));
    for (int k = 0; k < (1 << st); k++)
      rv[st][k] = (rv[st - 1][k & (h - 1)] << 1) | (k >= h);
  }
}
inline void fft(comp a[N], int n, int ln, bool inv) {
  for (int i = 0; i < n; i++) {
    int ni = rv[ln][i];
    if (i < ni) swap(a[i], a[ni]);
  }
  for (int st = 0; (1 << st) < n; st++) {
    int len = (1 << st);
    for (int k = 0; k < n; k += (len << 1)) {
      for (int pos = k; pos < k + len; pos++) {
        comp l = a[pos];
        comp r = a[pos + len] * (inv ? w[st][pos - k].conj() : w[st][pos - k]);
        a[pos] = l + r;
        a[pos + len] = l - r;
      }
    }
  }
  if (inv)
    for (int i = 0; i < n; i++) a[i] = a[i] / n;
}
comp aa[N];
comp bb[N];
comp cc[N];
inline void multiply(comp a[N], int sza, comp b[N], int szb, comp c[N],
                     int &szc) {
  int n = 1, ln = 0;
  while (n < (sza + szb)) n <<= 1, ln++;
  for (int i = 0; i < n; i++) aa[i] = (i < sza ? a[i] : comp());
  for (int i = 0; i < n; i++) bb[i] = (i < szb ? b[i] : comp());
  fft(aa, n, ln, false);
  fft(bb, n, ln, false);
  for (int i = 0; i < n; i++) cc[i] = aa[i] * bb[i];
  fft(cc, n, ln, true);
  szc = n;
  for (int i = 0; i < n; i++) c[i] = cc[i];
}
comp a[N];
comp b[N];
comp c[N];
vector<int> p_function(const vector<int> &v) {
  int n = v.size();
  vector<int> p(n);
  for (int i = 1; i < n; i++) {
    int j = p[i - 1];
    while (j > 0 && v[j] != v[i]) j = p[j - 1];
    if (v[j] == v[i]) j++;
    p[i] = j;
  }
  return p;
}
int p[26];
char buf[N];
string s, t;
int main() {
  precalc();
  for (int i = 0; i < 26; i++) {
    scanf("%d", &p[i]);
    p[i]--;
  }
  scanf("%s", buf);
  s = buf;
  scanf("%s", buf);
  t = buf;
  int n = s.size();
  int m = t.size();
  vector<int> color(26, 0);
  vector<vector<int> > cycles;
  for (int i = 0; i < 26; i++) {
    if (color[i]) continue;
    vector<int> cycle;
    int cc = cycles.size() + 1;
    int cur = i;
    while (color[cur] == 0) {
      cycle.push_back(cur);
      color[cur] = cc;
      cur = p[cur];
    }
    cycles.push_back(cycle);
  }
  vector<int> ans(m - n + 1);
  vector<int> s1, t1;
  for (int i = 0; i < n; i++) s1.push_back(color[int(s[i] - 'a')]);
  for (int i = 0; i < m; i++) t1.push_back(color[int(t[i] - 'a')]);
  vector<int> st = s1;
  st.push_back(0);
  for (auto x : t1) st.push_back(x);
  vector<int> pf = p_function(st);
  for (int i = 0; i < m - n + 1; i++)
    if (pf[2 * n + i] == n) ans[i] = 1;
  map<char, comp> m1, m2;
  for (auto cur : cycles) {
    int k = cur.size();
    for (int i = 0; i < k; i++) {
      long double ang1 = 2 * PI * i / k;
      long double ang2 = (PI - 2 * PI * i) / k;
      m1[char('a' + cur[i])] = comp(cosl(ang1), sinl(ang1));
      m2[char('a' + cur[i])] = comp(cosl(ang2), sinl(ang2));
    }
  }
  long double ideal = 0;
  for (int i = 0; i < n; i++) ideal += (m1[s[i]] * m2[s[i]]).x;
  reverse(s.begin(), s.end());
  for (int i = 0; i < n; i++) a[i] = m1[s[i]];
  for (int i = 0; i < m; i++) b[i] = m2[t[i]];
  int szc;
  multiply(a, n, b, m, c, szc);
  for (int i = 0; i < m - n + 1; i++)
    if (fabsl(c[i + n - 1].x - ideal) > 0.01) ans[i] = 0;
  for (int i = 0; i < m - n + 1; i++) printf("%d", ans[i]);
  return 0;
}
