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 JAVA):

Solution:
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Locale;
import java.util.StringTokenizer;

public class Solution implements Runnable {
	
	private PrintStream out;
	private BufferedReader in;
	private StringTokenizer st;
	
	public void solve() throws IOException {
		long time0 = System.currentTimeMillis();
		
		int n = nextInt();
		String t = next();
		int q = nextInt();
		int[] l1 = new int[q];
		int[] l2 = new int[q];
		int[] len = new int[q];
		for (int i = 0; i < q; i++) {
			l1[i] = nextInt() - 1;
			l2[i] = nextInt() - 1;
			len[i] = nextInt();
		}
		boolean[] answer = solve(n, t, q, l1, l2, len);
		for (int i = 0; i < q; i++) {
			if (answer[i]) {
				out.println("Yes");
			} else {
				out.println("No");
			}
		}
		
		System.err.println("time: " + (System.currentTimeMillis() - time0));
	}
	
	private boolean[] solve(int n, String t, int q, int[] l1, int[] l2, int[] len) {
		boolean[] tb = new boolean[n];
		for (int i = 0; i < n; i++) {
			if (t.charAt(i) == '0') {
				tb[i] = false;
			} else if (t.charAt(i) == '1') {
				tb[i] = true;
			} else {
				throw new RuntimeException("Botva in input!");
			}
		}
		int[] map = new int[n];
		boolean[] filtered = new boolean[n];
		int filteredCnt = 0;
		for (int i = 0; i < n; i++) {
			if (tb[i]) {
				map[i] = -1;
				if (filteredCnt > 0 && filtered[filteredCnt - 1]) {
					filteredCnt--;
				} else {
					filtered[filteredCnt++] = tb[i];
				}
			} else {
				map[i] = filteredCnt;
				filtered[filteredCnt++] = tb[i];
			}
		}
		SuffArray sa = new SuffArray(filtered, filteredCnt);
		int[] lcnt = new int[n];
		for (int i = 0; i < n; i++) {
			if (tb[i]) {
				if (i > 0) {
					lcnt[i] = lcnt[i - 1] + 1;
				} else {
					lcnt[i] = 1;
				}
			} else {
				lcnt[i] = 0;
			}
		}
		int[] rcnt = new int[n];
		for (int i = n - 1; i >= 0; i--) {
			if (tb[i]) {
				if (i < n - 1) {
					rcnt[i] = rcnt[i + 1] + 1;
				} else {
					rcnt[i] = 1;
				}
			} else {
				rcnt[i] = 0;
			}
		}
		boolean[] result = new boolean[q];
		for (int test = 0; test < q; test++) {
			result[test] = solve(l1[test], l2[test], len[test], map, lcnt, rcnt, sa);
		}
		return result;
	}

	private boolean solve(int l1, int l2, int len, int[] map, int[] lcnt, int[] rcnt, SuffArray sa) {
		if (rcnt[l1] >= len) {
			if (rcnt[l2] >= len) {
				return true;
			} else {
				return false;
			}
		} else {
			if (rcnt[l2] >= len) {
				return false;
			} else {
				// continue solve
			}
		}
		
		int r1 = l1 + len - 1;
		int r2 = l2 + len - 1;
		if (rcnt[l1] % 2 != rcnt[l2] % 2) {
			return false;
		} else {
			l1 += rcnt[l1];
			l2 += rcnt[l2];
		}
		if (lcnt[r1] % 2 != lcnt[r2] % 2) {
			return false;
		} else {
			r1 -= lcnt[r1];
			r2 -= lcnt[r2];
		}
		
		int ml1 = map[l1];
		int ml2 = map[l2];
		int mr1 = map[r1];
		int mr2 = map[r2];
		if (mr1 - ml1 != mr2 - ml2) {
			return false;
		}
		int mlen = mr1 - ml1 + 1;
		
		int clen = sa.lcp(sa.c_u[ml1], sa.c_u[ml2]);
		return mlen <= clen;
	}
	
	public class SuffArray {
		public byte[] s;
		public int[] p_i;
		public int[] c_u;
		public int[] lcp_i;
		public int[][] lcp_i_min;
		public int[] fln;
		public int[] pow;
		public SuffArray(boolean[] s, int slen) {
			this.s = new byte[slen + 1];
			for (int i = 0; i < slen; i++) {
				this.s[i] = s[i] ? (byte) 2 : (byte) 1;
			}
			this.s[slen] = (byte) 0;
			buildArray();
			buildLcp();
			buildMatrix();
		}
		private void buildArray() {
			p_i = new int[s.length];
			int[] p_i_buf = new int[p_i.length];
			c_u = new int[s.length];
			int[] c_u_buf = new int[c_u.length];
			int[] cnt_buf = new int[Math.max(256, s.length)];
			for (int i = 0; i < s.length; i++) {
				p_i[i] = i;
				c_u[i] = s[i];
			}
			for (int k = 1; true; k *= 2) {
				count_sort(p_i_buf, cnt_buf);
				assign_classes(c_u_buf, k / 2);
				if (c_u[p_i[p_i.length - 1]] == c_u.length - 1) {
					break;
				}
				for (int i = 0; i < p_i.length; i++) {
					p_i[i] = (p_i[i] - k + c_u.length) % c_u.length;
				}
			}
		}
		private void assign_classes(int[] c_u_buf, int k) {
			c_u_buf[p_i[0]] = 0;
			for (int i = 1; i < p_i.length; i++) {
				if (c_u[p_i[i]] == c_u[p_i[i - 1]] && c_u[(p_i[i] + k) % c_u.length] == c_u[(p_i[i - 1] + k) % c_u.length]) {
					c_u_buf[p_i[i]] = c_u_buf[p_i[i - 1]];
				} else {
					c_u_buf[p_i[i]] = c_u_buf[p_i[i - 1]] + 1;
				}
			}
			flush_buf(c_u, c_u_buf);
		}
		private void count_sort(int[] p_i_buf, int[] cnt_buf) {
			Arrays.fill(cnt_buf, 0);
			for (int u = 0; u < c_u.length; u++) {
				cnt_buf[c_u[u]]++;
			}
			int cnt_sum = 0;
			for (int c = 0; c < cnt_buf.length; c++) {
				cnt_sum = cnt_sum + cnt_buf[c];
				cnt_buf[c] = cnt_sum - cnt_buf[c];
			}
			for (int i = 0; i < p_i.length; i++) {
				p_i_buf[cnt_buf[c_u[p_i[i]]]++] = p_i[i];
			}
			flush_buf(p_i, p_i_buf);
		}
		private void flush_buf(int[] a, int[] buf) {
			for (int i = 0; i < a.length; i++) {
				a[i] = buf[i];
			}
		}
		private void buildLcp() {
			lcp_i = new int[s.length];
			lcp_i[0] = Integer.MIN_VALUE;
			int k = 0;
			for (int u = 0; u < s.length - 1; u++) {
				int v = p_i[c_u[u] - 1];
				while (s[u + k] == s[v + k]) {
					k++;
				}
				lcp_i[c_u[u]] = k;
				k = Math.max(0, k - 1);
			}
		}
		private void buildMatrix() {
			int pow = 0;
			for (int len = 1; len < lcp_i.length; len *= 2) {
				pow++;
			}
			lcp_i_min = new int[pow][lcp_i.length];
			for (int i = 0; i < lcp_i.length; i++) {
				lcp_i_min[0][i] = lcp_i[i];
			}
			for (int p = 1, len = 2; p < pow; p++, len *= 2) {
				for (int i = 0; i + len <= lcp_i.length; i++) {
					lcp_i_min[p][i] = Math.min(lcp_i_min[p - 1][i], lcp_i_min[p - 1][i + len / 2]);
				}
			}
			fln = new int[lcp_i.length + 1];
			fln[0] = Integer.MIN_VALUE;
			fln[1] = 0;
			for (int i = 2; i < fln.length; i++) {
				fln[i] = fln[i / 2] + 1;
			}
			this.pow = new int[pow];
			this.pow[0] = 1;
			for (int i = 1; i < this.pow.length; i++) {
				this.pow[i] = this.pow[i - 1] * 2;
			}
		}
		public int lcp(int i, int j) {
			if (i == j) {
				return s.length - p_i[i];
			} else {
				int u = Math.min(i, j) + 1;
				int v = Math.max(i, j);
				int p = fln[v - u + 1];
				return Math.min(lcp_i_min[p][u], lcp_i_min[p][v - pow[p] + 1]);
			}
		}
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}
	
	public long nextLong() throws IOException {
		return Long.parseLong(next());
	}
	
	public int nextInt() throws IOException {
		return Integer.parseInt(next());
	}
	
	public String next() throws IOException {
		while (!st.hasMoreTokens()) {
			String line = in.readLine();
			if (line == null) {
				return null;
			}
			st = new StringTokenizer(line);
		}
		return st.nextToken();
	}
	
	@Override
	public void run() {
		try {
			solve();
			out.close();
		} catch (Throwable e) {
			throw new RuntimeException(e);
		}
	}
	
	public Solution(String name) throws IOException {
		Locale.setDefault(Locale.US);
		if (name == null) {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintStream(new BufferedOutputStream(System.out));
		} else {
			in = new BufferedReader(new InputStreamReader(new FileInputStream(name + ".in")));
			out = new PrintStream(new BufferedOutputStream(new FileOutputStream(name + ".out")));
		}
		st = new StringTokenizer("");
	}
	
	public static void main(String[] args) throws IOException {
		new Thread(new Solution(null)).start();
	}
}