#P7785. String Distance

String Distance

String Distance

Problem Description

For two strings SS and TT, you can do the following operation for arbitrary number of times: Select a string SS or TT, insert or delete a character at any position. The distance between two strings SS and TT is defined as the minimum number of operations to make SS and TT equal. You will be given two strings A[1..n],B[1..m]A[1..n],B[1..m] and qq queries. In each query, you will be given two integers lil_i and rir_i (1lirin1\leq l_i\leq r_i\leq n), you need to find the distance between the continous substring A[li..ri]A[l_i..r_i] and the whole string BB.

Input

The first line of the input contains a single integer TT (1T101 \leq T \leq 10), the number of test cases. For each case, the first line of the input contains a string AA consists of nn (1n1000001\leq n\leq 100\,000) lower-case English letters. The second line of the input contains a string BB consists of mm (1m201\leq m\leq 20) lower-case English letters. The third line of the input contains a single integer qq (1q1000001\leq q\leq 100\,000), denoting the number of queries. Then in the following qq lines, there are two integers li,ril_i,r_i (1lirin1\leq l_i\leq r_i\leq n) in each line, denoting a query.

Output

For each query, print a single line containing an integer, denoting the answer.

Sample Input

1
qaqaqwqaqaq
qaqwqaq
3
1 7
2 8
3 9

Sample Output

4
2
0

Source

2020 Multi-University Training Contest 2