Problem: In this problem, we will deal with binary strings. Each character of a binary string is either a 0 or a 1. We will also deal with substrings; recall that a substring is a contiguous subsequence of a string. We denote the substring of string s starting from the l-th character and ending with the r-th character as s[l ... r]. The characters of each string are numbered from 1.

We can perform several operations on the strings we consider. Each operation is to choose a substring of our string and replace it with another string. There are two possible types of operations: replace 011 with 110, or replace 110 with 011. For example, if we apply exactly one operation to the string 110011110, it can be transformed into 011011110, 110110110, or 110011011.

Binary string a is considered reachable from binary string b if there exists a sequence s_1, s_2, ..., s_k such that s_1 = a, s_k = b, and for every i ∈ [1, k - 1], s_i can be transformed into s_{i + 1} using exactly one operation. Note that k can be equal to 1, i. e., every string is reachable from itself.

You are given a string t and q queries to it. Each query consists of three integers l_1, l_2 and len. To answer each query, you have to determine whether t[l_1 ... l_1 + len - 1] is reachable from t[l_2 ... l_2 + len - 1].

Input

The first line contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the length of string t.

The second line contains one string t (|t| = n). Each character of t is either 0 or 1.

The third line contains one integer q (1 ≤ q ≤ 2 ⋅ 10^5) — the number of queries.

Then q lines follow, each line represents a query. The i-th line contains three integers l_1, l_2 and len (1 ≤ l_1, l_2 ≤ |t|, 1 ≤ len ≤ |t| - max(l_1, l_2) + 1) for the i-th query.

Output

For each query, print either YES if t[l_1 ... l_1 + len - 1] is reachable from t[l_2 ... l_2 + len - 1], or NO otherwise. You may print each letter in any register.

Example

Input


5
11011
3
1 3 3
1 4 2
1 2 3


Output


