#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("-ffloat-store")
using namespace std;
clock_t time_p = clock();
void aryanc403() {}
const long long int INF = 0xFFFFFFFFFFFFFFFL;
long long int seed;
mt19937 rng(seed = chrono::steady_clock::now().time_since_epoch().count());
inline long long int rnd(long long int l = 0, long long int r = INF) {
  return uniform_int_distribution<long long int>(l, r)(rng);
}
class CMP {
 public:
  bool operator()(pair<long long int, long long int> a,
                  pair<long long int, long long int> b) {
    return !(a.first < b.first || (a.first == b.first && a.second <= b.second));
  }
};
void add(map<long long int, long long int> &m, long long int x,
         long long int cnt = 1) {
  auto jt = m.find(x);
  if (jt == m.end())
    m.insert({x, cnt});
  else
    jt->second += cnt;
}
void del(map<long long int, long long int> &m, long long int x,
         long long int cnt = 1) {
  auto jt = m.find(x);
  if (jt->second <= cnt)
    m.erase(jt);
  else
    jt->second -= cnt;
}
bool cmp(const pair<long long int, long long int> &a,
         const pair<long long int, long long int> &b) {
  return a.first < b.first || (a.first == b.first && a.second < b.second);
}
const long long int mod = 1500000767;
const long long int B = 107L;
const long long int Binv = 981308913;
vector<long long int> pw;
long long int po(long long int a, long long int n) {
  if (n == 0) return 1;
  if (n % 2) return (a * po(a, n - 1)) % mod;
  return po(a * a % mod, n / 2);
}
struct node {
  long long int fs, ls;
  long long int h, len;
  node() : h(0), fs(0), ls(0), len(0){};
  node(char x) {
    h = fs = ls = x;
    len = 1;
  }
  void rmf() {
    assert(len > 0);
    assert(fs == '1');
    fs = 0;
    len--;
    h -= '1' * pw[len];
    h = (h % mod + mod) % mod;
  }
  void rml() {
    assert(len > 0);
    assert(ls == '1');
    h -= '1';
    h = (h * Binv) % mod;
    h = (h + mod) % mod;
    ls = 0;
    len--;
  }
};
node merge(node a, node b) {
  if (a.len == 0) return b;
  if (b.len == 0) return a;
  node ans;
  if (a.ls == '1' && b.fs == '1') {
    a.rml();
    b.rmf();
  }
  if (a.len == 0) return b;
  if (b.len == 0) return a;
  ans.h = (a.h * po(B, b.len) % mod + b.h) % mod;
  ans.h = (ans.h + mod) % mod;
  ans.len = a.len + b.len;
  ans.fs = a.fs;
  ans.ls = b.ls;
  return ans;
}
long long int T, n, i, j, k, in, cnt, l, r, u, v, x, y;
long long int m;
string s, te, to;
vector<long long int> a;
vector<node> f;
void build(long long int id, long long int l, long long int r) {
  if (l == r) {
    f[id] = node(s[l]);
    return;
  }
  long long int m = (l + r) / 2;
  build(2 * id, l, m);
  build(2 * id + 1, m + 1, r);
  f[id] = merge(f[2 * id], f[2 * id + 1]);
}
node query(long long int id, long long int l, long long int r, long long int L,
           long long int R) {
  if (r < L || R < l) return node();
  if (L <= l && r <= R) return f[id];
  long long int m = (l + r) / 2;
  return merge(query(2 * id, l, m, L, R), query(2 * id + 1, m + 1, r, L, R));
}
long long int gt(long long int l, long long int r) {
  long long int h = query(1, 0, n + 1, l, r).h;
  h = (h % mod + mod) % mod;
  return h;
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  {
    cin >> n;
    pw.push_back(1);
    for (i = (1); i <= (n + 10); ++i) pw.push_back(pw.back() * B % mod);
    a.resize(n + 1, -1);
    cin >> s;
    s = "#" + s + "#";
    f.resize(4 * n + 10);
    build(1, 0, n + 1);
    long long int q;
    cin >> q;
    while (q--) {
      long long int l1, l2, len;
      cin >> l1 >> l2 >> len;
      cout << (gt(l1, l1 + len - 1) == gt(l2, l2 + len - 1) ? "YES" : "NO")
           << "\n";
    }
  }
  aryanc403();
  return 0;
}
