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;
vector<int> build_sa(const string &s) {
  const int n = (int)s.size();
  int m = 256;
  vector<int> c(max(m, n)), x(n), y(n), sa(n);
  for (int i = 0; i < m; i++) c[i] = 0;
  for (int i = 0; i < n; i++) c[x[i] = s[i]]++;
  for (int i = 1; i < m; i++) c[i] += c[i - 1];
  for (int i = n - 1; i >= 0; i--) sa[--c[x[i]]] = i;
  for (int move = 1; move < n; move <<= 1) {
    int p = 0;
    for (int i = n - move; i < n; i++) y[p++] = i;
    for (int i = 0; i < n; i++)
      if (sa[i] >= move) y[p++] = sa[i] - move;
    for (int i = 0; i < m; i++) c[i] = 0;
    for (int i = 0; i < n; i++) c[x[i]]++;
    for (int i = 1; i < m; i++) c[i] += c[i - 1];
    for (int i = n - 1; i >= 0; i--) sa[--c[x[y[i]]]] = y[i];
    m = 0;
    y[sa[0]] = m++;
    for (int i = 1; i < n; i++) {
      y[sa[i]] = x[sa[i]] == x[sa[i - 1]] && sa[i] + move < n &&
                         sa[i - 1] + move < n &&
                         x[sa[i] + move] == x[sa[i - 1] + move]
                     ? m - 1
                     : m++;
    }
    if (m == n) break;
    x.swap(y);
  }
  return sa;
}
vector<int> build_height(const string &s, const vector<int> &sa,
                         vector<int> &r) {
  const int n = (int)s.size();
  int l = 0;
  vector<int> h(n, 0);
  r.resize(n);
  for (int i = 0; i < n; i++) r[sa[i]] = i;
  for (int i = 0; i < n; i++) {
    if (l) l--;
    if (r[i] == 0) continue;
    const int j = sa[r[i] - 1];
    while (s[i + l] == s[j + l]) l++;
    h[r[i]] = l;
  }
  return h;
}
vector<vector<int>> build_spt(const vector<int> &s) {
  const int n = (int)s.size();
  const int nb = 32 - __builtin_clz(n);
  vector<vector<int>> spt(nb, vector<int>(n));
  for (int i = 0; i < n; i++) spt[0][i] = s[i];
  for (int b = 1; b < nb; b++) {
    for (int i = 0; i + (1 << b) <= n; i++) {
      spt[b][i] = min(spt[b - 1][i], spt[b - 1][i + (1 << (b - 1))]);
    }
  }
  return spt;
}
int query_spt(const vector<vector<int>> &spt, const int i, const int j) {
  const int b = 32 - __builtin_clz(j - i + 1) - 1;
  return min(spt[b][i], spt[b][j - (1 << b) + 1]);
}
string t_del;
vector<int> SA, R, H;
vector<vector<int>> SPT;
int cmp_t_del(const int i, const int j) {
  int a = R[i], b = R[j];
  if (a > b) swap(a, b);
  if (a == b) return INT_MAX;
  return query_spt(SPT, a + 1, b);
}
bool t_del_same(const int i1, const int j1, const int i2, const int j2,
                const bool f1, const bool b1, const bool f2, const bool b2) {
  if (f1 && f2) return t_del_same(i1, j1, i2, j2, false, b1, false, b2);
  if (b1 && b2) return t_del_same(i1, j1, i2, j2, f1, false, f2, false);
  if (f1)
    return i2 <= j2 && t_del[i2] == '1' &&
           t_del_same(i1, j1, i2 + 1, j2, false, b1, f2, b2);
  if (b1)
    return i2 <= j2 && t_del[j2] == '1' &&
           t_del_same(i1, j1, i2, j2 - 1, f1, false, f2, b2);
  if (f2)
    return i1 <= j1 && t_del[i1] == '1' &&
           t_del_same(i1 + 1, j1, i2, j2, f1, b1, false, b2);
  if (b2)
    return i1 <= j1 && t_del[j1] == '1' &&
           t_del_same(i1, j1 - 1, i2, j2, f1, b1, f2, false);
  if (j1 - i1 != j2 - i2) return false;
  return cmp_t_del(i1, i2) >= j1 - i1 + 1;
}
void print(const vector<int> &s) {
  for (int v : s) clog << ' ' << v;
  clog << endl;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  string t;
  cin >> t;
  t_del.clear();
  vector<int> t_pos;
  for (int i = 0; i < n;) {
    if (i + 1 < (int)t.size() && t[i] == '1' && t[i + 1] == '1') {
      t_pos.push_back((int)t_del.size());
      t_pos.push_back((int)t_del.size());
      i += 2;
    } else {
      t_del.push_back(t[i]);
      t_pos.push_back((int)t_del.size());
      i++;
    }
  }
  SA = build_sa(t_del);
  H = build_height(t_del, SA, R);
  SPT = build_spt(H);
  vector<int> t_ones = {0};
  int ones = 0;
  for (int i = 0; i < n; i++) {
    if (t[i] == '1') ones++;
    t_ones.push_back(ones);
  }
  vector<int> left_zero(n);
  int lz = -1;
  for (int i = 0; i < n; i++) {
    if (t[i] == '0') lz = i;
    left_zero[i] = lz;
  }
  vector<int> rigt_zero(n);
  int rz = n;
  for (int i = n - 1; i >= 0; i--) {
    if (t[i] == '0') rz = i;
    rigt_zero[i] = rz;
  }
  auto judge = [&](const int l1, const int l2, const int len) -> bool {
    if (t_ones[l1 + len] - t_ones[l1] != t_ones[l2 + len] - t_ones[l2])
      return false;
    const int i1 = rigt_zero[l1], i2 = rigt_zero[l2];
    const int j1 = left_zero[l1 + len - 1], j2 = left_zero[l2 + len - 1];
    if ((i1 <= j1) != (i2 <= j2)) return false;
    if (i1 > j1) return true;
    if (!t_del_same(t_pos[i1] - 1, t_pos[j1] - 1, t_pos[i2] - 1, t_pos[j2] - 1,
                    (i1 - l1) % 2, (i1 + len - 1 - j1) % 2, (i2 - l2) % 2,
                    (i2 + len - 1 - j2) % 2))
      return false;
    return true;
  };
  int q;
  cin >> q;
  while (q--) {
    int l1, l2, len;
    cin >> l1 >> l2 >> len;
    cout << (judge(l1 - 1, l2 - 1, len) ? "Yes" : "No") << endl;
  }
  return 0;
}