Yes
Yes
No

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
using namespace std;
long long mod1 = 1000000009;
long long mod2 = 1000000007;
int prime = 101;
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long inv1 = power(prime, mod1 - 2, mod1);
long long inv2 = power(prime, mod2 - 2, mod2);
pair<long long, long long> doubleHash(const string &str) {
  long long p1 = prime;
  long long p2 = prime;
  pair<long long, long long> p = make_pair(str[0], str[0]);
  for (int i = 1; i < str.length(); i++) {
    p.first = (p.first + p1 * str[i]) % mod1;
    p.second = (p.second + p2 * str[i]) % mod2;
    p1 = (p1 * prime) % mod1;
    p2 = (p2 * prime) % mod2;
  }
  return p;
}
vector<long long> getHashPrefix(const string &str) {
  long long p1 = prime;
  vector<long long> ret(str.length());
  ret[0] = str[0];
  for (int i = 1; i < str.length(); i++) {
    ret[i] = (ret[i - 1] + p1 * str[i]) % mod1;
    p1 = (p1 * prime) % mod1;
  }
  return ret;
}
pair<vector<long long>, vector<long long>> doubleHashPrefix(const string &str) {
  long long p1 = prime;
  long long p2 = prime;
  pair<vector<long long>, vector<long long>> p = make_pair(
      vector<long long>(str.length()), vector<long long>(str.length()));
  p.first[0] = str[0];
  p.second[0] = str[0];
  for (int i = 1; i < str.length(); i++) {
    p.first[i] = (p.first[i - 1] + p1 * str[i]) % mod1;
    p.second[i] = (p.second[i - 1] + p2 * str[i]) % mod2;
    p1 = (p1 * prime) % mod1;
    p2 = (p2 * prime) % mod2;
  }
  return p;
}
pair<long long, long long> substringHash(
    pair<vector<long long>, vector<long long>> preHash, int i, int j,
    const vector<long long> &invpwr1, const vector<long long> &invpwr2) {
  return make_pair(
      ((preHash.first[j] - preHash.first[i] + mod1) * invpwr1[i]) % mod1,
      ((preHash.second[j] - preHash.second[i] + mod2) * invpwr2[i]) % mod2);
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  string str;
  cin >> str;
  vector<int> lasts(n, -1);
  vector<long long> invpwr1(str.length(), 0);
  vector<long long> invpwr2(str.length(), 0);
  vector<pair<long long, long long>> hashes(n);
  vector<bool> diff(n, true);
  hashes[0].first = str[0];
  vector<long long> p1(str.length());
  vector<long long> p2(str.length());
  invpwr1[0] = 1;
  invpwr2[0] = 1;
  p1[0] = 1;
  p2[0] = 1;
  if (str[n - 1] == '1') {
    lasts[n - 1] = n - 1;
  }
  for (int i = n - 2; i >= 0; i--) {
    if (str[i] == '1') {
      if (lasts[i + 1] != -1) {
        lasts[i] = lasts[i + 1];
      } else {
        lasts[i] = i;
      }
    }
  }
  for (int i = 1; i < str.length(); i++) {
    invpwr1[i] = (invpwr1[i - 1] * inv1) % mod1;
    invpwr2[i] = (invpwr2[i - 1] * inv2) % mod2;
    p1[i] = (p1[i - 1] * prime) % mod1;
    p2[i] = (p2[i - 1] * prime) % mod2;
  }
  hashes[0].second = str[0];
  vector<int> ones(n + 1);
  vector<int> counts(n, 0);
  ones[0] = 0;
  counts[0] = 1;
  if (str[0] == '0') {
    diff[0] = false;
    ones[1] = 0;
  } else {
    ones[1] = 1;
  }
  for (int i = 1; i < n; i++) {
    if (diff[i - 1]) {
      if (str[i] == '1') {
        ones[i + 1] = ones[i] + 1;
        diff[i] = false;
        if (i == 1) {
          hashes[i].first = 0;
          hashes[i].second = 0;
          counts[i] = 0;
        } else {
          counts[i] = counts[i - 2];
          hashes[i].first = (hashes[i - 2].first);
          hashes[i].second = hashes[i - 2].second;
        }
        continue;
      } else {
        counts[i] = counts[i - 1] + 1;
        ones[i + 1] = ones[i];
        diff[i - 1] = false;
        diff[i] = false;
        hashes[i].first =
            (hashes[i - 1].first + p1[counts[i] - 1] * str[i] % mod1) % mod1;
        hashes[i].second =
            (hashes[i - 1].second + p2[counts[i] - 1] * str[i] % mod2) % mod2;
      }
    } else {
      counts[i] = counts[i - 1] + 1;
      if (str[i] == '1') {
        ones[i + 1] = ones[i] + 1;
        hashes[i].first =
            (hashes[i - 1].first + p1[counts[i] - 1] * str[i] % mod1) % mod1;
        hashes[i].second =
            (hashes[i - 1].second + p2[counts[i] - 1] * str[i] % mod2) % mod2;
      } else {
        ones[i + 1] = ones[i];
        diff[i] = false;
        hashes[i].first =
            (hashes[i - 1].first + p1[counts[i] - 1] * str[i] % mod1) % mod1;
        hashes[i].second =
            (hashes[i - 1].second + p2[counts[i] - 1] * str[i] % mod2) % mod2;
      }
    }
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int l1, l2, len;
    cin >> l1 >> l2 >> len;
    l1--;
    l2--;
    if (l1 > l2) {
      swap(l1, l2);
    }
    if (l1 == l2) {
      cout << "YES\n";
      continue;
    }
    if (ones[l1 + len] - ones[l1] != ones[l2 + len] - ones[l2]) {
      cout << "NO\n";
      continue;
    }
    pair<long long, long long> hash1;
    if (l1 == 0) {
      hash1 = hashes[len - 1];
    } else {
      if (str[l1] == '1') {
        if (lasts[l1] >= l1 + len - 1) {
          if (len % 2) {
            hash1.first = '1';
            hash1.second = '1';
          } else {
            hash1.first = 0;
            hash1.second = 0;
          }
        } else {
          if ((lasts[l1] - l1) % 2) {
            hash1.first =
                ((hashes[l1 + len - 1].first - hashes[lasts[l1]].first + mod1) *
                 invpwr1[counts[lasts[l1]]]) %
                mod1;
            hash1.second = ((hashes[l1 + len - 1].second -
                             hashes[lasts[l1]].second + mod2) *
                            invpwr2[counts[lasts[l1]]]) %
                           mod2;
          } else {
            if (counts[lasts[l1]] == 0) {
              hash1.first = ((hashes[l1 + len - 1].first -
                              hashes[lasts[l1]].first + mod1) *
                                 prime +
                             str[l1]) %
                            mod1;
              hash1.second = ((hashes[l1 + len - 1].second -
                               hashes[lasts[l1]].second + mod2) *
                                  prime +
                              str[l1]) %
                             mod2;
            } else {
              hash1.first = ((hashes[l1 + len - 1].first -
                              hashes[lasts[l1]].first + mod1) *
                                 invpwr1[counts[lasts[l1]] - 1] +
                             str[l1]) %
                            mod1;
              hash1.second = ((hashes[l1 + len - 1].second -
                               hashes[lasts[l1]].second + mod2) *
                                  invpwr2[counts[lasts[l1]] - 1] +
                              str[l1]) %
                             mod2;
            }
          }
        }
      } else {
        hash1.first =
            (hashes[l1 + len - 1].first - hashes[l1 - 1].first + mod1) *
            invpwr1[counts[l1 - 1]] % mod1;
        hash1.second =
            (hashes[l1 + len - 1].second - hashes[l1 - 1].second + mod2) *
            invpwr2[counts[l1 - 1]] % mod2;
      }
    }
    pair<long long, long long> hash2;
    if (str[l2] == '1') {
      if (lasts[l2] >= l2 + len - 1) {
        if (len % 2) {
          hash2.first = '1';
          hash2.second = '1';
        } else {
          hash2.first = 0;
          hash2.second = 0;
        }
      } else {
        if ((lasts[l2] - l2) % 2) {
          hash2.first =
              ((hashes[l2 + len - 1].first - hashes[lasts[l2]].first + mod1) *
               invpwr1[counts[lasts[l2]]]) %
              mod1;
          hash2.second =
              ((hashes[l2 + len - 1].second - hashes[lasts[l2]].second + mod2) *
               invpwr2[counts[lasts[l2]]]) %
              mod2;
        } else {
          if (counts[lasts[l2]] == 0) {
            hash2.first =
                ((hashes[l2 + len - 1].first - hashes[lasts[l2]].first + mod1) *
                     prime +
                 str[l2]) %
                mod1;
            hash2.second = ((hashes[l1 + len - 1].second -
                             hashes[lasts[l2]].second + mod2) *
                                prime +
                            str[l2]) %
                           mod2;
          } else {
            hash2.first =
                ((hashes[l2 + len - 1].first - hashes[lasts[l2]].first + mod1) *
                     invpwr1[counts[lasts[l2]] - 1] +
                 str[l2]) %
                mod1;
            hash2.second = ((hashes[l2 + len - 1].second -
                             hashes[lasts[l2]].second + mod2) *
                                invpwr2[counts[lasts[l2]] - 1] +
                            str[l2]) %
                           mod2;
          }
        }
      }
    } else {
      hash2.first = (hashes[l2 + len - 1].first - hashes[l2 - 1].first + mod1) *
                    invpwr1[counts[l2 - 1]] % mod1;
      hash2.second =
          (hashes[l2 + len - 1].second - hashes[l2 - 1].second + mod2) *
          invpwr2[counts[l2 - 1]] % mod2;
    }
    if (hash1 == hash2) {
      cout << "YES\n";
    } else {
      cout << "NO\n";
    }
  }
}