#include <bits/stdc++.h>
using namespace std;
int A = 2;
const int B = 2e9 + 11;
struct _data {
  long long hash;
  long long ultimo;
  long long primero;
  long long size;
};
const int MAXN = 2e5 + 5;
int pot[MAXN];
int inv;
int modpow(long long a, long long p) {
  if (p == 0) return 1;
  if (p % 2) return (modpow(a, p - 1) * a) % B;
  return modpow((a * a) % B, p / 2);
}
int _hash(long long a) { return (a * A) % B; }
_data merge(_data a, _data b) {
  if (a.size == 0) return b;
  if (b.size == 0) return a;
  _data ans;
  ans.primero = a.primero;
  ans.ultimo = b.ultimo;
  if (a.ultimo == b.primero && a.ultimo == 1) {
    a.hash = (a.hash - pot[a.size]) % B;
    b.hash = (b.hash * inv - 1) % B;
    a.size--;
    b.size--;
    if (a.size == 1) ans.primero = 0;
    if (b.size == 1) ans.ultimo = 0;
  }
  ans.hash = (a.hash + (b.hash * pot[a.size]) % B) % B;
  ans.size = a.size + b.size;
  return ans;
}
struct st {
  int size;
  vector<_data> nodos;
  st(int n, int numeros[]) {
    int copia = n;
    size = 1;
    while (copia > 1) size <<= 1, copia >>= 1;
    if (size < n) {
      size <<= 1;
    }
    nodos.resize(2 * size);
    for (int i = (0); i < (2 * size); i++) nodos[i] = {0, 0, 0, 0};
    for (int i = (0); i < (n); i++) {
      nodos[size + i] = {_hash(numeros[i]), numeros[i], numeros[i], 1};
    }
    for (int j = size - 1; j > 0; j--) {
      nodos[j] = merge(nodos[j << 1], nodos[j << 1 | 1]);
    }
  }
  _data query(int a, int b, int nodo = 1, int l = 0, int r = 0) {
    if (nodo == 1) {
      r = size - 1;
    }
    if (b < l || a > r) {
      return {0, 0, 0, 0};
    }
    if (l >= a && r <= b) {
      return nodos[nodo];
    }
    int m = l + r >> 1;
    _data left = query(a, b, nodo << 1, l, m);
    _data right = query(a, b, nodo << 1 | 1, m + 1, r);
    return merge(left, right);
  }
};
int main() {
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  A = rng() % B;
  int n, q;
  cin >> n;
  int numeros[n];
  for (int i = (0); i < (n); i++) {
    char in;
    cin >> in;
    numeros[i] = in - '0';
  }
  long long p = 1;
  for (int i = (0); i < (MAXN); i++) {
    pot[i] = p;
    p = (p * A) % B;
  }
  inv = modpow(A, B - 2);
  st tree(n, numeros);
  cin >> q;
  for (int i = (0); i < (q); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    auto rango1 = tree.query(a, a + c - 1);
    auto rango2 = tree.query(b, b + c - 1);
    if (rango1.hash == rango2.hash && rango1.size == rango2.size) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}
