String Distance

아직 제출이 없습니다시간 제한4초메모리 제한512 MB

문제

For two strings SS and TT, you can do the following operation an 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]A\[1..n] and B\[1..m]B\[1..m], and also qq queries.

In each query, you will be given two integers l_il\_i and r_ir\_i (1l_ir_in1 \leq l\_i \leq r\_i \leq n). You need to find the distance between the continuous substring A\[l_i..r_i]A\[l\_i..r\_i] and the whole string BB.

입력

The first line contains a single integer TT (1T101 \leq T \leq 10), the number of test cases. For each test case:

The first line contains a string AA which consists of nn (1n100,0001 \leq n \leq 100\\,000) lower-case English letters.

The second line contains a string BB which consists of mm (1m201 \leq m \leq 20) lower-case English letters.

The third line contains a single integer qq (1q100,0001 \leq q \leq 100\\,000) denoting the number of queries.

Each of the following qq lines contains two integers l_il\_i and r_ir\_i (1l_ir_in1 \leq l\_i \leq r\_i \leq n) describing a query.

출력

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