#include<bits/stdc++.h>
 
using namespace std;
 
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define fr(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
#define f(v,value) find(v.begin(),v.end(),value)
#define asc(a,n) sort(a,a+n)
#define desc(a,n,data_type) sort(a,a+n,greater<data_type>())
#define vasc(v)  sort(v.begin(),v.end())
#define vdesc(v,data_type) sort(v.begin(),v.end(),greater<data_type>())
const int mod = 1e9 + 7;         
const int N = 1e5 + 4;
 
int nooffac(long long a)
{
int c=0;
for(int i=1;i*i<=a;i++)
{
if(a%i==0)
{
c++;
if(a/i!=i)
c++;
}
return c;
}
}
 
ll check(ll val)
{
    ll k2=val;ll t=0;ll sum=0;
    val=val-val%5;
    while(k2>0)
    { 
        k2=k2/5;
         t++;
        //cout<<"k2"<<k2;
    }
    t--;//cout<<t<<" ";
     ll k1=pow(5,t);
     //cout<<k1;
    while(k1>=5)
    {
        
    
        
        sum+=val/k1;
 
        k1=k1/5;
        //cout<<sum<<"@ "<<k1;
        
    }
    //cout<<val<<"sum"<<sum<<" ";
    return sum;
}
 
ll bi_search(ll k)
{
    ll low=0;
    ll high=1e12;
    ll pos;
    while(high>low)
    {
        
        ll mid=(low+high)/2;
        //cout<<"mid"<<mid<<" ";
        if(check(mid)>=k)
        {
            pos=mid; //cout<<pos<<" ";
            high=mid-1;
        }
        else
        low=mid+1;
    }
   return pos;
}

ll common(string str1, string str2, ll m, ll n)
{
    
    ll longest[m + 1][n + 1];
    ll l = 0; 
 
    
    for (int i = 0; i <= m; i++)
    {
        for (int j = 0; j <= n; j++)
        {
            
            if (i == 0 || j == 0)
                longest[i][j] = 0;
 
            else if (str1[i - 1] == str2[j - 1]) {
                longest[i][j] = longest[i - 1][j - 1] + 1;
                l = max(l, longest[i][j]);
            }
            else
                longest[i][j] = 0;
        }
    }
    return l;
}
int main()
{
   
   ll n;
   lscn(n);
   fr(i,0,n)
   {
    string str1,str2;
    cin>>str1>>str2;
    ll m=str1.length();
    ll n=str2.length();
    cout<<m+n-2*common(str1,str2,m,n)<<endl;
   }   
}