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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.IntStream;
import java.io.OutputStream;
import java.util.function.IntUnaryOperator;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.io.Closeable;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "", 1 << 27);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastInput in = new FastInput(inputStream);
            FastOutput out = new FastOutput(outputStream);
            DReachableStrings solver = new DReachableStrings();
            solver.solve(1, in, out);
            out.close();
        }
    }

    static class DReachableStrings {
        public void solve(int testNumber, FastInput in, FastOutput out) {
            int n = in.readInt();
            char[] s = new char[n];
            in.readString(s, 0);
            int[] indexes = new int[n];
            StringBuilder reorder = new StringBuilder(n);
            IntegerDeque dq = new IntegerDequeImpl(n);
            for (int i = 0; i < n; i++) {
                if (s[i] == '0') {
                    while (!dq.isEmpty()) {
                        int tail = dq.removeLast();
                        reorder.append(s[tail]);
                        indexes[tail] = reorder.length() - 1;
                    }
                    reorder.append(s[i]);
                    indexes[i] = reorder.length() - 1;
                } else {
                    if (dq.isEmpty()) {
                        dq.addLast(i);
                    } else {
                        while (!dq.isEmpty()) {
                            int tail = dq.removeLast();
                            indexes[tail] = -1;
                        }
                        indexes[i] = -1;
                    }
                }
            }
            if (!dq.isEmpty()) {
                reorder.append('1');
                indexes[dq.removeLast()] = reorder.length() - 1;
            }
            int[] newS = reorder.chars().toArray();
            Hash h31 = new Hash(newS.length, 31);
            Hash h41 = new Hash(newS.length, 41);
            h31.populate(i -> newS[i], newS.length);
            h41.populate(i -> newS[i], newS.length);
            int[] next = new int[n];
            int[] last = new int[n];
            for (int i = 0; i < n; i++) {
                if (i == 0) {
                    last[i] = -1;
                } else {
                    last[i] = last[i - 1];
                }
                if (s[i] == '0') {
                    last[i] = i;
                }
            }

            for (int i = n - 1; i >= 0; i--) {
                if (i == n - 1) {
                    next[i] = n;
                } else {
                    next[i] = next[i + 1];
                }
                if (s[i] == '0') {
                    next[i] = i;
                }
            }

            int q = in.readInt();
            for (int i = 0; i < q; i++) {
                int l1 = in.readInt() - 1;
                int l2 = in.readInt() - 1;
                int len = in.readInt();
                int r1 = l1 + len - 1;
                int r2 = l2 + len - 1;
                boolean contain1 = next[l1] <= r1;
                boolean contain2 = next[l2] <= r2;
                if (contain1 != contain2) {
                    out.println("No");
                    continue;
                }
                if (!contain1 && !contain2) {
                    out.println("Yes");
                    continue;
                }
                if (parity(l1, next[l1]) != parity(l2, next[l2]) ||
                        parity(r1, last[r1]) != parity(r2, last[r2])) {
                    out.println("No");
                    continue;
                }
                l1 = indexes[next[l1]];
                r1 = indexes[last[r1]];
                l2 = indexes[next[l2]];
                r2 = indexes[last[r2]];
                if (h31.hashVerbose(l1, r1) == h31.hashVerbose(l2, r2) &&
                        h41.hashVerbose(l1, r1) == h41.hashVerbose(l2, r2)) {
                    out.println("Yes");
                    continue;
                }
                out.println("No");
            }
        }

        public int parity(int a, int b) {
            return (b - a) & 1;
        }

    }

    static interface IntegerStack {
        void addLast(int x);

        int removeLast();

        boolean isEmpty();

    }

    static class Power {
        final Modular modular;

        public Power(Modular modular) {
            this.modular = modular;
        }

        public int pow(int x, int n) {
            if (n == 0) {
                return modular.valueOf(1);
            }
            long r = pow(x, n >> 1);
            r = modular.valueOf(r * r);
            if ((n & 1) == 1) {
                r = modular.valueOf(r * x);
            }
            return (int) r;
        }

        public int inverseByFermat(int x) {
            return pow(x, modular.m - 2);
        }

    }

    static interface IntegerIterator {
        boolean hasNext();

        int next();

    }

    static class IntegerDequeImpl implements IntegerDeque {
        private int[] data;
        private int bpos;
        private int epos;
        private static final int[] EMPTY = new int[0];
        private int n;

        public IntegerDequeImpl(int cap) {
            if (cap == 0) {
                data = EMPTY;
            } else {
                data = new int[cap];
            }
            bpos = 0;
            epos = 0;
            n = cap;
        }

        private void expandSpace(int len) {
            while (n < len) {
                n = Math.max(n + 10, n * 2);
            }
            int[] newData = new int[n];
            if (bpos <= epos) {
                if (bpos < epos) {
                    System.arraycopy(data, bpos, newData, 0, epos - bpos);
                }
            } else {
                System.arraycopy(data, bpos, newData, 0, data.length - bpos);
                System.arraycopy(data, 0, newData, data.length - bpos, epos);
            }
            epos = size();
            bpos = 0;
            data = newData;
        }

        public IntegerIterator iterator() {
            return new IntegerIterator() {
                int index = bpos;


                public boolean hasNext() {
                    return index != epos;
                }


                public int next() {
                    int ans = data[index];
                    index = IntegerDequeImpl.this.next(index);
                    return ans;
                }
            };
        }

        public int removeLast() {
            int ans = data[last(epos)];
            epos = last(epos);
            return ans;
        }

        public void addLast(int x) {
            ensureMore();
            data[epos] = x;
            epos = next(epos);
        }

        private int last(int x) {
            return (x == 0 ? n : x) - 1;
        }

        private int next(int x) {
            return x + 1 >= n ? 0 : x + 1;
        }

        private void ensureMore() {
            if (next(epos) == bpos) {
                expandSpace(n + 1);
            }
        }

        public int size() {
            int ans = epos - bpos;
            if (ans < 0) {
                ans += data.length;
            }
            return ans;
        }

        public boolean isEmpty() {
            return bpos == epos;
        }

        public String toString() {
            StringBuilder builder = new StringBuilder();
            for (IntegerIterator iterator = iterator(); iterator.hasNext(); ) {
                builder.append(iterator.next()).append(' ');
            }
            return builder.toString();
        }

    }

    static class FastInput {
        private final InputStream is;
        private byte[] buf = new byte[1 << 20];
        private int bufLen;
        private int bufOffset;
        private int next;

        public FastInput(InputStream is) {
            this.is = is;
        }

        private int read() {
            while (bufLen == bufOffset) {
                bufOffset = 0;
                try {
                    bufLen = is.read(buf);
                } catch (IOException e) {
                    bufLen = -1;
                }
                if (bufLen == -1) {
                    return -1;
                }
            }
            return buf[bufOffset++];
        }

        public void skipBlank() {
            while (next >= 0 && next <= 32) {
                next = read();
            }
        }

        public int readInt() {
            int sign = 1;

            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+' ? 1 : -1;
                next = read();
            }

            int val = 0;
            if (sign == 1) {
                while (next >= '0' && next <= '9') {
                    val = val * 10 + next - '0';
                    next = read();
                }
            } else {
                while (next >= '0' && next <= '9') {
                    val = val * 10 - next + '0';
                    next = read();
                }
            }

            return val;
        }

        public int readString(char[] data, int offset) {
            skipBlank();

            int originalOffset = offset;
            while (next > 32) {
                data[offset++] = (char) next;
                next = read();
            }

            return offset - originalOffset;
        }

    }

    static class Modular {
        int m;

        public Modular(int m) {
            this.m = m;
        }

        public Modular(long m) {
            this.m = (int) m;
            if (this.m != m) {
                throw new IllegalArgumentException();
            }
        }

        public Modular(double m) {
            this.m = (int) m;
            if (this.m != m) {
                throw new IllegalArgumentException();
            }
        }

        public int valueOf(int x) {
            x %= m;
            if (x < 0) {
                x += m;
            }
            return x;
        }

        public int valueOf(long x) {
            x %= m;
            if (x < 0) {
                x += m;
            }
            return (int) x;
        }

        public int mul(int x, int y) {
            return valueOf((long) x * y);
        }

        public int plus(int x, int y) {
            return valueOf(x + y);
        }

        public String toString() {
            return "mod " + m;
        }

    }

    static interface IntegerDeque extends IntegerStack {
    }

    static class FastOutput implements AutoCloseable, Closeable, Appendable {
        private StringBuilder cache = new StringBuilder(10 << 20);
        private final Writer os;

        public FastOutput append(CharSequence csq) {
            cache.append(csq);
            return this;
        }

        public FastOutput append(CharSequence csq, int start, int end) {
            cache.append(csq, start, end);
            return this;
        }

        public FastOutput(Writer os) {
            this.os = os;
        }

        public FastOutput(OutputStream os) {
            this(new OutputStreamWriter(os));
        }

        public FastOutput append(char c) {
            cache.append(c);
            return this;
        }

        public FastOutput append(String c) {
            cache.append(c);
            return this;
        }

        public FastOutput println(String c) {
            return append(c).println();
        }

        public FastOutput println() {
            cache.append(System.lineSeparator());
            return this;
        }

        public FastOutput flush() {
            try {
                os.append(cache);
                os.flush();
                cache.setLength(0);
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
            return this;
        }

        public void close() {
            flush();
            try {
                os.close();
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }

        public String toString() {
            return cache.toString();
        }

    }

    static class Hash {
        public static final Modular MOD = new Modular((int) (1e9 + 7));
        public static final Power POWER = new Power(MOD);
        private int[] inverse;
        private int[] xs;
        private int[] hash;

        public Hash(Hash model) {
            inverse = model.inverse;
            hash = new int[model.hash.length];
            xs = model.xs;
        }

        public Hash(int size, int x) {
            inverse = new int[size + 1];
            hash = new int[size + 1];
            xs = new int[size + 1];
            int invX = POWER.inverseByFermat(x);
            inverse[0] = 1;
            xs[0] = 1;
            for (int i = 1; i <= size; i++) {
                this.inverse[i] = MOD.mul(this.inverse[i - 1], invX);
                xs[i] = MOD.mul(xs[i - 1], x);
            }
        }

        public <T> void populate(IntUnaryOperator function, int n) {
            hash[0] = function.applyAsInt(0);
            for (int i = 1; i < n; i++) {
                hash[i] = MOD.valueOf(hash[i - 1] + (long) function.applyAsInt(i) * xs[i]);
            }
        }

        public int hashVerbose(int l, int r) {
            int h = hash(l, r);
            h = MOD.plus(h, xs[r - l + 1]);
            return h;
        }

        public int hash(int l, int r) {
            long h = hash[r];
            if (l > 0) {
                h -= hash[l - 1];
                h *= inverse[l];
            }
            return MOD.valueOf(h);
        }

    }
}