#include <bits/stdc++.h>
using namespace std;
template <typename T>
void __read(T &a) {
  cin >> a;
}
template <typename T, typename... Args>
void __read(T &a, Args &...args) {
  cin >> a;
  __read(args...);
}
constexpr long long M7 = 1000000007ll;
constexpr long long M9 = 1000000009ll;
constexpr long long MFFT = 998244353ll;
template <class T>
void outv(T &a) {
  for (auto &x : a) cout << x << ' ';
}
static mt19937 rnd(static_cast<unsigned>(
    chrono::steady_clock::now().time_since_epoch().count()));
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr));
void fft(vector<complex<long double> > &a, bool invert = false) {
  long long n = a.size();
  vector<long long> inv(n);
  for (long long i = 1; i < n; ++i) {
    if (i & 1) {
      inv[i] = inv[i - 1] + n / 2;
    } else {
      inv[i] = inv[i >> 1] >> 1;
    }
    if (inv[i] < i) {
      swap(a[inv[i]], a[i]);
    }
  }
  for (long long len = 1; len < n; len *= 2) {
    long double alpha = M_PI / len;
    if (invert) {
      alpha *= -1;
    }
    complex<long double> wlen(cos(alpha), sin(alpha));
    for (long long i = 0; i < n; i += 2 * len) {
      complex<long double> w(1);
      for (long long j = 0; j < len; ++j) {
        auto v = a[i + j];
        auto u = a[i + j + len] * w;
        a[i + j] = v + u;
        a[i + j + len] = v - u;
        w *= wlen;
      }
    }
  }
  if (invert) {
    for (long long i = 0; i < n; ++i) {
      a[i] /= n;
    }
  }
}
int32_t main() {
  vector<long long> p(26);
  for (auto &v : p) {
    cin >> v;
    v--;
  }
  string t, s;
  __read(t, s);
  vector<long long> id(p.size()), ind(p.size(), -1), sz;
  long long lst = 0;
  for (long long i = 0; i < p.size(); ++i) {
    if (ind[i] == -1) {
      ind[i] = 0;
      id[i] = lst++;
      while (ind[p[i]] == -1) {
        ind[p[i]] = ind[i] + 1;
        id[p[i]] = id[i];
        i = p[i];
      }
      sz.push_back(ind[i] + 1);
      i = p[i];
    }
  }
  vector<long long> ans(s.length() - t.length() + 1);
  {
    vector<long long> q;
    for (long long i = 0; i < t.length(); ++i) {
      q.push_back(id[t[i] - 'a']);
    }
    q.push_back(-1);
    for (long long i = 0; i < s.length(); ++i) {
      q.push_back(id[s[i] - 'a']);
    }
    vector<long long> pr(q.size());
    for (long long i = 1; i < q.size(); ++i) {
      pr[i] = pr[i - 1];
      while (pr[i] > 0 && q[i] != q[pr[i]]) {
        pr[i] = pr[pr[i] - 1];
      }
      if (q[i] == q[pr[i]]) {
        pr[i]++;
      }
    }
    for (long long i = 0; i < ans.size(); ++i) {
      if (pr[i + 2 * t.length()] == t.length()) {
        ans[i] = 1;
      }
    }
  }
  long long nn = 1;
  while (nn < s.length()) {
    nn *= 2;
  }
  nn *= 2;
  vector<complex<long double> > a(nn), b(nn);
  reverse((t).begin(), (t).end());
  for (long long i = 0; i < s.length(); ++i) {
    long long c = s[i] - 'a';
    long double alpha = (M_PI - 2 * M_PI * ind[c]) / sz[id[c]];
    a[i] = complex<long double>(cos(alpha), sin(alpha));
  }
  long double res = 0;
  for (long long i = 0; i < t.length(); ++i) {
    long long c = t[i] - 'a';
    long double alpha = (2 * M_PI * ind[c]) / sz[id[c]];
    b[i] = complex<long double>(cos(alpha), sin(alpha));
    res += cos(M_PI / sz[id[c]]);
  }
  fft(a);
  fft(b);
  for (long long i = 0; i < a.size(); ++i) {
    a[i] *= b[i];
  }
  fft(a, true);
  for (long long i = 0; i < ans.size(); ++i) {
    long double q = a[i + t.length() - 1].real();
    if (abs(q - res) >= 1e-6) {
      ans[i] = 0;
    }
  }
  for (long long i = 0; i < ans.size(); ++i) {
    cout << ans[i];
  }
  return 0;
}
