• محدودیت زمان: ۱ ثانیه
  • محدودیت حافظه: ۲۵۶ مگابایت

Mathematicians have always loved generalizing mathematics to everything. They even contributed lots of optimizations and valuable formulas to Computer Science. Have you heard about String Multiplication? What do you think will happen if we write the following code in python?

print (3 * "abc")

As you might have guessed, it prints "abcabcabc". It is equal to

print("abc" + "abc" + "abc")

We define string SS is divisible by string TT, if there is some number kN0k \in \mathbb{N} \cup {0} which satisfies the equation S=k×TS = k \times T .

Your task is simple. Given two strings SS and TT. What is the minimum number of characters which should be removed from SS, so SS is divisible by TT?

ورودی

The first line of the input contains QQ the number of the test cases. 1Q1001 \leq Q \leq 100

Each test case consists of two lines. The first line contains string SS consisting of lowercase English letters. 0S1040 \leq |S| \leq 10^4

The second line contains string TT consisting of lowercase English letters. 0T1040 \leq |T| \leq 10^4

خروجی

For each test case print a single integer, the minimum number of characters which should be removed.

مثال‌ها

ورودی نمونه ۱

5
babbaba
ab
dictate
acid

abc
p
q
dddabcbcbcacccbccbad
abc
Plain text

خروجی نمونه ۱

3
7
0
1
14
Plain text

ارسال پاسخ برای این سؤال
فایلی انتخاب نشده است.