Alice has a string consisting of characters 'A', 'B' and 'C'. Bob can use the following transitions on any substring of our string in any order any number of times: 

  * A <image> BC
  * B <image> AC
  * C <image> AB
  * AAA <image> empty string 



Note that a substring is one or more consecutive characters. For given queries, determine whether it is possible to obtain the target string from source.

Input

The first line contains a string S (1 ≤ |S| ≤ 105). The second line contains a string T (1 ≤ |T| ≤ 105), each of these strings consists only of uppercase English letters 'A', 'B' and 'C'.

The third line contains the number of queries Q (1 ≤ Q ≤ 105).

The following Q lines describe queries. The i-th of these lines contains four space separated integers ai, bi, ci, di. These represent the i-th query: is it possible to create T[ci..di] from S[ai..bi] by applying the above transitions finite amount of times?

Here, U[x..y] is a substring of U that begins at index x (indexed from 1) and ends at index y. In particular, U[1..|U|] is the whole string U.

It is guaranteed that 1 ≤ a ≤ b ≤ |S| and 1 ≤ c ≤ d ≤ |T|.

Output

Print a string of Q characters, where the i-th character is '1' if the answer to the i-th query is positive, and '0' otherwise.

Example

Input

AABCCBAAB
ABCB
5
1 3 1 2
2 2 2 4
7 9 1 1
3 4 2 3
4 5 1 3


Output

10011

Note

In the first query we can achieve the result, for instance, by using transitions <image>.

The third query asks for changing AAB to A — but in this case we are not able to get rid of the character 'B'.
import java.io.*;
import java.util.*;

public class Main {
    public Main() throws IOException {
    }

    static void solve() throws IOException {
        String s = input.readLine();
        String t = input.readLine();
        rl();
        int n = ni2();

        int ls = s.length();
        int lt = t.length();
        int count_s[] = new int[ls]; // count the numbers of B and C in S
        int count_t[] = new int[lt];
        for (int i = 0; i < ls; i++) {
            if (s.charAt(i) == 'B' || s.charAt(i) == 'C') {
                if (i == 0) count_s[i] = 1;
                else count_s[i] = count_s[i - 1] + 1;
            }
            else {
                if (i == 0) count_s[i] = 0;
                else count_s[i] = count_s[i - 1];
            }
        }
        for (int i = 0; i < lt; i++) {
            if (t.charAt(i) == 'B' || t.charAt(i) == 'C') {
                if (i == 0) count_t[i] = 1;
                else count_t[i] = count_t[i - 1] + 1;
            }
            else {
                if (i == 0) count_t[i] = 0;
                else count_t[i] = count_t[i - 1];
            }
        }

        int nearest_bs[] = new int[ls];
        int nearest_bt[] = new int[lt];

        for (int i = 0; i < ls; i++) {
            if (s.charAt(i) == 'B' || s.charAt(i) == 'C') {
                nearest_bs[i] = i;
            } else {
                if (i == 0) nearest_bs[i] = -1;
                else nearest_bs[i] = nearest_bs[i - 1];
            }
        }

        for (int i = 0; i < lt; i++) {
            if (t.charAt(i) == 'B' || t.charAt(i) == 'C') {
                nearest_bt[i] = i;
            } else {
                if (i == 0) nearest_bt[i] = -1;
                else nearest_bt[i] = nearest_bt[i - 1];
            }
        }

        for (int i = 0; i < n; i++) {
            rl();
            int a = ni2() - 1, b = ni2() - 1, c = ni2() - 1, d = ni2() - 1;
            int bs = a > 0 ? count_s[b] - count_s[a - 1] : count_s[b];
            int bt = c > 0 ? count_t[d] - count_t[c - 1] : count_t[d];
            int as = Math.min(b - nearest_bs[b], b - a + 1);
            int at = Math.min(d - nearest_bt[d], d - c + 1);
            if (bs > bt) ans.append("0");
            else if (bs == bt) {
                if (as >= at & (as - at) % 3 == 0) ans.append("1");
                else ans.append("0");
            } else {
                if ((bt - bs) % 2 != 0) ans.append("0");
                else {
                    if (bs == 0) {
                        if (as > at) ans.append("1");
                        else ans.append("0");
                    } else {
                        if (as >= at) ans.append("1");
                        else ans.append("0");
                    }
                }
            }
        }

        output.write(ans.toString());
        output.flush();
        output.close();
    }

    public static void main(String[] args) throws IOException {
        new Main().solve();
    }

    static BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
    static BufferedWriter output = new BufferedWriter(new OutputStreamWriter(System.out));
    static StringBuilder ans = new StringBuilder();
    static StringTokenizer stringTokenizer;

    static int ni1() throws IOException {
        return Integer.parseInt(input.readLine());
    }

    static int ni2() throws IOException {
        return Integer.parseInt(stringTokenizer.nextToken());
    }

    static long nl1() throws IOException {
        return Long.parseLong(input.readLine());
    }

    static long nl2() {
        return Long.parseLong(stringTokenizer.nextToken());
    }

    static void rl() throws IOException {
        stringTokenizer = new StringTokenizer(input.readLine());
    }
}