In this problem, 2 strings A and B of same length N are considered equivalent if following conditions are true for all 1 <= i, j <= N:
- (Ai != Aj) <=> (Bi != Bj)
- (Ai = Aj) <=> (Bi = Bj)
where Si denotes the i-th (1-based indexing) character of string S. It is easy to see that, if strings A and B are equivalent, strings B and C are equivalent, then strings A and C are also equivalent.
You are given 2 strings A and B of the same length N. You have to answer Q queries. Each query consists of 3 integers i, j, k, and for given query you are asked to check whether strings A[ i, i + k - 1] and B[ j, j + k - 1] are equivalent.
Input
The first line contains T - the number of test cases. Then T test cases follow.
Each test case consists of several lines.
- The first line contains string A. The second line contains string B. They both have same length N.
- The next line contains a positive integer Q - the number of queries you have to answer.
- Then Q lines follow, each line contains 3 integers i, j, k with meaning described in the statement. It is guaranteed that 1 ≤ i ≤ N - k + 1; 1 ≤ j ≤ N - k + 1.
Output
For each query, print "yes" (without quotes) if substrings are equivalent and "no" otherwise. Print answer for every query in new line.
Constraints
- Let SN be the sum of N over all T test cases, SQ be the sum of Q over all T test cases.
- 1 ≤ SN, SQ ≤ 100000
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial