#P7785. String Distance
String Distance
String Distance
Problem Description
For two strings and , you can do the following operation for arbitrary number of times: Select a string or , insert or delete a character at any position. The distance between two strings and is defined as the minimum number of operations to make and equal. You will be given two strings and queries. In each query, you will be given two integers and (), you need to find the distance between the continous substring and the whole string .
Input
The first line of the input contains a single integer (), the number of test cases. For each case, the first line of the input contains a string consists of () lower-case English letters. The second line of the input contains a string consists of () lower-case English letters. The third line of the input contains a single integer (), denoting the number of queries. Then in the following lines, there are two integers () 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